FeliXXL Posted December 17, 2014 Share Posted December 17, 2014 Hey there. I posted a slightly shortened version of my code below: expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> Global $g_hHook, $g_hStub_KeyProc = "" Test() Func Test() OnAutoItExitRegister("CleanUp") Local $hMod $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "Int", "int;wparam;lparam") $hMod = _WinAPI_GetModuleHandle(0) $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod) While 1 Sleep(100) WEnd EndFunc Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $wParam = $WM_KEYDOWN Then KeyValue(DllStructGetData($tKEYHOOKS, "vkCode")) EndIf Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndFunc Func KeyValue($iKeycode) If ($iKeycode = 112) Then ;do stuff if F1 has been pressed ElseIf ($iKeycode = 117) Then Exit ;exit if F6 has been pressed EndIf EndFunc Func CleanUp() _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_KeyProc) EndFunc Now my question... The ";do suff if F1 has been pressed" is a placeholder... Normally i put in "Send("text")" to try it out. And this works just fine. But if i do put in "Send("This is a very long message, so i dont want to type it all by myself")" he only writes it down the first 6 times i press "F1" (($iKeycode = 112))... I cannot imagine any possible way to fix that, so i thought you might be able to help me out of that misery. Greetings FeliXXL Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 17, 2014 Moderators Share Posted December 17, 2014 Seeing as I can't replicate your issue, I can only suggest you use _IsPressed() or HotKeySet(), which kind of make more sense in this situation anyway. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FeliXXL Posted December 18, 2014 Author Share Posted December 18, 2014 (edited) Alright... I did not believe it too, so i made a video, just to clearify what i meant... Edited December 18, 2014 by FeliXXL Link to comment Share on other sites More sharing options...
FeliXXL Posted December 18, 2014 Author Share Posted December 18, 2014 Alright, i did some testing and have got some news... If my string i send is under 30 characters it does exactly everything as expected. If it is more than 30 characters it struggles and only lets me execute it 6 times... Now i tested running it x64 (instead of x32 previously) and it works fine. I still want it to be able to run on 32 bit machines though. Any suggestions on how to achieve it without doing a "dirty hack" like splitting every string up in 30 character-chunks and sending em one after another? Greetings FeliXXL Link to comment Share on other sites More sharing options...
Solution computergroove Posted December 18, 2014 Solution Share Posted December 18, 2014 (edited) Your video was a good idea to post here. Go to your script window and click f5 (this will run your opened script) and open notepad and don't maximize the window (You want to see the console in Scite). Add a @CR at the end of your text insertion. This works for me more than 10 times on windows 7 x64 (I had to change the F1 to F2 because I have the help menu popping up with F1): expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> Global $g_hHook, $g_hStub_KeyProc = "" Test() Func Test() OnAutoItExitRegister("CleanUp") Local $hMod $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "Int", "int;wparam;lparam") $hMod = _WinAPI_GetModuleHandle(0) $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod) While 1 Sleep(100) WEnd EndFunc Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $wParam = $WM_KEYDOWN Then KeyValue(DllStructGetData($tKEYHOOKS, "vkCode")) EndIf Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndFunc Func KeyValue($iKeycode) If ($iKeycode = 113) Then send("This is a really long bit of text I dont want to type manually" & @CR) ElseIf ($iKeycode = 117) Then Exit ;exit if F6 has been pressed EndIf EndFunc Func CleanUp() _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_KeyProc) EndFunc Look in the console window below your code in the scite window for an error to occur when your script stops working. Edited December 18, 2014 by computergroove FeliXXL 1 Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html 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