Mikesch Posted March 19, 2010 Share Posted March 19, 2010 Hi, the following will work fine for about 2 seconds, sending "x" and "y" alternating, then output will be sorted. So if I press the defined $hotkey for some seconds, I'll end up with something like xyxyxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyy. Guess it has to do with the keyboard buffer or message queuing, but I can't find out why this would happen or how to avoid it. Could you point me to the right direction, please? Func Sendkeys() While _IsPressed($hotkey, $dll) = 1 Send("x") sleep(100) Send("y") sleep(100) WEnd EndFunc ;==>Sendkeys Thanks, Mike Link to comment Share on other sites More sharing options...
l3ill Posted March 19, 2010 Share Posted March 19, 2010 This may work better: HotKeySet("{F1}", "_Sendkeys") While 1 Sleep(28800) WEnd Func _Sendkeys() Send("xy") EndFunc ;==>Sendkeys My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Mikesch Posted March 19, 2010 Author Share Posted March 19, 2010 Hi billo, thanks for your reply. I know your code would work, and I even don't have issues when using F-Keys with _isPressed(), but in this case the function should really only run as long as the defined key ("z") is held down. (The 100 ms delay is crucial, too.) Send("x") and 'y' will be replaced later, probably with some ControlSend() commands I need for video cutting. While testing I came about that strange behaviour and still can't see what I'm missing. Mike Link to comment Share on other sites More sharing options...
l3ill Posted March 19, 2010 Share Posted March 19, 2010 No Problem... Maybe one of the more experienced coders will shed some light on the issue... good luck! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
bogQ Posted March 19, 2010 Share Posted March 19, 2010 (edited) I dont have problem with this when it is in main loop, you did not post the script that can replicate problem so its hard to know where problem is #Include <Misc.au3> While 1 If _IsPressed("74") Then ;74 = F5 try not to use F1 becose it is mented for help in most of programs Send("x") Sleep(100) Send("y") Sleep(100) EndIf WEnd Edit: ok i know what did you do wrong You did something like this probably #Include <Misc.au3> HotKeySet("{F5}","Sendkeys") While 1 ;~ If _IsPressed("74") Then Sendkeys() WEnd Func Sendkeys() While _IsPressed("74") = 1 Send("x") sleep(100) Send("y") sleep(100) WEnd EndFunc ;==>Sendkeys So if thats your problem delite hotkey and put ispresed in main loop (probably my crystal ball is working ) Edited March 19, 2010 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Mikesch Posted March 19, 2010 Author Share Posted March 19, 2010 (edited) Oh, re-reading the script I think the problem occurs because I launch the function by hotkey, so the problem is not within the function itself, but in the way it is called. Thanks, you helped me very much. "Main Loop" was the correct keyword. Regards, Mike EDIT: Got me! ;-) Even before I did. Crystal ball functioning properly. Thanks again. Mike Edited March 19, 2010 by Mikesch 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