Jump to content

PixelGetColor error or something?


Recommended Posts

Hello i wrote script which uses pixels to work. Unfortunately he stopped working poperly. I used AutoIt info tool to check pixel color but despite good pixel script doesnt work good.

Is there any solution to perform action if pixel is good? Maybe time in sleep is too low. Few days ago everything was working... DPI and resolution are ok.

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
HotKeySet("{ESC}", "koniec")

FileInstall ("C:\Users\magazyn1\Downloads\1.wav","")
Func koniec()
        Exit
    EndFunc  
Example()
Func zaslona()
    sleep(1000)

MouseClickDrag($MOUSE_CLICK_LEFT, 963, 1009, 960, 273)
sleep(1000)
EndFunc
Func Example()

       
        Opt("GUIOnEventMode", 1)
        GUICreate("MyGUI")
        Local $hGUI = GUICreate("Przesiewacz by ORL", 300, 100)
        GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
        GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
        GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
        
    
    $iButton1 = GUICtrlCreateButton("Przygotowanie", 60, 20)
    GUICtrlSetOnEvent($iButton1, "przyg")
        $iButton2 = GUICtrlCreateButton("Zasłona",140, 20)
    GUICtrlSetOnEvent($iButton2, "zaslona")
    $iButton3 = GUICtrlCreateButton("0", 95,50,40,20)
    GUICtrlSetOnEvent($iButton3, "regaly")
       $iButton4 = GUICtrlCreateButton("A B S Z", 140, 50,60,20)
        GUICtrlSetOnEvent($iButton4, "ABSZ")
        GUICtrlCreateLabel("Only for Res: 1920x1080, DPI: 100%", 20,80) 
       

        GUISetState(@SW_SHOW)

      
        While 1
                Sleep(10)
        WEnd
EndFunc  
func przyg ()
    
    
sleep(5000)
    
MouseClick("",496, 69)
    
Send("^0")
sleep(2000)

MouseClick("",855, 192)
Sleep(1000)

mouseClick("",818, 212,2)
Sleep(1000)

Send("1")
Sleep(1000)

MouseClick("",819, 236,2)
Sleep(1000)

Send("4")
sleep(1000)

send("{ENTER}")
sleep(1000)

Local $ibaner = PixelGetColor(1913, 386)
if $ibaner =  15132390 Then
    MouseClick("",1916,981,2)
EndIf
sleep(1000)

Local $ibaner1 = PixelGetColor(941,990)
if $ibaner1 =  7764866 Then
    MouseClick("",1025,993,1)
    sleep(1000)
    MouseClick("",980,1021,1)
    sleep(1000)
    
    MouseClick("",1912,265,3)
    
    MouseClick("",1912,265,3)
    
    MouseClick("",1912,265,3)
    
    sleep(2000)
EndIf

MouseClickDrag($MOUSE_CLICK_LEFT, 963, 1009, 960, 273)
sleep(1000)

    
MouseClick("",458, 288)
sleep(1000)

MouseClick("",286, 287)

sleep(1000)

Local $iCol1 = PixelGetColor(1424,364)

if $iCol1 = 16447992 or $iCol1 = 12829634  Then
    MouseClick($MOUSE_CLICK_RIGHT, 1366, 378)
    sleep(1000)
    MouseClick("",1462,443)
    sleep(1000)
    
EndIf


sleep(1000)
MouseClickDrag($MOUSE_CLICK_LEFT, 226, 108, 231,146)
sleep(1000)
MouseClick("",13,147)
sleep(1000)
Send("{F5}")
EndFunc

Func SpecialEvents()
        Select
               Case @GUI_CtrlId = $GUI_EVENT_CLOSE
                        
                        Exit

    

        EndSelect
        

EndFunc  

Func ABSZ()
    

    local $b = 0
    

Local $l_dok_wprow = InputBox(" ", "Liczba dokumentów do przypisania")
Local $login = InputBox(" ", "Login")
Local $l_dok = 0
            
sleep(5000)

MouseClick("",623, 72)
Do
$4poz = PixelGetColor(1080, 510)    
$3poz = PixelGetColor(1080, 490)
$2poz = PixelGetColor(1080, 470)
$1poz = PixelGetColor(1080, 450)
$antyblok = PixelGetColor(325, 261)
$antyblok2 = PixelGetColor(12, 261)

if $antyblok = 15397622 Then
    $b = $b + 1
Else
    $b = $b - 1
EndIf

if $b=5 or  $b =-5 Then
    ExitLoop
EndIf

if $antyblok2 = 10860233 Then
    ExitLoop
EndIf

Select

