WeMartiansAreFriendly Posted October 14, 2007 Author Posted October 14, 2007 A couple bugs for you mrRevoked. 1) Right bracket (DB) in Whatkey.dat has {]} for the Send key (should be {[}). 2) You're missing Apostrophe ('): DE|Apostrophe|Apostrophe key|{'}. 3) Prime (C0) in Whatkey.dat has {'} for Send key, should be {`}. Otherwise looks pretty cool. I'm actually experimenting with your whatkey.dat right now, trying another approach for a HotKey dialog. Updated. And good luck with that Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
therks Posted October 14, 2007 Posted October 14, 2007 It's lookin pretty cool now actually.expandcollapse popup#include <Misc.au3> #include <GUIConstants.au3> Global $hUser32 = DllOpen('user32.dll') Global $sFileLoad = FileRead('KeyList.dat', FileGetSize('KeyList.dat')) Global $aFileLines = StringSplit(StringStripCR($sFileLoad), @LF) Global $aKeyInfo[$aFileLines[0] + 1][3] = [ [ $aFileLines[0] ] ] For $i = 1 To $aFileLines[0] If $aFileLines[$i] = '' Then ContinueLoop $aLineSplit = StringSplit($aFileLines[$i], '|') $aKeyInfo[$i][0] = $aLineSplit[1] $aKeyInfo[$i][1] = $aLineSplit[2] $aKeyInfo[$i][2] = $aLineSplit[3] Next $gui = GUICreate('', 200, 200) GUICtrlCreateLabel('Key String:', 5, 5, 60, 20, $SS_CENTERIMAGE) $in_KeyDisplay = GUICtrlCreateInput('', 65, 5, 130, 20) GUICtrlCreateLabel('Raw key:', 5, 30, 60, 20, $SS_CENTERIMAGE) $in_RawKey = GUICtrlCreateInput('', 65, 30, 130, 20) $bt_SetKey = GUICtrlCreateButton('Set key', 45, 55, 70, 25) $bt_Test = GUICtrlCreateButton('Test key', 125, 55, 70, 25) GUISetState() While 1 $gm = GUIGetMsg() Switch $gm Case $bt_SetKey ToolTip('Press your key combination now') $aKeyReturn = _HarvestKey() ToolTip('') Case $bt_Test If IsDeclared('aKeyReturn') Then If HotKeySet($aKeyReturn[0], '_TestHotKey') Then MsgBox(0x2000, 'Hotkey set', 'Hotkey set successfully') Else MsgBox(0x2010, 'Could not set hotkey', 'Hotkey may be in use by another application') EndIf Else MsgBox(0x2010, 'No hotkey', 'You haven''t defined a hotkey yet') EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _TestHotKey() MsgBox(0x2000, 'Hotkey test', 'Hotkey appears to work. @HotKeyPressed = ' & @HotKeyPressed & @CRLF & 'Unsetting hotkey now.') HotKeySet(@HotKeyPressed) EndFunc Func _HarvestKey() Opt('GUICloseOnEsc', 0) Local $bDone = False, $sKeyString, $sHotKey Do $sKeyString = '' $sHotKey = '' For $i = 1 To $aKeyInfo[0][0] If _IsPressed($aKeyInfo[$i][0], $hUser32) Then If $i = 2 And $sKeyString <> '' Then ContinueLoop; This is to prevent double Win key if Left and Right are both pressed $sKeyString &= $aKeyInfo[$i][1] & '+' $sHotKey &= $aKeyInfo[$i][2] If $i > 5 Then; The first five keys are modifiers, so any key pressed beyond that would complete the hotkey, so finish the harvest $bDone = True EndIf EndIf Next $sKeyString = StringTrimRight($sKeyString, 1) GUICtrlSetData($in_KeyDisplay, $sKeyString) GUICtrlSetData($in_RawKey, $sHotKey) Until $bDone Opt('GUICloseOnEsc', 1) Local $aReturn[2] = [ $sHotKey, $sKeyString ] Return $aReturn EndFuncUses a modified keylist though. Grab it here. My AutoIt Stuff | My Github
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