jsteng Posted June 28, 2014 Posted June 28, 2014 (edited) Is there a function that will convert a single key/char used with send to its equivalent keycode used by _IsPressed? ie, $key = "=" $keycode = FUNCTION($key) ;will convert "=" to "BB" send("{"& $key & " down}") _IsPressed($keycode) is true it should work also for the other special characters like SHIFT, CTRL, ALT, SPACE, BACkSPACE... and so on. $key = "SHIFT" $keycode = FUNCTION($key) ;will convert "SHIFT" to "10" send("{"& $key & " down}") _IsPressed($keycode) is true ASC? Or perhaps something that is better/simpler than _IsPressed ie $key = "v" send("{"& $key & " down}") . . FunctionIsPressed($key) is true bottom line, I dont like having to lookup the keycode that is used by IsPressed Edited June 28, 2014 by jsteng
JohnOne Posted June 28, 2014 Posted June 28, 2014 I have not seen one, but it's a simple task to make one for your own benefit. Post your code if you are having trouble. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
johnmcloud Posted June 28, 2014 Posted June 28, 2014 (edited) I'll not do this for you ( teach a man to fish bla bla ) but this is a good startup script, go, finish it and post the result: P.S. There is CODE tag button, use it! ; Johnmcloud - 2014 #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") ConsoleWrite("_IsPressed: BACKSPACE is equal to: " & _Hex_ToKey("BACKSPACE") & @CRLF) ConsoleWrite("_IsPressed: TAB is equal to: " & _Hex_ToKey("TAB") & @CRLF) ConsoleWrite("_IsPressed: JOHNCMLOUD is equal to: " & _Hex_ToKey("JOHNCMLOUD") & @CRLF) $MyKey = _Hex_ToKey("TAB") If $MyKey = "NOT_FOUND" Then Exit MsgBox(16, "Error", "Key wasn't found") ConsoleWrite("Press TAB to exit from the script" & @CRLF) While Not _IsPressed($MyKey, $hDLL) ConsoleWrite("Waiting for TAB..." & @CRLF) Sleep(100) WEnd Func _Hex_ToKey($sHexKey) Local $aArray[2][2] = [["BACKSPACE", "TAB"],["08", "09"]] For $i = 0 To UBound($aArray) - 1 If $aArray[0][$i] = $sHexKey Then Return $aArray[1][$i] Next Return "NOT_FOUND" ; whatever error if the key wasn't find by For...Next EndFunc ;==>_Hex_ToKey http://www.autoitscript.com/wiki/Arrays Edited June 28, 2014 by johnmcloud
Moderators Melba23 Posted June 28, 2014 Moderators Posted June 28, 2014 Hi,Before this thread goes any further, can I just remind everyone about the prohibition on keyloggers. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jsteng Posted June 28, 2014 Author Posted June 28, 2014 (edited) rest assured this is NOT a keylogger app nor other prohibited apps besides, there are other programming languages that can do that purpose better and easier Edited June 29, 2014 by jsteng
kylomas Posted June 29, 2014 Posted June 29, 2014 (edited) jsteng, Can you explain more about what you are trying to do? Particularly what you are trying to do with IsPressed() and Send(). There may be alternatives once we understand your task. kylomas edit: spelling Edited June 29, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
AndyG Posted June 29, 2014 Posted June 29, 2014 Hi, Can you explain more about what you are trying to do? a$ = inkey$ REM if i remember correctly from GW-Basic 1983 or 84, returns the pressed key.... I don´t know why this BASIC (hehe, isn´t that funny^^) function to get a keyboard-code is not implemented in AutoIt. "Prohibition on keyloggers" is a weak excuse.
JohnOne Posted June 29, 2014 Posted June 29, 2014 Don't understand the fuss and confusion. All the codes are in the respective documentation. Func _IsPressedCode($char) Switch $char Case "A" Return "42" Case "B" Return "43" ;etc... EndSwitch EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted June 29, 2014 Moderators Posted June 29, 2014 AndyG, "Prohibition on keyloggers" is a weak excuseBut that is one of the rules here as set out by the AutoIt site owner and author. If you want to post here, then you need to respect them. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Moderators Melba23 Posted June 29, 2014 Moderators Posted June 29, 2014 jsteng,I am sure you are not writing a keylogger - but you still need to respect the guidance in the thread to which I linked. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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