case  $4poz = 16777185
    
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColor2 = PixelGetColor(1250,450)
    Local $iColor3 = PixelGetColor(1250,470)
    Local $iColor4 = PixelGetColor(1250,490)
    Local $iColorZ1= PixelGetColor(1247,429)
    Local $iColorZ2= PixelGetColor(1247,449)
    Local $iColorZ3= PixelGetColor(1247,469)
    Local $iColorZ4= PixelGetColor(1247,489)
    sleep(1000)

   if $iColor1 = 0 or  $iColor1 =3684401 or $iColor1 = 1315858 or $iColorZ1 = 6645081 and $iColor2 = 0 or  $iColor2 =3684401 or $iColor2 = 1315858 or $iColorZ2 = 6645081 and $iColor3 = 0 or  $iColor3 =3684401 or $iColor3 = 1315858 or $iColorZ2 = 6645081   and $iColor4 = 0 or  $iColor4 =3684401 or $iColor4 = 1315858 or $iColorZ2 = 6645081 Then
        
      sleep(1000)
      MouseClick ("", 13,261)
      sleep(500)
      send("{DOWN}")
      sleep(1000)
      $l_dok = $l_dok + 1
     
    Else
        
        send("{DOWN}")
        sleep(1000)
    EndIf
case  $3poz = 16777185
    
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColor2 = PixelGetColor(1250,450)
    Local $iColor3 = PixelGetColor(1250,470)
    Local $iColorZ1 = PixelGetColor(1247,429)
    Local $iColorZ2 = PixelGetColor(1247,449)
    Local $iColorZ3 = PixelGetColor(1247,469)
    sleep(1000)

   if $iColor1 = 0 or  $iColor1 =3684401 or $iColor1 = 1315858 or $iColorZ1 = 6645081 and $iColor2 = 0 or  $iColor2 =3684401 or $iColor2 = 1315858 or $iColorZ2 = 6645081 and $iColor3 = 0 or  $iColor3 =3684401 or $iColor3 = 1315858 or $iColorZ3 = 6645081   Then
        
      sleep(1000)
      MouseClick ("", 13,261)
      sleep(500)
      send("{DOWN}")
      sleep(1000)
      $l_dok = $l_dok + 1
      
        
    Else
        
        send("{DOWN}")
        sleep(1000)
    EndIf

case  $2poz = 16777185
    
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColor2 = PixelGetColor(1250,450)
    Local $iColorZ1 = PixelGetColor(1247,429)
    Local $iColorZ2= PixelGetColor(1247,449)
    sleep(1000)

    if $iColor1 = 0 or  $iColor1 =3684401 or $iColor1 = 1315858  or $iColorZ1 =6645081  and $iColor2 = 0 or  $iColor2 =3684401 or $iColor2 = 1315858 or $iColorZ2 = 6645081 Then
        
      sleep(1000)
      MouseClick ("", 13,261)
      sleep(500)
      send("{DOWN}")
      sleep(1000)
      $l_dok = $l_dok + 1
      
        
    Else
        
        send("{DOWN}")
        sleep(1000)
    EndIf
        
  
    
case  $1poz = 16777185
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColorZ1 = PixelGetColor(1247,429)
    sleep(1000)

if $iColor1 = 0 or  $iColor1 =3684401 or $iColor1 = 1315858 or $iColorZ1 = 6645081  Then
    sleep(1000)
    MouseClick ("", 13,261)
    sleep(500)

    send("{DOWN}")
    sleep(1000)
    $l_dok = $l_dok + 1
    
        
    Else
    send("{DOWN}")
    sleep(1000)

           
        
EndIf
    
    
EndSelect

until $l_dok = $l_dok_wprow

if $l_dok >0 Then

MouseClick("",1854, 70)
sleep(3000)
MouseClick("",95, 69)
sleep(1000)
MouseClick("",132,95)
sleep (2000)
Local $iCs1 = PixelGetColor(695, 569)
Local $iCs2 = PixelGetColor(782, 537)
Local $iCs3 = PixelGetColor(807, 526)
Select
case    $iCs1 = 3753043 
MouseClick("",967, 581)
sleep(1000)
Send($login)
sleep (1000)
MouseClick("",967, 581)
sleep (1000)
MouseClick("",967, 581)
SoundPlay("1.wav", 1)
MsgBox($MB_SYSTEMMODAL,"", "Przypisano około " & $l_dok & " doku. userowi :" &$login)
case    $iCs2 = 3753043 
MouseClick("",948, 588)
sleep(1000)
Send($login)
sleep (1000)
MouseClick("",956, 586)
sleep (1000)
MouseClick("",956, 586)
SoundPlay("1.wav", 1)
MsgBox($MB_SYSTEMMODAL,"", "Przypisano około " & $l_dok & " doku. userowi :" &$login)
case $iCs3 = 3753043 
sleep(1000)
Send($login)
sleep(1000)
MouseClick("",967, 581)
sleep(1000)
MouseClick("",967, 581)
SoundPlay("1.wav", 1)
MsgBox($MB_SYSTEMMODAL,"", "Przypisano około " & $l_dok & " doku. userowi :" &$login)
EndSelect
else 
    MsgBox($MB_SYSTEMMODAL,"", "Brak dokumentów do przypisania")
endif
EndFunc

Func regaly()
 

    
    local $b = 0
    

Local $l_dok_wprow = InputBox(" ", "Liczba dokumentów do przypisania")
Local $login = InputBox(" ", "Login")
Local $l_dok = 0
            
sleep(5000)

