AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

not able to test docs example

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
edu



Joined: 12 Oct 2006
Posts: 88
Location: Canada

PostPosted: Fri Dec 28, 2007 6:59 pm    Post subject: not able to test docs example Reply with quote

Hello, I'm finally taking time to read the docs on GUI, and this example gives me an error with this script:

Quote:

Gui, Menu [, MenuName]
Attaches a menu bar to the window. Use the Menu command to create an ordinary menu for this purpose. For example:

Menu, FileMenu, Add, &Open Ctrl+O, MenuFileOpen ; See remarks below about Ctrl+O.
Menu, FileMenu, Add, E&xit, MenuHandler
Menu, HelpMenu, Add, &About, MenuHandler
Menu, MyMenuBar, Add, &File, :FileMenu ; Attach the two sub-menus that were created above.
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBarIn the first line above, notice that &Open is followed by Ctrl+O (with a tab character in between). This indicates a keyboard shortcut that the user may press instead of selecting the menu item. To enable such a shortcut in the script, use a context-sensitive hotkey:

#IfWinActive GUI Window's Title ahk_class AutoHotkeyGUI
^o:: ; The Ctrl+O hotkey.
MenuFileOpen:
Gui +OwnDialogs ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFile
MsgBox You selected the file %SelectedFile%.
return

; The following part is needed only if the script will be run on Windows 95/98/Me:
#IfWinActive
$^o::Send ^o

_________________
The best things of life are free.
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Fri Dec 28, 2007 7:05 pm    Post subject: Reply with quote

the example is only this part:
Code:

Menu, FileMenu, Add, &Open Ctrl+O, MenuFileOpen ; See remarks below about Ctrl+O.
Menu, FileMenu, Add, E&xit, MenuHandler
Menu, HelpMenu, Add, &About, MenuHandler
Menu, MyMenuBar, Add, &File, :FileMenu ; Attach the two sub-menus that were created above.
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar ;In the first line above, notice that &Open is followed by Ctrl+O (with a tab character in between). This indicates a keyboard shortcut that the user may press instead of selecting the menu item. To enable such a shortcut in the script, use a context-sensitive hotkey:

#IfWinActive GUI Window's Title ahk_class AutoHotkeyGUI
^o:: ; The Ctrl+O hotkey.
MenuFileOpen:
Gui +OwnDialogs ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFile
MsgBox You selected the file %SelectedFile%.
return

; The following part is needed only if the script will be run on Windows 95/98/Me:
#IfWinActive
$^o::Send ^o


you can tell what is and isn't code by the indentation of the help file.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
edu



Joined: 12 Oct 2006
Posts: 88
Location: Canada

PostPosted: Sat Dec 29, 2007 1:04 am    Post subject: Reply with quote

Hi! I copied your code to a new script and I get this message:

Error: Target label does not exist. The current thread will exit.

Specifically: MenuHandler

Line#
002: Menu,FileMenu,Add,&Open Ctrl+O,MenuFileOpen
---> 003: Menu,FileMenu,Add,E&xit,MenuHandler
004: Menu,HelpMenu,Add,&About,MenuHandler
005: Menu,MyMenuBar,Add,&File,:FileMenu
006: Menu,MyMenuBar,Add,&Help,:HelpMenu
007: Gui,Menu,MyMenuBar
010: Return
012: Gui,+OwnDialogs
013: FileSelectFile,SelectedFile

---------------------------
OK
---------------------------
_________________
The best things of life are free.
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Sat Dec 29, 2007 6:12 am    Post subject: Reply with quote

so make a menuhandler

Code:

MenuHandler:

Msgbox, you pressed %A_ThisMenuItem% on %A_This Menu%
return

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group