jonny1234 Posted March 2, 2007 Posted March 2, 2007 Hi, I would like to set up access keys to each of the controls on a form, so that the user just has to press Alt and a key to get to a control. I thought that all that was required was to put a & in front of the appropriate letter within the caption of the control, but this does not just allow Alt+key to be used; it also allows Shift+key and Ctrl+key and even just the key itself to be used, as you can see in the following example: #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $frmTest = GUICreate("Test", 233, 137, 193, 123) GUISetOnEvent($GUI_EVENT_CLOSE, "frmTestClose") $cmdButton1 = GUICtrlCreateButton("&Test 1", 12, 28, 73, 29, 0) $cmdButton2 = GUICtrlCreateButton("T&est 2", 12, 62, 73, 29, 0) $cmdButton3 = GUICtrlCreateButton("Te&st 3", 12, 96, 73, 29, 0) $lblTest = GUICtrlCreateLabel("Te&xt", 112, 34, 29, 17) $inpTest = GUICtrlCreateInput("Some text", 144, 30, 61, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func frmTestClose() GUIDelete($frmTest) Exit EndFunc When I set the form up the same way in Visual Basic, only Alt+key can be used. This is what I would expect and is what I would like to achieve in AutoIt. Please can you tell me how to set things up so that only Alt+key works, and not all the other combinations, as I would like to use Shift and Ctrl for other purposes. Thanks for your help. Regards, Jonny
HardHackz Posted March 3, 2007 Posted March 3, 2007 HotKeySet() [center]My BlogOldSock Programs (AutoIT Apps)A Message to Hackers! (NOT SKIDDIES!)OldSock Programs is my little "company."[/center]
Emiel Wieldraaijer Posted March 4, 2007 Posted March 4, 2007 Use _IsPressed with WinActive instead , this will only be activated when program is active HotKeySet is as long as the program is run active #Include <Misc.au3> ; This is CTRL and P While 1 If BitAND (_IsPressed ("11"), _IsPressed ("50")) and WinActive ("GUIName") Then ExecuteFunction () Wend Best regards,Emiel Wieldraaijer
jonny1234 Posted March 5, 2007 Author Posted March 5, 2007 Thank you both for your replies. I have investigated them both, and found out that HotKeySet was not suitable anyway (in addition to the reason stated by Emiel) because Alt+key has to be pressed and also released before the function is executed. This is not standard Alt+key behaviour, where the function should be executed as soon as Alt and the key are pressed down. So I'll be going with Emiel's solution. Regards, Jonny
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