Jump to content

Looping PixelGetColor within an existing loop (probably easy)


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...