joncom Posted April 19, 2005 Posted April 19, 2005 I'm curious how to make the common drop down links that most programs have, such as "File > Edit > View> Help" etc... Also, witht he GUI that I have, the "x" that should close the program (in top right) does not seem to work. How can I make it function.
buzz44 Posted April 19, 2005 Posted April 19, 2005 expandcollapse popup#include <GUIConstants.au3> GUICreate("My GUI menu",300,200) Global $defaultstatus = "Ready" Global $status $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) GUICtrlSetState(-1,$GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu ("?") $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu) GUICtrlSetState(-1,$GUI_DISABLE) $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu) $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu) $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1) $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu) GUICtrlSetState(-1,$GUI_CHECKED) $okbutton = GUICtrlCreateButton ("OK",50,130,70,20) GUICtrlSetState(-1,$GUI_FOCUS) $cancelbutton = GUICtrlCreateButton ("Cancel",180,130,70,20) $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 If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop If $msg = $infoitem Then Msgbox(0,"Info","Only a test...") WEnd GUIDelete() Exit I think you need one of the latest BETA's. qq
joncom Posted April 19, 2005 Author Posted April 19, 2005 (edited) I have whatever the latest AutoIt version is.... just got few days ago... I have the following: #include <GUIConstants.au3> GUICreate("test gui", 180, 150) GUISetState () $menuFile = GUICtrlCreateMenu ("&File") $menuAbout = GUICtrlCreateMenu ("&About") $itemExit = GUICtrlCreateMenuitem ("E&xit",$menuFile) $itemAbout = GUICtrlCreateMenuitem ("About Us",$menuAbout) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $itemExit Then ExitLoop Wend GUIDelete() Exit However, the exit button doesn't seem to work... this still goes for the "X" button in the top right as well. Edited April 19, 2005 by joncom
randallc Posted April 19, 2005 Posted April 19, 2005 joncom, FYI, your file works on my computer with either exit! Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
zcoacoaz Posted April 19, 2005 Posted April 19, 2005 Works fine here. Exactly what autoit version do you have? [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]
joncom Posted April 19, 2005 Author Posted April 19, 2005 (edited) I'm using 3.1.1.0... hmmm it seems that other script that I didnt' bother mentioning is screwing it up. While $complete = 0 $pixelMiss = 0 $pixelFound = 0 If $detectLast = "Left" Then detectLeft() If $pixelFound = 0 Then detectRight() EndIf ElseIf $detectLast = "Right" Then detectRight() If $pixelFound = 0 Then detectLeft() EndIf ElseIf $detectLast = "" Then detectLeft() If $pixelFound = 0 Then detectRight() EndIf EndIf ; Detection for NONE If $pixelMiss > 1 Then GUICtrlSetData($positionDetected,"...") GUICtrlSetData($currentAction,"...") $detectLast = "" Sleep(50) EndIf WEnd If I have $complete set to "0".... then the exit features do not work.... can the script not exit while performing a loop? How can I change it to work even while this is running. Edited April 19, 2005 by joncom
layer Posted April 20, 2005 Posted April 20, 2005 if your using both of your posted scripts in one script, then when $complete = 0 then its going into another loop where its not polling 4 events.. so add this to the last thing you posted.. $get = GUIGetMsg() If $get = -3 then exit then it will poll 4 events FootbaG
joncom Posted April 20, 2005 Author Posted April 20, 2005 Can you please tell me why a -3 is used... if I can understand that, maybe I will be able to do it myself in the future when I have more code in the file as well.
CyberSlug Posted April 20, 2005 Posted April 20, 2005 Can you please tell me why a -3 is used... if I can understand that, maybe I will be able to do it myself in the future when I have more code in the file as well.<{POST_SNAPBACK}>-3 is the value that AutoIt arbitrarily uses to represent the window closing event.It's much better to put #include <GUIConstants.au3> at the beginning of your scriptand use the variable $GUI_EVENT_CLOSE (just in case the AutoIt developer would decide to change -3 to another value) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
joncom Posted April 21, 2005 Author Posted April 21, 2005 Still doesn't work.. I'm guessing because while my program is running... unless I disable the point of the whole script, it never even makes it to the lines $get = GUIGetMsg() If $get = -3 then exit This is because its stuck in a loop above these lines of code.
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