tsolrm Posted April 26, 2012 Share Posted April 26, 2012 (edited) I need to record keystrokes of two keys "q" and "w" However since the majority of people using my script are russian, they have russian keyboard layout and the russian letter corresponding to q and w are "й" and "ц". I need to differentiate between the russian and english keys. However I can't think of a way to do this. This is what i've got so far. Any suggestions? Case _IsPressed("51", $hDLL) If _IsPressed("A0", $hDLL) or _IsPressed("A1", $hDLL) Then $send = "Q" Else $send = "q" EndIf Pressed ($send) While _IsPressed("51", $hDLL) Sleep (10) Wend Case _IsPressed("57", $hDLL) If _IsPressed("A0", $hDLL) or _IsPressed("A1", $hDLL) Then $send = "W" Else $send = "w" EndIf Pressed ($send) While _IsPressed("57", $hDLL) Sleep (10) Wend Edited April 26, 2012 by tsolrm Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2012 Moderators Share Posted April 26, 2012 tsolrm, You might use the code here to detect which keyboard language is in use - then you can adjust the code accordingly. 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 Link to comment Share on other sites More sharing options...
tsolrm Posted April 26, 2012 Author Share Posted April 26, 2012 I've tried this and it doesn't work. Usually returns the default keyboard layout. Tried using the macro too. #RequireAdmin HotKeySet ("{q}", "key") TraySetState() $exit = TrayCreateItem("Выход") While 1 $msg=TrayGetMsg() If $msg = $exit Then Exit $hWnd = WinGetHandle ("") $layout= _GetKeyboardLayout($hWnd) Wend Func key () MsgBox (0, "test", $layout) EndFunc Func _GetKeyboardLayout($hWnd) Local $ret = DllCall("user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWnd, "ptr", 0) $ret = DllCall("user32.dll", "long", "GetKeyboardLayout", "long", $ret[0]) Return "0000" & Hex($ret[0], 4) EndFunc Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 26, 2012 Share Posted April 26, 2012 (edited) Hey maybe THis KeyHook will help you out The Function will both trigger in KeyUp and KeyDown events Code <snip> Edited April 26, 2012 by Melba23 Code removed My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
tsolrm Posted April 26, 2012 Author Share Posted April 26, 2012 Hm i don't quite understand how to apply this Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2012 Moderators Share Posted April 26, 2012 PhoenixXL,Please read this - what you posted was essentially a full keyboard watcher. All,We are serious about this - do NOT post scripts which watch the keyboard or try to detect virtually all the keys. Looking for a few keys such as the OP is trying to do is fine, do not drag the thread into forbidden waters. I did not post the announcement to which I linked to increase my post count and if people keep ignoring our prohibition on keyloggers then they will find they get some time off to read the rules more carefully. 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 Link to comment Share on other sites More sharing options...
tsolrm Posted April 26, 2012 Author Share Posted April 26, 2012 Okey, any other solutions please? Link to comment Share on other sites More sharing options...
qsek Posted April 26, 2012 Share Posted April 26, 2012 (edited) Lookup the example script in the help file for <snip> I hope thats ok @Melba Edited April 26, 2012 by Melba23 Removed text Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2012 Moderators Share Posted April 26, 2012 (edited) qsek,I hope thats ok @MelbaNo. All,For the last time: In this forum you do not post, link to or name any code which watches the keyboard and returns keycodes. How difficult is that to understand? We all know that there are several ways to do it - and anyone intelligent enough can work it out from first principles without too much difficulty. What we do not want you to do is to give out freebie code to every teenage "script kiddie" out there who wants to hack into his sister's e-mails - or worse. Just use some commonsense - we do not have many prohibitions here but those we do have, we enforce. And a warning - I am now getting near the limit of my patience on this subject. M23Edit:tsolrm,Sorry your thread has got so off-topic - did the code I posted above not work to get the keyboard language? Edited April 26, 2012 by Melba23 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 Link to comment Share on other sites More sharing options...
tsolrm Posted April 26, 2012 Author Share Posted April 26, 2012 I wish I was hands on with DLL structures, then i would've used the advice above. I'm looking for something less complicated. Is there no way to simply detect the input language? Link to comment Share on other sites More sharing options...
qsek Posted April 26, 2012 Share Posted April 26, 2012 (edited) I've tried this and it doesn't work. Usually returns the default keyboard layout. Tried using the macro too. This code returns the active keyboard layout number. It works for me 407 for german layout 419 кгыышфт lol try this code, if i use the message box then windows switches to standard layout. Console Write is safer Func key() ConsoleWrite($layout & @CRLF) EndFunc ;==>key Edited April 26, 2012 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 27, 2012 Share Posted April 27, 2012 (edited) @M23 Sorry For That Post............. I thought that It will since not log all The Keys , It may not be Refered a Keylogger........... Anyways It wont be Repeated Again....... Sorry For the Inconveniance Regards Phoenix XL Edited April 27, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. 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