NomadByNature Posted August 11, 2013 Share Posted August 11, 2013 Thank you to all who have helped me along the way thus far on this little project of mine. (those of you who have been following it know what i am talking about), although i have successfully made about 10 automations in the past 6 months of this software, none were this complex, and i have learned a lot from all of you. and that deserves a special thanks, I am an independent person, so the fact that people will "teach" instead of just give the answer here means a lot to me. So onto the question....... I have this script to automate accepting new registrants to my website, which has to be done manually as i normally, have to verify a bit of information before i accept them. I am also CHEAP, so rather than hire someone to do this for me, i spend 8-16 hours a day some times, hovering around a computer/tablet/phone or some sort of web interface to do the work myself. with great help from some of our fellow forum members, i managed to work out this GREAT little script over the past 2 days, and it worked like a charm, i got to take my wife out to dinner last night, and just let this little dandy of a script do the work for me so i wasnt constantly checking the site on my tablet at the resturant. HotKeySet("{ESC}", "Terminate") While 1 Do sleep(2000) MouseClick("left", 362, 146) Sleep(3000) Until PixelGetColor (977, 239) <> 0xDAE1DF MouseClick("left", 520, 287) Sleep(3000) MouseClick("left", 553, 270) Local $timer=TimerInit() Do Sleep(2000) Until PixelGetColor (1037, 477) <> 0xCF6B66 Or TimerDiff($timer)>240000 MouseClick("left", 479, 666) WEnd Func Terminate() Exit 0 EndFunc Before i get too much into making myself go mad researching things to try and do what i want next. i simply want to know if it is even possible. All of what i want next has to do with recording the tasks in a numeric fashion. i know that things like that require a DB of some sort, as well as a basic GUI. Most of the reason i want to track it, is so i can imporove efficiancy as this project progresses. So... part one (for real this time) The first part of the script clicks the refresh button on my website in the admin pannel, then checks another button to see if it has changed color. if it has changed color, it clicks a button at another location. What i want, is a way to track how many times it clicks then checks, clicks than checks before the check is successful and it moves to the next step. The next thing i want to track is how many total times it makes it all the way through the script from start to finish without having to use the "timeout" function on the "or Timerdiff" line of line 14. The next thing i want to track is how many times it had to use the time out, skip, repeat option or say, how many times the 240000 ms passed. and lastly i want to track an hour by hour running total, for my own amusment, to see how many hours i have saved by using this wonderful application, It works ok for right now, but this will let me know if i want to invest more time, or more than likley money to hire someone to turn this chopped together script into something real that i can use to replace myself all together in that aspect of my business. So to summarize.... When i get back to my computer after being away. i would like to press a button, lets say ctrl+Q, have the application pause, and a window pop up that says something like the following STATS C - F X number / X number | (the number of times it checked, and the number of times it did change color from the first, do ... until set) Complete X Number | (the number of times it made it through the whole script and started over) Timeout X Number | (the number of times the 240000ms exception was used) Usage XX:XX time | ( the total amount of time in hours and minutes, Total from every time i use this app, that it has been running) I am not looking for someone to spend a bunch of time doing this for me, i want to do it myself, i like to learn, To start, i just want to know if it is possible, and if someone can get me started in the right direction to learning to do it. something more than "search the forum" trust that i did that for hours before posting. Thanks, (and special thanks to Edano, as i know you will chime in on this subject with great wisdom as you allways do) Link to comment Share on other sites More sharing options...
0xdefea7 Posted August 11, 2013 Share Posted August 11, 2013 (edited) Yes, it is possible. This should get you started. I commented each line I added, let me know if you have questions expandcollapse popup#include <File.au3> ;Needded for the logging function at the bottom HotKeySet("{ESC}", "Terminate") $iNumClicksThenChecks = 0 ;Counter for number of times refresh clicked $hTotalHoursTimer = TimerInit() While 1 Do Sleep(2000) MouseClick("left", 362, 146) Sleep(3000) $iNumClicksThenChecks += 1 ; Each time the loop runs, count up LogChange("Refresh clicked: " & $iNumClicksThenChecks) ;Log the number of changes Until PixelGetColor(977, 239) <> 0xDAE1DF $iNumClicksThenChecks = 0 ;Set number of refreshes back to 0 LogChange() LogChange("Loop 1 Exit:") LogChange("Button1 color <> 0xDAE1DF") ;Log the button color changing MouseClick("left", 520, 287) Sleep(3000) MouseClick("left", 553, 270) If PixelGetColor(1037, 477) <> 0xCF6B66 And TimerDiff($timer) > 240000 Then ; Run all the way through LogChange("Skipping loop 2") ; Log the change MouseClick("left", 479, 666) ; Click the mouse (same as bottom) ContinueLoop ; Go back to the top of the loop EndIf Local $timer = TimerInit() Do Sleep(2000) Until PixelGetColor(1037, 477) <> 0xCF6B66 Or TimerDiff($timer) > 240000 LogChange() LogChange("Loop 2 Exit:") LogChange("Timer has reached: " & TimerDiff($timer)) ;Log timer diff LogChange("Button color is: " & PixelGetColor(1037, 477) ;Log pixel color MouseClick("left", 479, 666) WEnd Func Terminate() Local $aTime = _Diff2Time(TimerDiff($hTotalHoursTimer)) ;Get the total hours in the exit function and sort them LogChange("Total hours saved (H:M:S): " & $aTime[0] & ":" & $aTime[1] & ":" & $aTime[2]) ;Record hours saved LogChange("The program will now exit.") ;Exit message Exit 0 EndFunc ;==>Terminate Func LogChange($sText = @CRLF) ; Function to log the changes _FileWriteLog(@DesktopDir & "\MyLog.log", $sText) ;Log the changes with timestamp EndFunc ;==>LogChange ;http://www.autoitscript.com/forum/topic/94697-how-can-i-display-timerdiff-in-hms-format/ ;By Yashied Func _Diff2Time($TimerDiff) ;Returns an array ;$HMS[0] = Hour ;$HMS[1] = Min ;$HMS[2] = Sec Dim $HMS[3] $HMS[2] = Int($TimerDiff / 1000) $HMS[1] = $HMS[2] - Mod($HMS[2], 60) $HMS[2] -= $HMS[1] $HMS[1] /= 60 $HMS[0] = $HMS[1] - Mod($HMS[1], 60) $HMS[1] -= $HMS[0] $HMS[0] /= 60 Return $HMS EndFunc ;==>_Diff2Time Edited August 11, 2013 by 0xdefea7 Link to comment Share on other sites More sharing options...
jaberwacky Posted August 11, 2013 Share Posted August 11, 2013 Well, you can't beat that. Code but without all of the work. Yes, it is possible. This should get you started. That should get him started opn his vacation and now he can sit back and make money off of his business. I wonder if he'll donate to you? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
0xdefea7 Posted August 11, 2013 Share Posted August 11, 2013 That should get him started opn his vacation and now he can sit back and make money off of his business. I wonder if he'll donate to you? I didn't do ALL of it. I left a little out. But I only spent a few mins so just be nice to someone today in return Link to comment Share on other sites More sharing options...
Edano Posted August 11, 2013 Share Posted August 11, 2013 great wisdom [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
NomadByNature Posted August 11, 2013 Author Share Posted August 11, 2013 Yes, it is possible. This should get you started. I commented each line I added, let me know if you have questions expandcollapse popup#include <File.au3> ;Needded for the logging function at the bottom HotKeySet("{ESC}", "Terminate") $iNumClicksThenChecks = 0 ;Counter for number of times refresh clicked $hTotalHoursTimer = TimerInit() While 1 Do Sleep(2000) MouseClick("left", 362, 146) Sleep(3000) $iNumClicksThenChecks += 1 ; Each time the loop runs, count up LogChange("Refresh clicked: " & $iNumClicksThenChecks) ;Log the number of changes Until PixelGetColor(977, 239) <> 0xDAE1DF $iNumClicksThenChecks = 0 ;Set number of refreshes back to 0 LogChange() LogChange("Loop 1 Exit:") LogChange("Button1 color <> 0xDAE1DF") ;Log the button color changing MouseClick("left", 520, 287) Sleep(3000) MouseClick("left", 553, 270) If PixelGetColor(1037, 477) <> 0xCF6B66 And TimerDiff($timer) > 240000 Then ; Run all the way through LogChange("Skipping loop 2") ; Log the change MouseClick("left", 479, 666) ; Click the mouse (same as bottom) ContinueLoop ; Go back to the top of the loop EndIf Local $timer = TimerInit() Do Sleep(2000) Until PixelGetColor(1037, 477) <> 0xCF6B66 Or TimerDiff($timer) > 240000 LogChange() LogChange("Loop 2 Exit:") LogChange("Timer has reached: " & TimerDiff($timer)) ;Log timer diff LogChange("Button color is: " & PixelGetColor(1037, 477) ;Log pixel color MouseClick("left", 479, 666) WEnd Func Terminate() Local $aTime = _Diff2Time(TimerDiff($hTotalHoursTimer)) ;Get the total hours in the exit function and sort them LogChange("Total hours saved (H:M:S): " & $aTime[0] & ":" & $aTime[1] & ":" & $aTime[2]) ;Record hours saved LogChange("The program will now exit.") ;Exit message Exit 0 EndFunc ;==>Terminate Func LogChange($sText = @CRLF) ; Function to log the changes _FileWriteLog(@DesktopDir & "\MyLog.log", $sText) ;Log the changes with timestamp EndFunc ;==>LogChange ;http://www.autoitscript.com/forum/topic/94697-how-can-i-display-timerdiff-in-hms-format/ ;By Yashied Func _Diff2Time($TimerDiff) ;Returns an array ;$HMS[0] = Hour ;$HMS[1] = Min ;$HMS[2] = Sec Dim $HMS[3] $HMS[2] = Int($TimerDiff / 1000) $HMS[1] = $HMS[2] - Mod($HMS[2], 60) $HMS[2] -= $HMS[1] $HMS[1] /= 60 $HMS[0] = $HMS[1] - Mod($HMS[1], 60) $HMS[1] -= $HMS[0] $HMS[0] /= 60 Return $HMS EndFunc ;==>_Diff2Time Super thanks Oxdefea7, Kept me busy for the last 2 hours for sure, and a special thanks for commenting it so i could learn from it. Lesser the missing close on line 42 "))" evading me for 10 minutes, i have made a good bit of headway. I will pop back in if i get stuck on anything, Link to comment Share on other sites More sharing options...
0xdefea7 Posted August 11, 2013 Share Posted August 11, 2013 Fail, I totally missed that close on 42, common rookie mistake Glad it helped you out. 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