MuffettsMan Posted January 8, 2008 Share Posted January 8, 2008 I am trying to find a way to set Hotkeys from a GUI so that users can define their own hotkeys without me having to create them manually.... so far I kindof can get it to detect what key was pressed though its far from being able to report if someone wanted to assing say Shift+Alt+G furthermore from the way i have hacked together it to detect which key was pressed i'm losing alot of the range of what Ispressed can find (ie all the keys that don't resolve directly to a number) anyone have some tips to make my code cleaner? here is a streamlined version of what i'm attempting: expandcollapse popup#include <GUIConstants.au3> #Include <Misc.au3> $dll = DllOpen("user32.dll") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 136, 150, 193, 125) $BindLabel = GUICtrlCreateLabel("Key is Bound to:", 18, 24, 94, 16, $SS_CENTER) $Input1 = GUICtrlCreateInput("<No Key Bound>", 24, 40, 89, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY)) $SetKey = GUICtrlCreateButton("Set Key", 32, 64, 75, 25, 0) $Clear = GUICtrlCreateButton("Clear Key", 32, 96, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SetKey $Input1 = GUICtrlCreateInput("Press any key", 24, 40, 89, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY)) BindKeyFunc() Case $Clear ClearFunc() EndSwitch WEnd Func BindKeyFunc() $KeyPressed = GetKeyPressed() $Input1 = GUICtrlCreateInput($KeyPressed, 24, 40, 89, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY)) EndFunc Func ClearFunc() $Input1 = GUICtrlCreateInput("Key Unbound", 24, 40, 89, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY)) EndFunc ; 10 SHIFT key ; 11 CTRL key ; 12 ALT key Func GetKeyPressed() while 1 for $i = 8 to 222 If _IsPressed($i, $dll) Then Return $i EndIf Next wend EndFunc;GetKeyPressed()==> Don't let that status fool you, I am no advanced memeber! Link to comment Share on other sites More sharing options...
Siao Posted January 8, 2008 Share Posted January 8, 2008 See herehttp://www.autoitscript.com/forum/index.ph...msctls_hotkey32 "be smart, drink your wine" Link to comment Share on other sites More sharing options...
therks Posted January 9, 2008 Share Posted January 9, 2008 This isn't necessarily what you're looking for, but you could also check out this that I wrote. My AutoIt Stuff | My Github 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