Zest Posted February 3, 2007 Share Posted February 3, 2007 Hello, I have a simple GUI with several windows to click through one after another. Each window has 10 buttons that can be clicked. I would like to assign the keys 1 to 0 to these, so that I don't have to use the mouse to click a button but simply press it's number. I read something about hotkeys but I'm not sure if this is the correct way to set this up or if there is an easier way. It would be great if there was a way to assign a key to a button directly when creating the button, but I can't find something like this in the docs. What is the best way to get this functionality? Any help is appreciated! Link to comment Share on other sites More sharing options...
BigDod Posted February 3, 2007 Share Posted February 3, 2007 Press R or B #include <GUIConstants.au3> GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("&Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "&Button Test", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect Wend Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Zest Posted February 3, 2007 Author Share Posted February 3, 2007 Thank you for your answer, but this is not what I meant: I already have my GUI up and running without problems when I use the mouse, but I want to have it so that when the user presses the "1" key on the keyboard, the script 'presses' the first button. When the user presses the "2" key on the keyboard, the script 'presses' the second button and so on ... Do you know how to do that ? Link to comment Share on other sites More sharing options...
GaryFrost Posted February 3, 2007 Share Posted February 3, 2007 look at HotKeySet SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
BigDod Posted February 3, 2007 Share Posted February 3, 2007 #include <GUIConstants.au3> GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("&1 Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "&2 Button Test", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSelect Wend Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Zest Posted February 3, 2007 Author Share Posted February 3, 2007 Thanks! This is exactly what I needed. Although the only must is that the numbers are actually in the text (which doesn't bother me) it works great. I didn't realise the answer was already in your first post: The '&' is used to define the key... I'm ashamed of my stupidity ... :"> Link to comment Share on other sites More sharing options...
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