MouseClick("",623, 72)

Do
$4poz = PixelGetColor(1080, 510)    
$3poz = PixelGetColor(1080, 490)
$2poz = PixelGetColor(1080, 470)
$1poz = PixelGetColor(1080, 450)
$antyblok = PixelGetColor(325, 261)
$antyblok2 = PixelGetColor(12, 261)

if $antyblok = 15397622 Then
    $b = $b + 1
Else
    $b = $b - 1
EndIf

if $b=5 or  $b =-5 Then
    ExitLoop
EndIf

if $antyblok2 = 10860233 Then
    ExitLoop
EndIf

Select

case  $4poz = 16777185
    
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColor2 = PixelGetColor(1250,450)
    Local $iColor3 = PixelGetColor(1250,470)
    Local $iColor4 = PixelGetColor(1250,490)
    sleep(1000)

    if $iColor1 = 9803139  and $iColor2 = 9803139 and $iColor3 = 9803139 and $iColor4 = 9803139 Then
        
      sleep(1000)
      MouseClick ("", 13,261)
      sleep(500)
      send("{DOWN}")
      sleep(1000)
      $l_dok = $l_dok + 1
     
    Else
        
        send("{DOWN}")
        sleep(1000)
    EndIf
case  $3poz = 16777185
    
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColor2 = PixelGetColor(1250,450)
    Local $iColor3 = PixelGetColor(1250,470)
    sleep(1000)

    if $iColor1 = 9803139  and $iColor2 = 9803139 and $iColor3 = 9803139 Then
        
      sleep(1000)
      MouseClick ("", 13,261)
      sleep(500)
      send("{DOWN}")
      sleep(1000)
      $l_dok = $l_dok + 1
      
        
    Else
        
        send("{DOWN}")
        sleep(1000)
    EndIf

case  $2poz = 16777185
    
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    Local $iColor2 = PixelGetColor(1250,450)
    sleep(1000)

    if $iColor1 = 9803139  and $iColor2 = 9803139 Then
        
      sleep(1000)
      MouseClick ("", 13,261)
      sleep(500)
      send("{DOWN}")
      sleep(1000)
      $l_dok = $l_dok + 1
      
        
    Else
        
        send("{DOWN}")
        sleep(1000)
    EndIf
        
  
    
case  $1poz = 16777185
    MouseClick("",517, 259)
    MouseClick("",662, 260)
    sleep(500)
    Local $iColor1 = PixelGetColor(1250,430)
    sleep(1000)

if $iColor1 = 9803139 Then
    sleep(1000)
    MouseClick ("", 13,261)
    sleep(500)

    send("{DOWN}")
    sleep(1000)
    $l_dok = $l_dok + 1
    
        
    Else
    send("{DOWN}")
    sleep(1000)

           
        
EndIf
    
    
EndSelect

Until  $l_dok = $l_dok_wprow

if $l_dok >0 Then
MouseClick("",1854, 70)
sleep(3000)
MouseClick("",95, 69)
sleep(1000)
MouseClick("",132,95)
sleep (2000)
Local $iCs1 = PixelGetColor(695, 569)
Local $iCs2 = PixelGetColor(782, 537)
Local $iCs3 = PixelGetColor(807, 526)
Select
case    $iCs1 = 3753043 
MouseClick("",967, 581)
sleep(1000)
Send($login)
sleep (1000)
MouseClick("",967, 581)
sleep (1000)
MouseClick("",967, 581)
SoundPlay("1.wav", 1)
MsgBox($MB_SYSTEMMODAL,"", "Przypisano około " & $l_dok & " doku. userowi :" &$login)
case    $iCs2 = 3753043 
MouseClick("",948, 588,2)
sleep(1000)
Send($login)
sleep (1000)
MouseClick("",956, 586)
leep (1000)
MouseClick("",956, 586)
SoundPlay("1.wav", 1)
MsgBox($MB_SYSTEMMODAL,"", "Przypisano około " & $l_dok & " doku. userowi :" &$login)
case $iCs3 = 3753043 
sleep(1000)
Send($login)
sleep(1000)
MouseClick("",967, 581)
sleep(1000)
MouseClick("",967, 581)
SoundPlay("1.wav", 1)
MsgBox($MB_SYSTEMMODAL,"","Przypisano około " & $l_dok & " doku. userowi :" &$login)
EndSelect
else 
    MsgBox($MB_SYSTEMMODAL,"", "Brak dokumentów do przypisania")
EndIf
EndFunc

 

Link to post
Share on other sites
Posted (edited)

I dont have any idea how to not rely on pixels.I would like to make script to sort. I have information  e.g.

E0105
E0103

or

D0105
E0105
C0105

or

E0105
F0205
F0305
A0105

I have selected pixels in E and D which are diffefent and make actions. I dont have access to database I can only compare pixels.

Maybe there is better way how to compare and select only cases only with letter E or only with letter F

If I will change pixelgetcolor to pixelsearch and make more sleep time it will help? I will test script by adding tooltip in every conditionals. I hope this will work...

Edited by orok
.
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...