thewind27 Posted December 2, 2011 Posted December 2, 2011 (edited) I want everytime I press button "k" on keyboard, the program will execute the functions for the button I have in my GUI. This is my code so far: #include <GUIConstants.au3> GUICreate("My GUI") $button1 = GUICtrlCreateButton ("Task 1", 10, 30, 100) $button2 = GUICtrlCreateButton ( "Task 2", 0, -1) GUISetState () HotKeySet("k", "dotask1") Func dotask1() ;What should I put here so when I press "k", the program will execute $button1? EndFunc While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $button1 ;Execute my task #1. Case $button2 ;Execute my task #2. EndSelect Wend I have tried $button1 = GUICtrlCreateButton ("&k Task 1", 10, 30, 100) but it doesn't work like I expect. Edited December 2, 2011 by thewind27
FaridAgl Posted December 2, 2011 Posted December 2, 2011 (edited) Maybe GUISetAccelerators() ? Edit: Try this, if you click on Button 1 or press K Button1 function will execute. #include <GUIConstants.au3> GUICreate("My GUI") $button1 = GUICtrlCreateButton("Task 1", 10, 30, 100) $button2 = GUICtrlCreateButton("Task 2", 0, -1) GUISetState() HotKeySet("k", "Button1") Func Button1() MsgBox(0, '', "Button 1") EndFunc ;==>Button1 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button1 Button1() Case $msg = $button2 ;Execute my task #2. EndSelect WEnd Edited December 2, 2011 by D4RKON3 http://faridaghili.ir
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