Jump to content

A script detecting the press key code which locks my editor....


Recommended Posts

I took from Yashied'sHotKey UDF the following script and put this into one of my own script, which is for obtaining the code of the pressed key by tooltip. I don't know how this works, i just remove the parts I don't need from Yashied'sHotKey UDF, and it works fine for my purpose. But when I typed each letter, it seems my editor window is lock ( I can't move it, or I can but with difficulity). Do you know the reason ??

Global $hkTb[1][12] = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GUICreate('')]]
Global $KeyCode

_HotKey_Assign("")

Func _HotKey_Assign($iKey, $sFunction = 0)
Local $Index = 0, $Redim = False, $Error = False
If $Index = 0 Then
  If ($hkTb[0][5] = 0) And ($hkTb[0][3] = 0) Then
   $hkTb[0][4] = DllCallbackRegister('__HK_Hook', 'long', 'int;wparam;lparam')
   $hkTb[0][5] = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hkTb[0][4]), _WinAPI_GetModuleHandle(0), 0)
     EndIf
     $Index = $hkTb[0][0] + 1
  ReDim $hkTb[$Index + 1][UBound($hkTb, 2)] ;; Need this, otherwise,  error with array dim.
  $Redim = 1 ;; Also need this, otherwise, no function.
EndIf

$hkTb[$Index][0] = $iKey

For $i = 9 To 11
     $hkTb[$Index][$i] = 0
Next

If $Redim Then
  $hkTb[0][0] += 1
EndIf

Return 1
EndFunc

Func __HK_Hook($iCode, $wParam, $lParam)
    Local $vkCode = DllStructGetData(DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam), 'vkCode')
    Local $Key = BitOR(BitShift($hkTb[0][9], -8), $vkCode)
$KeyCode=$Key
ToolTip(  $key )
Return
EndFunc
Link to comment
Share on other sites

the goal is when I type some keys(not all the keys, but still have 60 keys....), then the editor should save the file. I could use for and _ispressed to do this, but I think using the above script should be more efficients. Yes, one can use it as keylogger, but one still has to do a bit more work to get the letter from the keycodes. And if I want to use it as keylogger, I don't have to ask here ,since I don't need to care about if my editor is lock the position or not....

Link to comment
Share on other sites

With regard your question, if you mean scite editor while the script is running, I have no problems with it at all.

If not, you might want to clarify, for someone else who might be able to help you.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

If I were doing what you are, I'd hotkeyset every key I needed like so.

HotKeySet("1","_func")
While 1
WEnd
Func _func()
HotKeySet(@HotKeyPressed)
Send(@HotKeyPressed)
Send("{F9}")
HotKeySet(@HotKeyPressed,"_func")
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

oops meant to add.

HotKeySet("1", "_func")
While 1
WEnd
Func _func()
If WinActive("MyWindow") Then
  HotKeySet(@HotKeyPressed)
  Send(@HotKeyPressed)
  Send("{F9}")
  HotKeySet(@HotKeyPressed, "_func")
EndIf
EndFunc

EDIT: there should be an Else condition in there, but you get the idea.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

hodgestructure,

I suggest that you read the MS doc entitled "Installing and Releasing Hook Procedures" and then look at Yashieds code very carefully...I think that you are compromising the low level keyboard hook chain...

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

Link to comment
Share on other sites

@kylomas,

No, I don't have time to do this now and for me it's not easy at all. But if I am compromising something, I should correct it. The abvoe script is obtained from try and error to get the result I want, so I don't know the structure...........

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...