Jump to content

PixelSearch returning errors


the_OG
 Share

Recommended Posts

Hello, my pixelsearch script that I made in hopes of learning more about AutoIt has been giving me errors left and right. How would I fix this? Could you explain indepth?

; *************************************
;   pixelsearch test
; *************************************

#include <GuiConstants.au3>
Opt("GUICoordMode",2)
AutoItSetOption("TrayIconHide", 1)

GUICreate("", 225, 100,200,200,$WS_DLGFRAME,$WS_THICKFRAME)

GUICTRLcreateLabel("Press escape to close", 55, 30, 220,150,-1,-1)


; ***** define what colour we're wanting 
$pos = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,0x0E7112) ; a shade of blue
        
; ***** set hotkeys 
Global $scrp
HotKeySet("{End}", "Toggle") ; hotkey to turn on/off

Func Toggle()
    $scrp = NOT $scrp
    While $scrp

        sleep(50)
        MouseClick("left", $pos[0], $pos[1],1,0)
                Send("{End}")
        
        WEnd
EndFunc
; ******

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

~The_OG

Link to comment
Share on other sites

  • 2 months later...

Hello, my pixelsearch script that I made in hopes of learning more about AutoIt has been giving me errors left and right. How would I fix this? Could you explain indepth?

; *************************************
;   pixelsearch test
; *************************************

#include <GuiConstants.au3>
Opt("GUICoordMode",2)
AutoItSetOption("TrayIconHide", 1)

GUICreate("", 225, 100,200,200,$WS_DLGFRAME,$WS_THICKFRAME)

GUICTRLcreateLabel("Press escape to close", 55, 30, 220,150,-1,-1)
; ***** define what colour we're wanting 
$pos = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,0x0E7112) ; a shade of blue
        
; ***** set hotkeys 
Global $scrp
HotKeySet("{End}", "Toggle") ; hotkey to turn on/off

Func Toggle()
    $scrp = NOT $scrp
    While $scrp

        sleep(50)
        MouseClick("left", $pos[0], $pos[1],1,0)
                Send("{End}")
        
        WEnd
EndFunc
; ******

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

~The_OG

What is the error you get?

Link to comment
Share on other sites

Most likely he's getting an invalid array error on this line:

MouseClick("left", $pos[0], $pos[1],1,0)

(At least that's what I got).

Try adding some shade variation to your pixel search (6th param). If I had to guess, it's not finding the colour you're searching for anywhere (since you're doing an exact match), and thus it does not return an array. Try checking @error after your pixelsearch, or checking the $pos variable with IsArray().

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...