| View previous topic :: View next topic |
| Author |
Message |
lemon Newbie
Joined: 20 Dec 2006 Posts: 2
|
Posted: Wed Dec 20, 2006 3:41 am Post subject: Sending keystrokes to another program |
|
|
Hello,
Im trying to send keystrokes to another application but I need to hold down some keys for several seconds and "window send" doesn't seem to handle that. I searched the best i could about it and found that keybd_event ( USER32 ) would do it. But it doesn't work and i don't know why...
I inspired myself with this post and help files from windows http://forum.vdsworld.com/viewtopic.php?t=3395&highlight=window+send+hold
This is my test code in notepad:
| Code: |
LOADLIB USER32
REM use your own value here
%N = Sans titre - Bloc-notes
if @winexists(%N)
goto send
else
exit
:send
WINDOW ACTIVATE,%N
REM set the key "x" down $58 being the virtual key for "x"
%%void = @lib(USER32, keybd_event, NIL:, INT: $58, INT: 0, INT: 0, INT: 0)
wait 5
REM set the key "x" up
%%void = @lib(USER32, keybd_event, NIL:, INT: $58, INT: 0, INT: 2, INT: 0)
FREELIB USER32
exit
|
but it only writes one single "x" as if it wasnt held down??
what am i doing wrong?  |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Dec 20, 2006 10:17 am Post subject: |
|
|
I'm not 100% sure, but I think it is working as documented. Auto-repeat is generated by the keyboard itself, or the Bios, or something, so you shouldn't see a string of x's if you simulate holding the key down within Windows. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
lemon Newbie
Joined: 20 Dec 2006 Posts: 2
|
Posted: Wed Dec 20, 2006 2:36 pm Post subject: |
|
|
You are right... it's working now in my application!
Don't know why yesterday it wouldn't, I lost so much time trying to figure it out hehe
thanks again. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|