 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
edu
Joined: 12 Oct 2006 Posts: 88 Location: Canada
|
Posted: Fri Dec 28, 2007 6:59 pm Post subject: not able to test docs example |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Fri Dec 28, 2007 7:05 pm Post subject: |
|
|
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 |
|
 |
edu
Joined: 12 Oct 2006 Posts: 88 Location: Canada
|
Posted: Sat Dec 29, 2007 1:04 am Post subject: |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Sat Dec 29, 2007 6:12 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|