Jump to content
Sign in to follow this  
computergroove

Looping PixelGetColor within an existing loop (probably easy)

Recommended Posts

computergroove

I have a loop that I need to perform an action when a pixel changes color on my screen. I think I should make another separate function and call it but I am unclear when this is appropriate to do (and I dont know what the code looks like). Here's what I have now.

While 1
    MouseClick ("left",882,525,1)
    Call("GetColor")
    MouseClick ("left",1075,563)
    sleep (1000)
    MouseClick ("left",1075,563)
    sleep (1000)
wend

Func GetColor()
While 1
     x = PixelGetColor(821,306)
     Sleep(1000)
     If x = 0xFFFFFF Then MouseClick("Left",821,306,1)
     Else Call(GetColor)
     EndIf
Wend

I know Im close. Any help is appreciated. Thanks

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
stormbreaker

Global $COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2)

While 1
Sleep(100)
If NOT PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) = $COLOR then
_DoSomething()
$COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2)
EndIf
WEnd

Func _DoSomething()
msgbox(64, 'Hurray', 'Color changed at the pixel')
EndFunc

Perhaps, this is what you want?


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
computergroove

Global $COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2)

While 1
Sleep(100)
If NOT PixelGetColor(@DesktopWidth/2, @DesktopHeight/2) = $COLOR then
_DoSomething()
$COLOR = PixelGetColor(@DesktopWidth/2, @DesktopHeight/2)
EndIf
WEnd

Func _DoSomething()
msgbox(64, 'Hurray', 'Color changed at the pixel')
EndFunc

Perhaps, this is what you want?

I dont want to mold the function around this action but rather add this in a loop in the existing look. Here is what I came up with - that doesn't work.

MouseClick ("left",1080,374)
    sleep (4000)
    MouseClick ("left",882,525,1)
    While 1
        sleep(100)
    If NOT PixelGetColor(821,306) = $color then
        $color = PixelGetColor(821,306)
    EndIf
    WEnd
    MouseClick ("left",821,306)
    sleep (1000)

I am pretty sure that it is bad practice to put a while 1 loop in another loop. I think I want to make a function and call the function from within the other loop.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
ileandros

I am pretty sure that it is bad practice to put a while 1 loop in another loop. I think I want to make a function and call the function from within the other loop.

It is not but I am not understanding what you are trying to loop???

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
water

What do you want to achieve with your script? Wait for a button to change color or ....? Maybe there is an easier way to do what you want.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
computergroove

What do you want to achieve with your script? Wait for a button to change color or ....? Maybe there is an easier way to do what you want.

I have an old Iphone that I have jailbroken and installed both veency (it's the hackers version of VNC) and an app that gives me points for watching videos. When I get enough points then I get an amazon or itunes gift card. I have setup a script that is working right now to automatically gather points all day and night. I want to make my script more efficient. By being able to click on a specific pixel when it changes to the color I want, I shave off 30 seconds per video and almost double my efficiency.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
ileandros

There you go

$x = PixelGetColor(821,306)

While (True)
Sleep(100)
$move = MouseMove(882,525)
While (True)
Sleep(100)
If $x = 0xFFFFFFThen
MouseClick("Left",821,306,1)
MsgBox(0,"Succed", "Pixel exists") ;Delete MsgBox it is only to explain
ExitLoop
Else
MsgBox(0,"Error", "Pixel doesn't exists") ;Delete MsgBox it is only to explain
ExitLoop
EndIf
WEnd
WEnd

Hope it is what you're looking for

Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
computergroove

This is my final product. I was not aware I could place while loops within the main loop.

<snip>

Edited by Melba23
Code removed

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
Melba23

computergroove,

Having looked at what "App Trailers" is, I have decided that "fast hacking" it is not something we wish to support - wear out your own fingers if you want to earn "free money". Code deleted and thread closed. Do not ask any further questions on this. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×