tp9191 Posted December 16, 2015 Share Posted December 16, 2015 Hello, good people. Basically what I'm trying to do is initially check a pixel, then wait 20 seconds, and check it again. If the subsequent pixel check is the same as the previous one, then I want it to do some statements (I plan on doing some simple sends and mouseclicks), if not, then I want it to sleep until it does in a loop.HotKeySet("`", "F1") HotKeySet("~", "Terminate") Func F1() While 1 Local $test = PixelGetColor (600, 500) Local $test2 = PixelGetColor (600, 500) If $test = True Then Sleep (20000) If $test2 = $test1 Then ToolTip ("blah", 400, 0, "blah") Else Sleep (1000) EndIf EndIf WEnd EndFunc While 1 Sleep (100) WEnd Func Terminate() Exit 0 EndFunc Yeah, it makes literally little to no sense. But I know I have to post something or else I would just look like a huge jerk. Unfortunately, I could sit here for hours and hardly get anything done. I would appreciate some different sorts of ideas here. Thanks! Link to comment Share on other sites More sharing options...
JohnOne Posted December 16, 2015 Share Posted December 16, 2015 (edited) First, one of your pixelgetcolor calls has to be after Sleep (20000) else they will almost always be the same.Pxelgetcolor returns a number representing a colour, not true or false, that test ... If $test = True Then...will only resolve to false if the colour is black Edited December 16, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tp9191 Posted December 17, 2015 Author Share Posted December 17, 2015 I know mods don't like it when people just come here expecting others to spoon fed by others. However, I really learn better by example so this is quite difficult for me no matter how much I read the help file. You wouldn't understand how many hours I've been sitting trying to think of how to put something together to accomplish what I want to do.If someone could give me other ideas on how to do this, it would be great.However, this is relatively easy, in theory, that I'm sure experienced people could do in their sleep. If someone wants to PM me, its an easy opportunity for a few bucks. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 17, 2015 Moderators Share Posted December 17, 2015 @tp9191, you are correct, this forum is dedicated to helping people with their own scripts. JohnOne has given you some good advice, what have you tried with it? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
tp9191 Posted December 17, 2015 Author Share Posted December 17, 2015 Nothing unfortunately since I really dont fully understand what I'm doing in the first place. I don't know why it is but some of the logic of this program just doesn't make sense to me. It is supposed to read like I'm reading a fluent language in a way but something about it simply does not click right with me. Link to comment Share on other sites More sharing options...
aa2zz6 Posted December 17, 2015 Share Posted December 17, 2015 (edited) tp9191 - Here is a script I wrote and it works for the most part. It's a good starter script. #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "Terminate") $iMinutes = 1 $hTimer = TimerInit() $color = 0x0D66BF ;This is the color it searches for (x,y) coordinates. While 1 ; Endless loop If TimerDiff($hTimer) > ($iMinutes * 20000) Then ;When timer is a certain time it runs $color = PixelGetColor(481, 63) ; Coordinates specified. If $color = true Then MsgBox($MB_SYSTEMMODAL, "Title", "Color was found!", 3) ; Test if it works ; mouse clicks would go here EndIf EndIf WEnd Func Terminate() Exit EndFunc ;==>Terminate Edited December 17, 2015 by aa2zz6 Link to comment Share on other sites More sharing options...
tp9191 Posted December 17, 2015 Author Share Posted December 17, 2015 tp9191 - Here is a script I wrote and it works for the most part. It's a good starter script. #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "Terminate") $iMinutes = 1 $hTimer = TimerInit() $color = 0x0D66BF ;This is the color it searches for. While 1 ; Endless loop If TimerDiff($hTimer) > ($iMinutes * 20000) Then ;When timer is a certain time it runs $color = PixelGetColor(481, 63) ; Coordinates specified. If $color = true Then MsgBox($MB_SYSTEMMODAL, "Title", "Color was found!", 3) ; Test if it works ; mouse clicks would go here EndIf EndIf WEnd Func Terminate() Exit EndFunc ;==>Terminate Thanks. I will try it when I get a chance and report back later. Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2015 Share Posted December 17, 2015 Thanks. I will try it when I get a chance and report back later.Just remember what I said about what Pxelgetcolor returns?Did you receive my PM yesterday? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tp9191 Posted December 17, 2015 Author Share Posted December 17, 2015 tp9191 - Here is a script I wrote and it works for the most part. It's a good starter script. #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "Terminate") $iMinutes = 1 $hTimer = TimerInit() $color = 0x0D66BF ;This is the color it searches for (x,y) coordinates. While 1 ; Endless loop If TimerDiff($hTimer) > ($iMinutes * 20000) Then ;When timer is a certain time it runs $color = PixelGetColor(481, 63) ; Coordinates specified. If $color = true Then MsgBox($MB_SYSTEMMODAL, "Title", "Color was found!", 3) ; Test if it works ; mouse clicks would go here EndIf EndIf WEnd Func Terminate() Exit EndFunc ;==>Terminate Hey, I just had a look at it and noticed it has a pixel color defined. I am not looking for a specific color; just wanting it to check whether or not it's the same pixel color from 20 seconds ago? Is it correct that the script is not doing such check? Link to comment Share on other sites More sharing options...
BrewManNH Posted December 17, 2015 Share Posted December 17, 2015 (edited) Try this version,aa2zz6's had the same defect your original script had. #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "Terminate") Global $iMinutes = 1, $hTimer = TimerInit() $OldColor = PixelGetColor(481, 63) ; get original color at specified pixel While 1 ; Endless loop If TimerDiff($hTimer) > ($iMinutes * 20000) Then ;When timer is a certain time it runs $color = PixelGetColor(481, 63) ; get current color of pixel If $color <> $OldColor Then ; if they're not the same color do this MsgBox($MB_SYSTEMMODAL, "Title", "Color was found!", 3) ; Test if it works ; mouse clicks would go here $OldColor = $color Else ; if they are the same do something else here ; do something here EndIf EndIf WEnd Func Terminate() Exit EndFunc ;==>Terminate Edited December 17, 2015 by BrewManNH 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...
tp9191 Posted December 18, 2015 Author Share Posted December 18, 2015 Try this version,aa2zz6's had the same defect your original script had. #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "Terminate") Global $iMinutes = 1, $hTimer = TimerInit() $OldColor = PixelGetColor(481, 63) ; get original color at specified pixel While 1 ; Endless loop If TimerDiff($hTimer) > ($iMinutes * 20000) Then ;When timer is a certain time it runs $color = PixelGetColor(481, 63) ; get current color of pixel If $color <> $OldColor Then ; if they're not the same color do this MsgBox($MB_SYSTEMMODAL, "Title", "Color was found!", 3) ; Test if it works ; mouse clicks would go here $OldColor = $color Else ; if they are the same do something else here ; do something here EndIf EndIf WEnd Func Terminate() Exit EndFunc ;==>Terminate Looks good so far. But, what's the $OldColor = $color line in there for? Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2015 Share Posted December 18, 2015 so it does not keep firing after change until it changes again. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tp9191 Posted December 18, 2015 Author Share Posted December 18, 2015 so it does not keep firing after change until it changes again.My brain does not quite compute why it prevents that from happening. Is it basically like "Yeah. Fine. We are equal to each other. So quit asking." ? Lol I don't really know. Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2015 Share Posted December 18, 2015 when the pixel changes, the msgbox shows, and it wont show again until it changes again, but it asks on every iteration of the liip. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tp9191 Posted December 20, 2015 Author Share Posted December 20, 2015 (edited) when the pixel changes, the msgbox shows, and it wont show again until it changes again, but it asks on every iteration of the liip.What is liip? EDIT: oh LOOP, hah.I actually wanted to run mouseclicks if pixel checks were the same, not if they were different. So that means I can simply change <> to = ? Edited December 20, 2015 by tp9191 Link to comment Share on other sites More sharing options...
Bert Posted December 20, 2015 Share Posted December 20, 2015 can I ask a simple question - why the pixel check? why not just check the state of the control? (like a button for example) Pixel checking is notoriously unreliable. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
JohnOne Posted December 20, 2015 Share Posted December 20, 2015 What is liip? EDIT: oh LOOP, hah.I actually wanted to run mouseclicks if pixel checks were the same, not if they were different. So that means I can simply change <> to = ?Yes.Careful with above question, could be a trap. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tp9191 Posted December 20, 2015 Author Share Posted December 20, 2015 can I ask a simple question - why the pixel check? why not just check the state of the control? (like a button for example) Pixel checking is notoriously unreliable. It is perfectly fine. It is just to check if a video has frozen.Yes.Careful with above question, could be a trap.I think I know what you mean, haha. But no I'm not doing that.Quick question: Does the script remember the value of PixelGetColors through each iteration of the loop? I kinda get the feeling that it is.Still having issues, but trying to fix it without any additional help here. Thanks. Link to comment Share on other sites More sharing options...
aa2zz6 Posted December 20, 2015 Share Posted December 20, 2015 tp9191 - We are here to help. Provide what you have edited and or created and we can further assist you. Link to comment Share on other sites More sharing options...
Bert Posted December 21, 2015 Share Posted December 21, 2015 video frozen - makes perfect sense. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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