gcue Posted September 4, 2013 Share Posted September 4, 2013 hello world! i am trying to find a way to convert a string of text to hexadecimal. but the results I am getting from help and on the forum dont match up with this example “kbd” denotes a string in hexadecimal format containing keyboard scan code input. This feature should be supported by all BIOS implementations. An example of a password structured in this format would be “<kbd/>321539191E1F1F11181320”, which is “my password” in US keyboard scan codes. is scan code different than just regular text? what conversion can i use to match it? thank you in advance!!! Link to comment Share on other sites More sharing options...
GPinzone Posted September 4, 2013 Share Posted September 4, 2013 Scan codes: http://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx It's different than ASCII. If a letter to scan code function doesn't exist in AutoIt, you can make one easy enough. Just make an array that converts scan code numbers to ASCII codes and then return the key using the existing ASCII character commands. Gerard J. Pinzonegpinzone AT yahoo.com Link to comment Share on other sites More sharing options...
Yashied Posted September 5, 2013 Share Posted September 5, 2013 #Include <APIConstants.au3> #Include <WinAPIEx.au3> $Text = 'MY PASSWORD' ; Characters to scan codes $Data = StringRegExp(StringUpper($Text), '.{1}', 3) $Text = '' For $i = 0 To UBound($Data) - 1 $Text &= Hex(_WinAPI_MapVirtualKey(Asc($Data[$i]), $MAPVK_VK_TO_VSC), 2) Next ConsoleWrite($Text & @CR) ; Scan codes to characters $Data = StringRegExp($Text, '.{2}', 3) $Text = '' For $i = 0 To UBound($Data) - 1 $Text &= Chr(_WinAPI_MapVirtualKey(Dec($Data[$i]), $MAPVK_VSC_TO_VK)) Next ConsoleWrite($Text & @CR) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
gcue Posted September 5, 2013 Author Share Posted September 5, 2013 thanks yashield. unfortunately - i dont have those includes (APIConstants nor WinAPIEx) - i have v3.3.8.1 and v3.3.9.19 beta installed. how can i get them? Link to comment Share on other sites More sharing options...
Yashied Posted September 5, 2013 Share Posted September 5, 2013 '?do=embed' frameborder='0' data-embedContent>> My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
gcue Posted September 5, 2013 Author Share Posted September 5, 2013 works great! many many thanks yashield!! Link to comment Share on other sites More sharing options...
gcue Posted September 5, 2013 Author Share Posted September 5, 2013 hmm as i incorporated it into my script, im getting conflicts with other udfs any idea which one im conflicting with? dunno what the best solution would be either - remove the word Const from both? or should i make this converter its own script and call it from the main script to get the conversion text? thanks again for your help! C:Program FilesAutoIt3IncludeAPIConstants.au3(3636,110) : ERROR: $KEY_READ previously declared as a 'Const' Global Const $KEY_READ = BitOR($STANDARD_RIGHTS_READ, $KEY_ENUMERATE_SUB_KEYS, $KEY_NOTIFY, $KEY_QUERY_VALUE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Program FilesAutoIt3IncludeAPIConstants.au3(3637,93) : ERROR: $KEY_WRITE previously declared as a 'Const' Global Const $KEY_WRITE = BitOR($STANDARD_RIGHTS_WRITE, $KEY_CREATE_SUB_KEY, $KEY_SET_VALUE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Program FilesAutoIt3IncludeWinAPIEx.au3(1044,399) : ERROR: $tagTEXTMETRIC previously declared as a 'Const' Global Const $tagTEXTMETRIC = 'long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;byte tmPitchAndFamily;byte tmCharSet;' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(301,31) : ERROR: $FO_MOVE previously declared as a 'Const' Global Const $FO_MOVE = 0x0001 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(302,31) : ERROR: $FO_COPY previously declared as a 'Const' Global Const $FO_COPY = 0x0002 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(303,33) : ERROR: $FO_DELETE previously declared as a 'Const' Global Const $FO_DELETE = 0x0003 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(304,33) : ERROR: $FO_RENAME previously declared as a 'Const' Global Const $FO_RENAME = 0x0004 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(306,42) : ERROR: $FOF_MULTIDESTFILES previously declared as a 'Const' Global Const $FOF_MULTIDESTFILES = 0x0001 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(307,40) : ERROR: $FOF_CONFIRMMOUSE previously declared as a 'Const' Global Const $FOF_CONFIRMMOUSE = 0x0002 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(308,34) : ERROR: $FOF_SILENT previously declared as a 'Const' Global Const $FOF_SILENT = 0x0004 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(309,45) : ERROR: $FOF_RENAMEONCOLLISION previously declared as a 'Const' Global Const $FOF_RENAMEONCOLLISION = 0x0008 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(310,42) : ERROR: $FOF_NOCONFIRMATION previously declared as a 'Const' Global Const $FOF_NOCONFIRMATION = 0x0010 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(311,45) : ERROR: $FOF_WANTMAPPINGHANDLE previously declared as a 'Const' Global Const $FOF_WANTMAPPINGHANDLE = 0x0020 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(312,37) : ERROR: $FOF_ALLOWUNDO previously declared as a 'Const' Global Const $FOF_ALLOWUNDO = 0x0040 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(313,37) : ERROR: $FOF_FILESONLY previously declared as a 'Const' Global Const $FOF_FILESONLY = 0x0080 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(314,42) : ERROR: $FOF_SIMPLEPROGRESS previously declared as a 'Const' Global Const $FOF_SIMPLEPROGRESS = 0x0100 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(315,42) : ERROR: $FOF_NOCONFIRMMKDIR previously declared as a 'Const' Global Const $FOF_NOCONFIRMMKDIR = 0x0200 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(316,37) : ERROR: $FOF_NOERRORUI previously declared as a 'Const' Global Const $FOF_NOERRORUI = 0x0400 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(317,49) : ERROR: $FOF_NOCOPYSECURITYATTRIBS previously declared as a 'Const' Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(318,39) : ERROR: $FOF_NORECURSION previously declared as a 'Const' Global Const $FOF_NORECURSION = 0x1000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(319,49) : ERROR: $FOF_NO_CONNECTED_ELEMENTS previously declared as a 'Const' Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(320,43) : ERROR: $FOF_WANTNUKEWARNING previously declared as a 'Const' Global Const $FOF_WANTNUKEWARNING = 0x4000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Scriptsgenie v0.4.3.8.au3(321,44) : ERROR: $FOF_NORECURSEREPARSE previously declared as a 'Const' Global Const $FOF_NORECURSEREPARSE = 0x8000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Link to comment Share on other sites More sharing options...
BrewManNH Posted September 5, 2013 Share Posted September 5, 2013 thanks yashield. unfortunately - i dont have those includes (APIConstants nor WinAPIEx) - i have v3.3.8.1 and v3.3.9.19 beta installed. how can i get them? The beta version 3.3.9.19 does have those files as includes, they're standard in that version now, that's why you're getting so many errors. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
gcue Posted September 5, 2013 Author Share Posted September 5, 2013 actually i also tried it on a 3.3.6.1 version (on another PC) copied over the udfs in which they did not exist. getting the errors there too Link to comment Share on other sites More sharing options...
BrewManNH Posted September 5, 2013 Share Posted September 5, 2013 You must have 2 copies of APIConstants.au3 in different folders, it's loading both. Also, this script genie v0.4.3.8.au3 is causing most of the errors, not sure why you are declaring these variables in that script if they're already declared elsewhere. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
gcue Posted September 5, 2013 Author Share Posted September 5, 2013 i dont see the second copy of apiconstants Also, this script genie v0.4.3.8.au3 is causing most of the errors, not sure why you are declaring these variables in that script if they're already declared elsewhere. i am not declaring anything. so it has to be another udf that is trying to figure out which one but dont think that will matter because there are duped declarations it seems - probably better to go interscript communication with this i think Link to comment Share on other sites More sharing options...
Yashied Posted September 5, 2013 Share Posted September 5, 2013 Copy the following lines into your script and enjoy. Global Const $MAPVK_VK_TO_VSC = 0 Global Const $MAPVK_VSC_TO_VK = 1 Func _WinAPI_MapVirtualKey($iCode, $iType, $hLocale = 0) Local $Ret = DllCall('user32.dll', 'uint', 'MapVirtualKeyExW', 'uint', $iCode, 'uint', $iType, 'uint_ptr', $hLocale) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_MapVirtualKey My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
gcue Posted September 5, 2013 Author Share Posted September 5, 2013 (edited) looks cool - except not sure what the itype variable looks like also, i wont be needing those includes then right? thanks soo much for your help!!! greatly appreciated. $text = '1234567' $scan_codes = _WinAPI_MapVirtualKey($text) ConsoleWrite($scan_codes & @CR) Global Const $MAPVK_VK_TO_VSC = 0 Global Const $MAPVK_VSC_TO_VK = 1 Func _WinAPI_MapVirtualKey($iCode, $iType, $hLocale = 0) Local $Ret = DllCall('user32.dll', 'uint', 'MapVirtualKeyExW', 'uint', $iCode, 'uint', $iType, 'uint_ptr', $hLocale) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_MapVirtualKey Edited September 6, 2013 by gcue Link to comment Share on other sites More sharing options...
gcue Posted September 6, 2013 Author Share Posted September 6, 2013 (edited) i tried both of these to no avail (thinking maybe the itype is either 0 or 1 (Const variables) sorry i have no idea what to plug in $text = '1234567' $scan_codes = _WinAPI_MapVirtualKey($text, 0) ConsoleWrite($scan_codes & @CR) $scan_codes = _WinAPI_MapVirtualKey(0, $text) ConsoleWrite($scan_codes & @CR) Edited September 6, 2013 by gcue Link to comment Share on other sites More sharing options...
gcue Posted September 6, 2013 Author Share Posted September 6, 2013 nevermind!!! i got it! hahahha so sorry man. no includes needed.. and here's the full script (for anyone who reads/needs this later..) thanks again yashield!!! expandcollapse popupGlobal Const $MAPVK_VK_TO_VSC = 0 Global Const $MAPVK_VSC_TO_VK = 1 $text = '1234567' $scan_codes = Convert_Characters_To_Scan_Codes($text) ConsoleWrite($scan_codes & @CR) ClipPut($scan_codes) Func Convert_Characters_To_Scan_Codes($text) ; Characters to scan codes $data = StringRegExp(StringUpper($text), '.{1}', 3) $text = '' For $i = 0 To UBound($data) - 1 $text &= Hex(_WinAPI_MapVirtualKey(Asc($data[$i]), $MAPVK_VK_TO_VSC), 2) Next Return $text EndFunc ;==>Convert_Characters_To_Scan_Codes $characters = Convert_Scan_Codes_To_Characters($scan_codes) ConsoleWrite($characters & @CR) Func Convert_Scan_Codes_To_Characters($text) ; Scan codes to characters $data = StringRegExp($text, '.{2}', 3) $text = '' For $i = 0 To UBound($data) - 1 $text &= Chr(_WinAPI_MapVirtualKey(Dec($data[$i]), $MAPVK_VSC_TO_VK)) Next Return $text EndFunc ;==>Convert_Scan_Codes_To_Characters Func _WinAPI_MapVirtualKey($iCode, $iType, $hLocale = 0) Local $Ret = DllCall('user32.dll', 'uint', 'MapVirtualKeyExW', 'uint', $iCode, 'uint', $iType, 'uint_ptr', $hLocale) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_MapVirtualKey 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