Jump to content

Problem with PixelGetColor


michu
 Share

Recommended Posts

Hello everyone

I have problem with my simple script. When at position (1743,511) on second page is red color I wan't to left click next button to third page and back to first page by pressing 2 times Escape,  otherwise it should back to the first page and try over and over again as soon as there will be red color on second page. For now script doesn't work, I don't know why. It's looks like function PixelGetColor doesn't work.

Thanks in advance for help

HotKeySet("{Space}", "Terminate")
While 1
   MouseClick("left", 1826 ,1013, 1, 100) ;it's next button on first page
   $var = PixelGetColor (1743,511)
If $var = 0xFF0000 Then
   MouseClick("left", 1743, 511, 1, 100) ;it's next button on second page
   Send("{ESC 1}")
   Sleep(500)
   Send("{ESC 1}")
   Sleep(500)
Else
   Send("{ESC 1}") ;back to the first page
   Sleep(1500)
 EndIf
Sleep(500)
WEnd
Func Terminate()
    Exit 0
EndFunc

 

Edited by michu
Link to comment
Share on other sites

  • Moderators

michu,

Welcome to the AutoIt forums.

It's looks like function PixelGetColor doesn't work

 I am sure it is more likely to be your code. That code snippet will act extremely quickly - are you sure that the "page" will have changed by the time you look for the "red" section and then click on one of the buttons? If the page has not yet correctly loaded then obviously none of the actions will happen on the "page" you think you are using.

So how can you tell if the page has indeed changed? What allows you to confirm that the "red" section might be present and that he buttons are ready to be pressed? Once you can confirm that the "page" is correctly loaded, then you can start looking and actioning it.

M23

Edited by Melba23
Typo

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

When I increase times to seconds and the second page load with not red color long time before cursor is in position (1743,511) the script press next button. Maybe I should declare 2 colours? The second page is only in two colours - red and white. 

Red> go to next page and then press 2 times escape button

White> back to first page by pressing one time escape button and try again

 

Edited by michu
Link to comment
Share on other sites

  • Moderators

michu,

Without sight of the "pages" it is hard to say whether your idea is a good one. But it seems that as I suspected timing was the major problem in your earlier script - I am sure you can come up with a solution now.

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

There is no waitpixelcolor. You need to add some lines of sleep in there to allow the page to change.

While 1
    MouseClick("",1826,1013,1,100);100 is pretty slow for the mouse move.
    Sleep(3000);sleep for 3 seconds to let the page load
    $var - PixelGetColor(1743,511)
    If $Var == 0xFF0000 Then
        MouseClick("",1743,511,1,100)
        Sleep(250)
        Send("{ESC}")
        Sleep(250)
        Send("{ESC}")
    Else
        Send("{ESC}")
        Sleep(1.5 * 1000);sleep for 1.5 seconds
    EndIf
Sleep(500)
WEnd

Func Terminate()
    Exit 0
EndFunc

 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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