darippaxp Posted August 30, 2011 Posted August 30, 2011 hey everyone i just need some help with my droplist, i want the items to open up a certain webpage when the user clicks on it, here is my code so far ; AutoIt 3.0.103 example ; 17 Jan 2005 - CyberSlug ; This script shows manual positioning of all controls; ; there are much better methods of positioning... #include <GuiConstantsEx.au3> #include <guiconstants.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; GUI #region - gui create $gui= guicreate('microstems internet console',800,200) winsetontop($gui, "",1) #endregion ; PIC GuiCtrlCreatePic("logo4.gif",0,0, 800,200) GuiCtrlSetColor(-1,0xffffff) dropmenu() Func dropmenu() Local $defaultstatus = "Ready", $status, $filemenu, $fileitem Local $helpmenu, $saveitem, $infoitem, $exititem, $recentfilesmenu Local $separator1, $viewmenu, $viewstatusitem, $okbutton, $cancelbutton Local $statuslabel, $msg, $file $filemenu = GUICtrlCreateMenu("&file") $webmenu = guictrlcreatemenu("µsystems web menu") $menuitem = guictrlcreatemenuitem("microsystems station headquarters", $webmenu) $menuitem = guictrlcreatemenuitem("microsystems music fanpages", $webmenu) $menuitem = guictrlcreatemenuitem("runescape.com", $webmenu) $socialnetworks = guictrlcreatemenu("&social networks") $menuitem = guictrlcreatemenuitem("facebook.com", $socialnetworks) $menuitem = guictrlcreatemenuitem("myspace.com", $socialnetworks) $menuitem = guictrlcreatemenuitem("youtube.com", $socialnetworks) $menuitem = guictrlcreatemenuitem("twitter.com", $socialnetworks) $music = guictrlcreatemenu("microsystems music fanpages") $menuitem = guictrlcreatemenuitem("three six mafia", $music) $menuitem = guictrlcreatemenuitem("eminem", $music) $menuitem = guictrlcreatemenuitem("lil joe", $music) $menuitem = guictrlcreatemenuitem("o-dubb", $music) $menuitem = guictrlcreatemenuitem("rick ross", $music) $games = guictrlcreatemenu("&games") $menuitem = guictrlcreatemenuitem("runescape", $games) $menuitem = guictrlcreatemenuitem("knights online", $games) $menuitem = guictrlcreatemenuitem("world of warcraft", $games) $menuitem = guictrlcreatemenuitem("project torque", $games) $fileitem = GUICtrlCreateMenuItem("open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $saveitem = GUICtrlCreateMenuItem("save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $exititem = GUICtrlCreateMenuItem("exit", $filemenu) $recentfilesmenu = GUICtrlCreateMenu("recent Files", $filemenu, 1) GUICtrlSetState(-1, $GUI_CHECKED) $okbutton = GUICtrlCreateButton("ok", 1000, 150, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("cancel", 1000, 150, 70, 20) $separator1 = GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line $viewmenu = GUICtrlCreateMenu("view", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $fileitem Then $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu) EndIf If $msg = $viewstatusitem Then If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf EndIf WEnd GUIDelete() EndFunc ;==>Example ; GUI MESSAGE LOOP GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEnd so if someone clicks on runescape it'll open up firefox or chrome and go to runescape.com or if they click on facebook it'll go to facebook.com and can u help me make it to where it searches if the user has chrome and where it is located and open the right file and check if the user has chrome and if they don't then open firefox instead. thanks if anyone could help
darippaxp Posted August 31, 2011 Author Posted August 31, 2011 someone please help i know its not hard
monoscout999 Posted August 31, 2011 Posted August 31, 2011 Hi and welcome... next time put your code between tags like this expandcollapse popup[/AUTOIT] your code must be between the brackets "]Your code[" About your code it have several errors, like using an unique variable to store all the ID of the munu Items, you will not be able to use those menu items later. I delete the last While loop because it seems useless, another thing that i change is the If method in the main loop because it seems a madness write all those "If Then, If Then If Then, etc." for all the cases you have, i change it to Swtich Case. I use ShellExecute to Open a WebPage with the default browser. [AUTOIT]#include <GuiConstantsEx.au3> #include <guiconstants.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; GUI #region - gui create $gui = GUICreate('microstems internet console', 800, 200) WinSetOnTop($gui, "", 1) #endregion - gui create ; PIC GUICtrlCreatePic("logo4.gif", 0, 0, 800, 200) GUICtrlSetColor(-1, 0xffffff) dropmenu() Func dropmenu() Local $defaultstatus = "Ready", $status, $filemenu, $fileitem Local $helpmenu, $saveitem, $infoitem, $exititem, $recentfilesmenu Local $separator1, $viewmenu, $viewstatusitem, $okbutton, $cancelbutton Local $statuslabel, $msg, $file $filemenu = GUICtrlCreateMenu("&file") $webmenu = GUICtrlCreateMenu("µsystems web menu") $menuitem1 = GUICtrlCreateMenuItem("microsystems station headquarters", $webmenu) $menuitem2 = GUICtrlCreateMenuItem("microsystems music fanpages", $webmenu) $menuitem3 = GUICtrlCreateMenuItem("runescape.com", $webmenu) $socialnetworks = GUICtrlCreateMenu("&social networks") $menuitem4 = GUICtrlCreateMenuItem("facebook.com", $socialnetworks) $menuitem5 = GUICtrlCreateMenuItem("myspace.com", $socialnetworks) $menuitem6 = GUICtrlCreateMenuItem("youtube.com", $socialnetworks) $menuitem7 = GUICtrlCreateMenuItem("twitter.com", $socialnetworks) $music = GUICtrlCreateMenu("microsystems music fanpages") $menuitem8 = GUICtrlCreateMenuItem("three six mafia", $music) $menuitem9 = GUICtrlCreateMenuItem("eminem", $music) $menuitem10 = GUICtrlCreateMenuItem("lil joe", $music) $menuitem11 = GUICtrlCreateMenuItem("o-dubb", $music) $menuitem12 = GUICtrlCreateMenuItem("rick ross", $music) $games = GUICtrlCreateMenu("&games") $menuitem13 = GUICtrlCreateMenuItem("runescape", $games) $menuitem14 = GUICtrlCreateMenuItem("knights online", $games) $menuitem15 = GUICtrlCreateMenuItem("world of warcraft", $games) $menuitem16 = GUICtrlCreateMenuItem("project torque", $games) $fileitem = GUICtrlCreateMenuItem("open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $saveitem = GUICtrlCreateMenuItem("save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $exititem = GUICtrlCreateMenuItem("exit", $filemenu) $recentfilesmenu = GUICtrlCreateMenu("recent Files", $filemenu, 1) GUICtrlSetState(-1, $GUI_CHECKED) $okbutton = GUICtrlCreateButton("ok", 1000, 150, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("cancel", 1000, 150, 70, 20) $separator1 = GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line $viewmenu = GUICtrlCreateMenu("view", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg ; Beacuse is a madness write If then If then for every item Case $GUI_EVENT_CLOSE Exit Case $fileitem $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu) Case $viewstatusitem If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf Case $menuitem3 ShellExecute("http://www.runescape.com") EndSwitch WEnd GUIDelete() EndFunc ;==>dropmenu
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now