Sign in to follow this  
Followers 0
DragonBall

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

14 posts in this topic

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

Share this post


Link to post
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....

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks , JohnOne. I felt this maybe because I embedded my editor and viewer by Melba23's GUIFrame UDF. I found for the windows not embedd, no problem and even, not all windows embedded have this problem....

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

I have thought to do this before, but is this good? I mean set a lot of keys.....and I don't need these hotkeys for anything else but only when I type in this editor.....? what's you oppnion about this?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@kylomas,

I wonder why I am compromising the low level keyboard hook chain...?

Share this post


Link to post
Share on other sites

hodgestructure,

Did you read the doc and look at EVERYTHING that Yahied does in his UDF???

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

Share this post


Link to post
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...........

Share this post


Link to post
Share on other sites

hodgestructure,

Then I will close with this advice...run this code on your PC only!!!

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

Share this post


Link to post
Share on other sites

Sorry about this topic....The problem come froms controlclick, not as mentioned above

Share this post


Link to post
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
Sign in to follow this  
Followers 0