WeMartiansAreFriendly Posted October 11, 2007 Share Posted October 11, 2007 (edited) Version 0.1: This is a simple Autoit Utility, You input the keyboard hex and it returns what key it is.. For instance you input '01', it will output 'Left mouse button', ect. Version 0.2 Added conversion so you can select from either side, hex value "01", or keyvalue "Left mouse", and it will return info such as hotkey and a description. (the script was easy to write, descript/info was the hardest part because i did it by hand <-- Edit: Changed it so it returns full info, description, hotkey, hexvalue, keyboard key.> Version 0.2e: applied fixes, thanks to smashly. > Version 0.2f: fixed: error when the key file contains a empty line. (thanks saunders)> Version 0.2g: fixed database file, typoes, missing keys (thanks saunders)Screenshot Enjoy!WhatKey.au3 (version 0.2g, Oct 13, 8:12 pm)expandcollapse popup#include <GUIConstants.au3> #include <GUICombo.au3> $hGUI = GUICreate("WhatKey? v.0.2g", 290, 265, -1, -1) $cmFile = GUICtrlCreateMenu('&File') $cmExit = GUICtrlCreateMenuitem('&Exit',$cmFile) $cmHelp = GUICtrlCreateMenu('&Help') $cmAbout = GUICtrlCreateMenuitem('&About',$cmHelp) GUICtrlCreateGroup("", 10, 7, 268, 226) GUICtrlCreateLabel("Value", 22, 25, 31, 17) $gcInput1 = GUICtrlCreateCombo("", 22, 49, 110, 21, $CBS_DROPDOWNLIST + $WS_VSCROLL) $gcInput2 = GUICtrlCreateCombo("", 140, 49, 125, 21, $CBS_DROPDOWNLIST + $WS_VSCROLL) GUICtrlCreateLabel("Results", 22, 76, 39, 17) $gcResult = GUICtrlCreateEdit("", 22, 99, 244, 116, BitOR($ES_WANTRETURN,$WS_VSCROLL,$ES_MULTILINE,$ES_READONLY), $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1,0xffffff) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Local $sSeparator = '|' Local $sKeyFile = _WKs_Init(@ScriptDir & '\Whatkey.dat', $sSeparator) Local $aInput[2], $aResult = '' While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $cmExit Exit Case $cmAbout MsgBox(0, 'About WhatKey?', 'WhatKey? is an Autoit keyboard helper') Case Else If GUICtrlRead($gcInput1) <> $aInput[0] Then _GUICtrlComboSetCurSel($gcInput2, _GUICtrlComboGetCurSel($gcInput1)) ElseIf GUICtrlRead($gcInput2) <> $aInput[1] Then _GUICtrlComboSetCurSel($gcInput1, _GUICtrlComboGetCurSel($gcInput2)) $aInput[0] = '' EndIf If GUICtrlRead($gcInput1) <> $aInput[0] Then $aInput[0] = GUICtrlRead($gcInput1) $aInput[1] = GUICtrlRead($gcInput2) $aResult = _WKS_Value($sKeyFile, $aInput[0], $sSeparator) If UBound($aResult)-1 <> 4 Or Not IsArray($aResult) Or @error Then GUICtrlSetData($gcResult, 'An error has occured.') Else GUICtrlSetData($gcResult, 'Description: '& $aResult[3] &@CRLF& 'Hotkey: '& $aResult[4]&@CRLF& _ 'Hex Value: '& $aResult[1] &@CRLF& 'Key: '& $aResult[2]) EndIf EndIf EndSwitch WEnd Func _WKs_Init($sKeyDat, $sSeparator = "|") Local $aFileKeys = StringSplit(StringStripCR(FileRead($sKeyDat)),@LF) If @Error Then Return Msgbox(0,'Error', $sKeyDat & ' could not be read properly, please make sure it exists.') Local $aArray, $aString[2] = ['',''] For $x = 1 To UBound($aFileKeys) - 1 $aArray = StringSplit($aFileKeys[$x],$sSeparator) If @error Then ContinueLoop If $x = 1 Then Local $1st[2] = [$aArray[1],$aArray[2]] EndIf $aString[0] &= $aArray[1] & '|' $aString[1] &= $aArray[2] & '|' Next GUICtrlSetData($gcInput1, $aString[0], $1st[0]) GUICtrlSetData($gcInput2, $aString[1], $1st[1]) Return $aFileKeys EndFunc Func _WKS_Value($aKeys, $sValue, $sASCII = 1, $sSeparator = "|") Local $aString If IsArray($aKeys) Then For $x = 1 To UBound($aKeys) - 1 $aString = StringSplit($aKeys[$x],$sSeparator) If IsArray($aString) Then If $aString[1] = $sValue Then Return $aString EndIf Next Return SetError(2,0,"") EndIf Return SetError(1,0,"") EndFuncWhatkey.datCODE01|Left Mouse|Left mouse button|{None}02|Right Mouse|Right mouse button|{None}04|Middle Mouse|Middle mouse button (three-button mouse)|{None}05|X1 Button|Windows 2000/XP: X1 mouse button|{None}06|X2 Button|Windows 2000/XP: X2 mouse button|{None}08|Backspace|BACKSPACE key|{Backspace} or {BS}09|Tab|TAB key|{Tab}0C|Clear|CLEAR key|{Clear}0D|Enter|ENTER key|{Enter}10|Shift|SHIFT key|{Shift} or {#}11|Ctrl|CTRL key|{Ctrl}12|Alt|ALT key|{Alt}13|Pause|PAUSE key|{Pause}14|Capslock|CAPS LOCK key|{Capslock}1B|Esc|ESC key|{Escape} or {Esc}20|Space|SPACEBAR|{Space}21|Pageup|PAGE UP key|{Pgup}22|Pagedown|PAGE DOWN key|{Pgdown}23|End|END key|{End}24|Home|HOME key|{Home}25|left|LEFT ARROW key|{Left}26|Up|UP ARROW key|{Up}27|Right|RIGHT ARROW key|{Right}28|Down|DOWN ARROW key|{Down}29|Select|SELECT key|{Select}2A|Print|PRINT key|{Print}2B|Execute|EXECUTE key|{Execute}2C|PrintScreen|PRINT SCREEN key|{PrintScreen}2D|Insert|INS key|{Insert} or {Ins}2E|Delete|DEL key|{Delete} or {Del}30|0|0 key|{0}31|1|1 key|{1}32|2|2 key|{2}33|3|3 key|{3}34|4|4 key|{4}35|5|5 key|{5}36|6|6 key|{6}37|7|7 key|{7}38|8|8 key|{8}39|9|9 key|{9}41|A|A key|{A}42|B|B key|{B}43|C|C key|{C}44|D|D key|{D}45|E|E key|{E}46|F|F key|{F}47|G|G key|{G}48|H|H key|{H}49|I|I key|{I}4A|J|J key|{I}4B|K|K key|{K}4C|L|L key|{L}4D|M|M key|{M}4E|N|N key|{N}4F|O|O key|{O}50|P|P key|{P}51|Q|Q key|{Q}52|R|R key|{R}53|S|S key|{S}54|T|T key|{T}55|U|U key|{U}56|V|V key|{V}57|W|W key|{W}58|X|X key|{X}59|Y|Y key|{Y}5A|Z|Z key|{Z}BA|;|Semi Colon|{;}BB|=|Equals|{=}BC|,|Comma|{,}BD|-|Dash|{-}BE|.|Period|{.}BF|/|Forward Slash|{/}C0|`|Prime|{`}DB|[|Right Bracket|{[}DC|\|Backslash|{\}DD|]|Left Bracket|{]}DE|'|Apostrophe key|{'}5B|Left Winkey|Left Windows key| {LWIN}5C|Right Winkey|Right Windows key| {RWIN}60|Num0|Numeric keypad 0 key|{NUMPAD0}61|Num1|Numeric keypad 1 key|{NUMPAD1}62|Num2|Numeric keypad 2 key|{NUMPAD2}63|Num3|Numeric keypad 3 key|{NUMPAD3}64|Num4|Numeric keypad 4 key|{NUMPAD4}65|Num5|Numeric keypad 5 key|{NUMPAD5}66|Num6|Numeric keypad 6 key|{NUMPAD6}67|Num7|Numeric keypad 7 key|{NUMPAD7}68|Num8|Numeric keypad 8 key|{NUMPAD8}69|Num9|Numeric keypad 9 key|{NUMPAD9}6A|*|Multiply key|{NUMPADMULT}6B|+|Add key|{NUMPADADD}6C|NumEnter|Separator key|{NUMPADENTER}6D|-|Subtract key|{NUMPADSUB}6E|.|Decimal key|{NUMPADDOT}6F|/|Divide key|{NUMPADDIV}70|F1|F1 key|{F1}71|F2|F2 key|{F2}72|F3|F3 key|{F3}73|F4|F4 key|{F4}74|F5|F5 key|{F5}75|F6|F6 key|{F6}76|F7|F7 key|{F7}77|F8|F8 key|{F8}78|F9|F9 key|{F9}79|F10|F10 key|{F10}7A|F11|F11 key|{F11}7B|F12|F12 key|{F12}7C|F13|F13 key|{F13}7D|F14|F14 key|{F14}7E|F15|F15 key|{F15}7F|F16|F16 key|{F16}80H|F17|F17 key|{F17}81H|F18|F18 key|{F18}82H|F19|F19 key|{F19}83H|F20|F20 key|{F20}84H|F21|F21 key|{F21}85H|F22|F22 key|{F22}86H|F23|F23 key|{F23}87H|F24|F24 key|{F24}90|Numlock|NUM LOCK key|{Numlock}91|Scrolllock|SCROLL LOCK key|{Scrollock}A0|LeftShift|Left SHIFT key|{LShift}A1|Right Shift|Right SHIFT key|{RShift}A2|Left Control|Left CONTROL key|{LShift}A3|Right Control|Right CONTROL key|{LCtrl}A4|Left Menu|Left MENU key|{None}A5|Right Menu|Right MENU key|{None} Edited October 14, 2007 by mrRevoked Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted October 11, 2007 Author Share Posted October 11, 2007 I thought it would was useful, I would appriciate atleast "one" feedback before this thread falls to the pits. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
GioVit Posted October 12, 2007 Share Posted October 12, 2007 I really like it, and I think it must be included in Scite Editor as a tool regards Link to comment Share on other sites More sharing options...
smashly Posted October 12, 2007 Share Posted October 12, 2007 (edited) Hi, Thank you and nice work but it's missing some keys.. BA; BB = BC , <----Probably won't be able to add comma due to your using comma as a delimiter in WhatKey.dat BD - BE . BF / C0 ` DB [ DC \ DD ]CheersEdit: Suggestion add $WS_VSCROLL style to the combo boxes.eg: $gcInput1 = GUICtrlCreateCombo("", 22, 49, 110, 21, $CBS_DROPDOWNLIST + $WS_VSCROLL) $gcInput2 = GUICtrlCreateCombo("", 140, 49, 125, 21, $CBS_DROPDOWNLIST + $WS_VSCROLL)Edit Again: I get an error if I hit my keyboard's END key while the gui is active, the gui crashes out .. o_0C:\#AutoIt Projects Misc\Help PPL\whateveragain2.au3 (43) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: GUICtrlSetData($gcResult, 'Description: '& $aResult[3] &@CRLF& 'Hotkey: '& $aResult[4]&@CRLF& 'Hex Value: '& $aResult[1] &@CRLF& 'Key: '& $aResult[2]) GUICtrlSetData($gcResult, 'Description: '& $aResult[3] &@CRLF& 'Hotkey: '& ^ ERROR ->12:49:52 AutoIT3.exe ended.rc:1Edit Again And Again: The crash happens if I go any futher down the list then Left Shift when selecting from either combo box.Edit umpteenth: Ok the array error is because of the WhatKey.dat , the last 5 line are missing a value on each line..A1,Right Shift,Right SHIFT key,{RShift}A2,Left Control,Left CONTROL key,{LShift}A3,Right Control,Right CONTROL key,{LCtrl}A4,Left Menu,Left MENU key,{None}A5,Right Menu,Right MENU key,{None}All good Edited October 12, 2007 by smashly Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 12, 2007 Share Posted October 12, 2007 It sounds nice, but it appears to need a little more work. This should be useful for people who don't like looking up the keycodes. (I'm one of those people who always has documentation open anyways.) Link to comment Share on other sites More sharing options...
BrettF Posted October 12, 2007 Share Posted October 12, 2007 Looks good. When you get the other half done it will be so much better! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted October 12, 2007 Author Share Posted October 12, 2007 Hi, Thank you and nice work but it's missing some keys.. ...All good Lol, Thanks for the bug hunting. Fixed (I think )Feedback very much appreciated. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
smashly Posted October 12, 2007 Share Posted October 12, 2007 Thank You once again .. that was quick and it works great so far. Good job. I'll keep it handy , saves me digging up my text file of keys when I'm looking for a value. Cheers Link to comment Share on other sites More sharing options...
GaryFrost Posted October 12, 2007 Share Posted October 12, 2007 http://www.autoitscript.com/forum/index.ph...c=21191&hl= 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...
jaenster Posted October 12, 2007 Share Posted October 12, 2007 (edited) Whoa , finaly.. Very handy Edited October 12, 2007 by jaenster -jaenster Link to comment Share on other sites More sharing options...
AlmarM Posted October 12, 2007 Share Posted October 12, 2007 (edited) Only this script is working for me expandcollapse popup#include <GUIConstants.au3> #include <GUICombo.au3> $hGUI = GUICreate("WhatKey? v.0.2e", 290, 265, -1, -1) $cmFile = GUICtrlCreateMenu('&File') $cmExit = GUICtrlCreateMenuitem('&Exit',$cmFile) $cmHelp = GUICtrlCreateMenu('&Help') $cmAbout = GUICtrlCreateMenuitem('&About',$cmHelp) GUICtrlCreateGroup("", 10, 7, 268, 226) GUICtrlCreateLabel("Value", 22, 25, 31, 17) $gcInput1 = GUICtrlCreateCombo("", 22, 49, 110, 21, $CBS_DROPDOWNLIST + $WS_VSCROLL) $gcInput2 = GUICtrlCreateCombo("", 140, 49, 125, 21, $CBS_DROPDOWNLIST + $WS_VSCROLL) GUICtrlCreateLabel("Results", 22, 76, 39, 17) $gcResult = GUICtrlCreateEdit("", 22, 99, 244, 116, BitOR($ES_WANTRETURN,$WS_VSCROLL,$ES_MULTILINE,$ES_READONLY), $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1,0xffffff) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Local $sSeparator = '|' Local $sKeyFile = _WKs_Init(@ScriptDir & '\WhatKey.dat', $sSeparator) Local $aInput[2], $aResult = '' While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $cmExit Exit Case $cmAbout MsgBox(0, 'About WhatKey?', 'WhatKey? is an Autoit keyboard helper') Case Else If GUICtrlRead($gcInput1) <> $aInput[0] Then _GUICtrlComboSetCurSel($gcInput2, _GUICtrlComboGetCurSel($gcInput1)) ElseIf GUICtrlRead($gcInput2) <> $aInput[1] Then _GUICtrlComboSetCurSel($gcInput1, _GUICtrlComboGetCurSel($gcInput2)) $aInput[0] = '' EndIf If GUICtrlRead($gcInput1) <> $aInput[0] Then $aInput[0] = GUICtrlRead($gcInput1) $aInput[1] = GUICtrlRead($gcInput2) $aResult = _WKS_Value($sKeyFile, $aInput[0], $sSeparator) If UBound($aResult)-1 <> 4 Or Not IsArray($aResult) Or @error Then GUICtrlSetData($gcResult, 'An error has occured.') Else GUICtrlSetData($gcResult, 'Description: '& $aResult[3] &@CRLF& 'Hotkey: '& $aResult[4]&@CRLF& _ 'Hex Value: '& $aResult[1] &@CRLF& 'Key: '& $aResult[2]) EndIf EndIf EndSwitch WEnd Func _WKs_Init($sKeyDat, $sSeparator = "|") Local $aFileKeys = StringSplit(StringStripCR(FileRead($sKeyDat)),@LF) If @Error Then Return Msgbox(0,'Error', $sKeyDat & ' could not be read properly, please make sure it exists.') Local $aArray, $aString[2] = ['',''] For $x = 1 To UBound($aFileKeys) - 1 $aArray = StringSplit($aFileKeys[$x],$sSeparator) If $x = 1 Then Local $1st[2] = [$aArray[1],$aArray[1]] EndIf $aString[0] &= $aArray[1] & '|' $aString[1] &= $aArray[1] & '|' Next GUICtrlSetData($gcInput1, $aString[0], $1st[0]) GUICtrlSetData($gcInput2, $aString[1], $1st[1]) Return $aFileKeys EndFunc Func _WKS_Value($aKeys, $sValue, $sASCII = 1, $sSeparator = "|") Local $aString If IsArray($aKeys) Then For $x = 1 To UBound($aKeys) - 1 $aString = StringSplit($aKeys[$x],$sSeparator) If IsArray($aString) Then If $aString[1] = $sValue Then Return $aString EndIf Next Return SetError(2,0,"") EndIf Return SetError(1,0,"") EndFunc I change 2 times the 2 into 1 (At line 58 and 61) Else I would get error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. And Nice Work ^^ Its very usefull for me ^^ Edited October 12, 2007 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
BigDod Posted October 12, 2007 Share Posted October 12, 2007 I get the following error D:\AutoIT\whatkey.au3 (61) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aString[1] &= $aArray[2] & '|' $aString[1] &= ^ ERROR 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...
Toady Posted October 12, 2007 Share Posted October 12, 2007 I remember posting this same type of thing in the help forum a few times. Yet didn't post here because I thought it was the basis of a keylogger.... Nice job btw, cool way to learn scan codes. www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
therks Posted October 14, 2007 Share Posted October 14, 2007 I get the following errorI did too, make sure there's no empty lines in your Whatkey.dat file. I had an extra line break at the very end of the file and on a whim decided to try trimming it and voila.@mrRevoked you should maybe have the script detect an empty line and just skip it? My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Nahuel Posted October 14, 2007 Share Posted October 14, 2007 http://www.autoitscript.com/forum/index.ph...c=21191&hl=I always get the same error when running your scripts:`cannot declare a constant'Why is this? I'm using beta too.. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 14, 2007 Share Posted October 14, 2007 I always get the same error when running your scripts:`cannot declare a constant'Why is this? I'm using beta too..Look how old most of my scripts are that are out there, to many to keep up to date.Only update if there is a big demand to. 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...
therks Posted October 14, 2007 Share Posted October 14, 2007 I always get the same error when running your scripts:`cannot declare a constant'Why is this? I'm using beta too..It's because a lot of those constants are now already declared in the includes. Try commenting (or deleting) lines 7 to 58. The script ran fine for me after that. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Nahuel Posted October 14, 2007 Share Posted October 14, 2007 It's because a lot of those constants are now already declared in the includes. Try commenting (or deleting) lines 7 to 58. The script ran fine for me after that.You're right. Thanks Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted October 14, 2007 Author Share Posted October 14, 2007 I did too, make sure there's no empty lines in your Whatkey.dat file. I had an extra line break at the very end of the file and on a whim decided to try trimming it and voila.@mrRevoked you should maybe have the script detect an empty line and just skip it?I added "If @error Then ContinueLoop" on line 57, hope that helps. Thanks Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
therks Posted October 14, 2007 Share Posted October 14, 2007 (edited) 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. Edited October 14, 2007 by Saunders 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