forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Sending keystrokes to another program

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
lemon
Newbie


Joined: 20 Dec 2006
Posts: 2

PostPosted: Wed Dec 20, 2006 3:41 am    Post subject: Sending keystrokes to another program Reply with quote

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? Question
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Dec 20, 2006 10:17 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
lemon
Newbie


Joined: 20 Dec 2006
Posts: 2

PostPosted: Wed Dec 20, 2006 2:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group