Jump to content

Anyone can check my script please ?


Recommended Posts

Hi,

I need some help for my script. I'm a newbe and I don't know all of features AutoIt has.

Here, I just want to send keystroke, when x pixel get x color code. I want the script checks, as fast as it can, the color of 6 pixel I have wrote, and react in function of these colors. It's very simple.

But when I strat the script, OK the msgbox, and activating the window, nothing happen :) No error, the script is still running.

If someone can help me, it would be appreciated.

HotKeySet("{ESC}", "close") ; => Press ESC to stop the macro
Func close()
Exit
EndFunc
$count = 0
$max = 100001 ; => This is how many times the macro will loop
$tempo1 = 500
$tempo2 = 1000
$tempo3 = 2500
MsgBox(0, "", "")
Winwait("")
While $count < $max
;Schedule
If PixelGetColor(1179,555) = 858585 Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Starting
If PixelGetColor(297,768) = 050505 Then
  Send("{ENTER}")
  sleep($tempo3)
EndIf
;Strating with space
If PixelGetColor(297,768) <> 050505 Then
  Send("{SPACE}")
  sleep($tempo3)
EndIf
;Ready1
If PixelGetColor(1040,830) = 181918 Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Ready2
If PixelGetColor(1630,842) = 000000  Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Ready3
If PixelGetColor(325,465) = 000000 Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;End
If PixelGetColor(1080,50) = 000000 Then
  Send("!{TAB}") ; ALT+TAB
  sleep($tempo2)
  WinActivate("")
  Winwait("")
  Sleep($tempo1)
  Send("{ENTER}")
EndIf
WEnd
Edited by UnknowName
Link to comment
Share on other sites

They are.

If there are not any error in my script, whether it's the script don't check pixels at all, whether the scrpit can't check pixels on fullscreen application, in both cases, I doubt...

I try Zedna, thanks.

Edited by UnknowName
Link to comment
Share on other sites

It don't work properly, at all... But for the Ready3, it works good. It's the only one. Alt+tab are too previous (I mean, it alt+tab when the pixel isn't black O_O), and other check don't works at all... Myabe my coordiantes are not good, I used GIMP, for coordinates+colors.

I have some troubles, does the script check ervytime, as fast as it can, the pixels I have wrote, and when he found one, does it do the function I have indicated ? I don't understand how it works with my script, line by line, or permanent refresh, searching pixels color ?

There is my script, edited :

HotKeySet("{ESC}", "close") ; => Press ESC to stop the macro
Func close()
Exit
EndFunc
$count = 0
$max = 100001 ; => This is how many times the macro will loop
$tempo1 = 500
$tempo2 = 1000
$tempo3 = 2500
MsgBox(0, "", "")
Winwait("")
While $count < $max
;Schedule
If PixelGetColor(1179,555) = 0x848484 Then
  ConsoleWrite('1179,555 0x' & Hex(PixelGetColor(1179,555),6) & @CRLF)
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Starting
If PixelGetColor(297,768) = 0x050505 Then
  ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF)
  Send("{ENTER}")
  sleep($tempo3)
EndIf
;Strating with space
If PixelGetColor(297,768) <> 0x050505 Then
  ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF)
  Send("{SPACE}")
  sleep($tempo3)
EndIf
;Ready1
If PixelGetColor(1040,830) = 0x2A292A Then
  ConsoleWrite('1040,830 0x' & Hex(PixelGetColor(1040,830),6) & @CRLF)
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Ready2
If PixelGetColor(1630,842) = 0x030403  Then
  ConsoleWrite('1630,842 0x' & Hex(PixelGetColor(1630,842),6) & @CRLF)
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Ready3
If PixelGetColor(325,465) = 0x000000 Then
  ConsoleWrite('325,465 0x' & Hex(PixelGetColor(325,465),6) & @CRLF)
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;End
If PixelGetColor(1080,50) = 0x000000 Then
  ConsoleWrite('1080,50 0x' & Hex(PixelGetColor(1080,50),6) & @CRLF)
  Send("!{TAB}") ; ALT+TAB
  sleep($tempo2)
  WinActivate("")
  Winwait("")
  Sleep($tempo1)
  Send("{ENTER}")
