Zanaj Posted February 22, 2013 Share Posted February 22, 2013 Hey guys. I was messing around to do a recap on all the stuff I've learnt so far and I came up with a bit of pointless program. Theres no intentionns behind it. Simple to recap. So what I basicly want it to do is to, keep writing however right or left mouse key is pressed but only for an X amount of times. I really want it to run by _IsPressed fuction if possible aswell the way I call the function so I can get trained that o: ... expandcollapse popup;Inclutions #include <GUIConstantsEx.au3> #include <Misc.au3> Testing(10); Calling our function Func Testing($Time); We want it to expect a $Time variable when called Sleep(5); We use sleep so it doens't record the very first click in gui Global $KeyPressed ; other functions want this key...Therefore it's global ;Variable we need in the sturcture Local $Current = 1 Local $hDLL = DllOpen("user32.dll") ;This is the keyboard handler Local $Stop = False Local $Begin = TimerInit() While 1 $Diff = TimerDiff($Begin) if $Diff>=$Time*1000 Then ; Checks if times up if so exitloop ExitLoop Else ;Otherwise it should keep waiting for input and write the input to console Do While $Stop = False ; to make an infity loop untill a key is pressed if _IsPressed("01",$hDLL) Then $Stop = True ; Stops that loop $KeyPressed = "Mouse Left" while _IsPressed(01) Sleep(250) WEnd elseif("02") Then $Stop = True $KeyPressed = "Mouse Right" while _IsPressed(02) Sleep(250) WEnd Endif WEnd Until $Stop = True ; Oh now our loop is on truee so we take a break $Current = $Current + 1 ; Current to debug test how many clicks we had... ConsoleWrite($KeyPressed & @CRLF & "" & $Current) ; Write the key so we can see if it worked $Stop = False ;Restart loop if time isn't up EndIf WEnd DllClose($hDLL); Close the dll we opened in our _Ispressed function Return $KeyPressed ; Return the key this is useless but tell if it's right please XD EndFunc Thats the code after 10 secounds I get "7049Mouse Right" and it doesn't get my left clicks...And Furthermore the hell if I could click 7049 times on 10 secs that 10 pr secound XDDD....Anyway I am realtive new and could anybody help me out here? Link to comment Share on other sites More sharing options...
BrewManNH Posted February 22, 2013 Share Posted February 22, 2013 There's an error in one line. ; this is the corrected line ElseIf _IsPressed("02", $hDLL) Then If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Zanaj Posted February 22, 2013 Author Share Posted February 22, 2013 Thanks for pointing out but it still doesn't explain why it record 7049 clicks when I in reality maybe only did like 17? Link to comment Share on other sites More sharing options...
BrewManNH Posted February 22, 2013 Share Posted February 22, 2013 Because the way you had it written, it would always fire off the ElseIf condition. You didn't even need to press a key. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Zanaj Posted February 22, 2013 Author Share Posted February 22, 2013 Thank you. Now it pick up every click atleast. Now how do I fix this so it's only write WHEN I click rather than keep writing what I previous clicked and wait until I clicked something new? Link to comment Share on other sites More sharing options...
BrewManNH Posted February 22, 2013 Share Posted February 22, 2013 I'm not sure what you mean, for me with that one change it picks up the click I'm doing (right or left mouse) and as soon as you let go it prints out to the console once. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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