MirnesC2 Posted February 11, 2010 Share Posted February 11, 2010 (edited) $timer = TimerInit() While 1 $timed = TimerDiff($timer) If _IsPressed("43", $dll) AND $timed >= 200 Then ConsoleWrite("c") $timer = TimerInit() EndIf WEndOkay so this little example code should give an out of "c" if pressed once and "cccc" if pressed 4 times. I added the little timer as my attempt to fix the problem I am having.Without the timer, pressing "c" just once would output "ccccccccccccccc". I added a timer to make it not do that, that was my attempt at a fix. The only problem is that it cant be constant. If I type "cccc" really fast it will only output "cc". I type at different speeds so the out is always changing. Sometimes it outputs more then the amount of letters i actually hit. Example "cc" would do "ccc".Is there any other solution to this besides the timer that will work better? Also another I have another problem. Is it possible to detect capital C? Like if I press both shift and c. Edited February 11, 2010 by MirnesC2 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 11, 2010 Share Posted February 11, 2010 That's actually really easy, everything you need is _IsPressed #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(10);Because I don't like when scripts take 100% CPU If _IsPressed("43", $dll) Then While _IsPressed("43", $dll) Sleep(10);Because I don't like when scripts take 100% CPU WEnd ConsoleWrite("c" & @CRLF) EndIf WEndAnd for the future, please post a working (as in runnable) reproducer. It's quite annoying having to write half the script to see whats wrong .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
MirnesC2 Posted February 11, 2010 Author Share Posted February 11, 2010 That's actually really easy, everything you need is _IsPressed #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(10);Because I don't like when scripts take 100% CPU If _IsPressed("43", $dll) Then While _IsPressed("43", $dll) Sleep(10);Because I don't like when scripts take 100% CPU WEnd ConsoleWrite("c" & @CRLF) EndIf WEnd And for the future, please post a working (as in runnable) reproducer. It's quite annoying having to write half the script to see whats wrong Wow thank you so much. So simple, kind of mad I didn't think of that. And I didn't know the timer functions took up so much cpu. Thank you!! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 11, 2010 Share Posted February 11, 2010 And I didn't know the timer functions took up so much cpu. Thank you!!They don't. But your app only idles when you do a Sleep() so you would be looping hundreds if not thousands of times per second without them. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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