EndIf
WEnd
Edited by UnknowName
Link to comment
Share on other sites

ConsoleWrite BEFORE PixelGetColor

HotKeySet("{ESC}", "close") ; => Press ESC to stop the macro
Func close()
Exit
EndFunc
$count = 0
$max = 100001 ; => This is how many times the macro will loop
$tempo1 = 500
$tempo2 = 1000
$tempo3 = 2500
MsgBox(0, "", "")
Winwait("")
While $count < $max
;Schedule
ConsoleWrite('1179,555 0x' & Hex(PixelGetColor(1179,555),6) & @CRLF)
If PixelGetColor(1179,555) = 0x848484 Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Starting
ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF)
If PixelGetColor(297,768) = 0x050505 Then
  Send("{ENTER}")
  sleep($tempo3)
EndIf
;Strating with space
ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF)
If PixelGetColor(297,768) <> 0x050505 Then
  Send("{SPACE}")
  sleep($tempo3)
EndIf
;Ready1
ConsoleWrite('1040,830 0x' & Hex(PixelGetColor(1040,830),6) & @CRLF)
If PixelGetColor(1040,830) = 0x2A292A Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Ready2
ConsoleWrite('1630,842 0x' & Hex(PixelGetColor(1630,842),6) & @CRLF)
If PixelGetColor(1630,842) = 0x030403  Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;Ready3
ConsoleWrite('325,465 0x' & Hex(PixelGetColor(325,465),6) & @CRLF)
If PixelGetColor(325,465) = 0x000000 Then
  Send("{ENTER}")
  sleep($tempo1)
EndIf
;End
ConsoleWrite('1080,50 0x' & Hex(PixelGetColor(1080,50),6) & @CRLF)
If PixelGetColor(1080,50) = 0x000000 Then
  Send("!{TAB}") ; ALT+TAB
  sleep($tempo2)
  WinActivate("")
  Winwait("")
  Sleep($tempo1)
  Send("{ENTER}")
EndIf
WEnd
Edited by Zedna
Link to comment
Share on other sites

Works better...much better :) <3

Edit : At End, the script keep alttabbing, and don't process line by line, how can I fix it ? Can't I tell the script to send ALTTAB just one time ?

Another question : How can I tell to the script to check the color of a rectangle, and if the rectangle is full of this color, => Then .....

Edited by UnknowName
Link to comment
Share on other sites

Alttabbing still don't work properly. The script spam alttab :)

I want : When 1800,145 is black, press alt tab, activate the window, and press enter.

;End
ConsoleWrite('1800,145 0x' & Hex(PixelGetColor(1800,145),6) & @CRLF)
    If PixelGetColor(1800,145) = 0x000000 Then
        sleep($tempo3)
        Send("!{TAB}")
        WinActivate("")
        Winwait("")
        sleep($tempo2)
        Send("{ENTER}")
    EndIf

It spams alttab and don't press enter at all, like that

Edited by UnknowName
Link to comment
Share on other sites

Okay thanks.

EDIT : How can I improve my script build ? It seems to be too slow, sometimes.

I think it's slow because of this :

;End
ConsoleWrite('1672,819 0x' & Hex(PixelGetColor(1672,819),6) & @CRLF)
If PixelGetColor(1672,819) = 0x6b6d5a Then
  sleep($tempo3)
  Send("!{TAB}")
  WinActivate("")
  sleep($tempo1)
EndIf

tempo3 = 10 000 millisec :/

And it seems even if PixelGetColor(1672,819) <> 0x6b6d5a, tempo3 is activated...

Edited by UnknowName
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...