gui529 Posted March 14, 2009 Posted March 14, 2009 I want it to hold space down for 3 seconds but it only sends space once. what is wrong with this script? Func Pickup() ControlSend($GameTitle, "", "", "{SPACE down}") sleep(3000) ControlSend($GameTitle, "", "", "{SPACE up}") endfunc
Authenticity Posted March 14, 2009 Posted March 14, 2009 Func Pickup() Dim $iInit = TimerInit() Do ControlSend($GameTitle, "", "", "{SPACE down}") Until TimerDiff($iInit) > 3000 ControlSend($GameTitle, "", "", "{SPACE up}") EndFunc
gui529 Posted March 14, 2009 Author Posted March 14, 2009 nothing really happens with that code. i tried run it and it just closes :[
Authenticity Posted March 14, 2009 Posted March 14, 2009 This is another question. Did your code worked in first place? You need to specify the ClassNN to successfully send keystrokes to the control.
Richard Robertson Posted March 14, 2009 Posted March 14, 2009 In response to your first post, that is the behavior you should expect. Holding a key and letting it go produces one character. If you want to repeat it, you have to add messages for repeating.
gui529 Posted March 14, 2009 Author Posted March 14, 2009 This is another question. Did your code worked in first place? You need to specify the ClassNN to successfully send keystrokes to the control.Yes, my first code did work but it only sends 1 character. As if its presing it once and not really holding it.In response to your first post, that is the behavior you should expect. Holding a key and letting it go produces one character. If you want to repeat it, you have to add messages for repeating.I see...so in order to do what i want i would have to play with sleeps and more sends?? or a loop?
Authenticity Posted March 14, 2009 Posted March 14, 2009 If your code worked for you then I believe it's something about SendKeyDownDelay option. Try to play with different values like 100 or 250 ms.
Richard Robertson Posted March 14, 2009 Posted March 14, 2009 SendKeyDownDelay is when you are sending regular keys, not key ups or downs. To repeat a key, you have to send a key repeat event. That will require you to learn window messages.
Authenticity Posted March 14, 2009 Posted March 14, 2009 Correct me if I'm wrong: Opt('SendKeyDownDelay', 20) Run('notepad') WinWaitActive('Untitled') Dim $hWnd = WinGetHandle('Untitled') Dim $iInit = TimerInit() Do ControlSend($hWnd, '', 'Edit1', '{a down}') Until TimerDiff($iInit) > 2000 ControlSend($hWnd, '', 'Edit1', '{a up}') ControlSend($hWnd, '', 'Edit1', '{ENTER}') Opt('SendKeyDownDelay', 100) $iInit = TimerInit() Do ControlSend($hWnd, '', 'Edit1', '{a down}') Until TimerDiff($iInit) > 2000 ControlSend($hWnd, '', 'Edit1', '{a up}')
Richard Robertson Posted March 14, 2009 Posted March 14, 2009 SendKeyDownDelay is the amount of time to wait before sending the key up code when just sending plain characters. Like Send("a") will use SendKeyDownDelay.
Authenticity Posted March 14, 2009 Posted March 14, 2009 Ok, I get the picture, so SendInput is much reliable method but I can't update to SP3 =$ otherwise my router won't like me anymore ;] but thanks for correcting me.
Richard Robertson Posted March 14, 2009 Posted March 14, 2009 That doesn't make any sense. What does the service pack have anything to do with SendInput? And when did SendInput even enter the conversation?
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