Jump to content

Variable problems


 Share

Recommended Posts

Hey, for some reason my script has a problem with using variables in some areas instead of the normal given value.

One of them is when I want to type something into an input box and then have it run it, for some reason it won't do it.

So they script would just be: Run $program as far as makes sense to me?

The second one is slightly more complicated. The PixelSearch command is having trouble taking a variable for the colour it should look for. The script is below.

CODE
#include <Windowsconstants.au3>

#include <GuiConstantsEx.au3>

#include <Misc.au3>

#include <GuiButton.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()

Local $GUI, $coords[4]

Local $box, $btn1, $btn2, $msg, $colour, $ans

GUICreate("GetColour", 400, 70)

$box = GUICtrlCreateInput("", 10, 5, 300, 20)

GUICtrlSetState(-1, $GUI_DROPACCEPTED)

$btn1 = GUICtrlCreateButton("Find", 10, 35, 60, 20)

$btn2 = GUICtrlCreateButton("Exit", 70, 35, 60, 20)

Guisetstate()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $btn1

$colour = PixelSearch(0,768,1024,1792, $box, 50)

If $colour = @error Then

$ans = MsgBox(4,"Colour","The colour you were looking for was not found." @CRLF "Would you like to search again?")

If $ans = 7 Then

Exit

EndIf

Else

MouseMove($colour[0],$colour[1],30)

EndIf

Case $msg = $btn2

Exit

EndSelect

WEnd

EndFunc

All that happens when you press the find button is the mouse moves to the bottom left of the screen. I've checked the coordinates, I put a hex code in instead of a variable and if won't find the colour at all. I've looked all through the helpfile and can't find any reason why it wouldn't work...

Thank you for any help in advance.

Link to comment
Share on other sites

So it should now read this?

Case $msg = $btn1

GUICtrlRead($box)

$colour = PixelSearch(0,768,1024,1792, $box, 50)

or

Case $msg = $btn1

$colour = PixelSearch(0,768,1024,1792, GUICtrlRead($box), 50)

I tried both and it's still doing the same thing...

Link to comment
Share on other sites

When putting the colour into the box it needs a 0x in front, correct?

Also I searched white and it went to the bottom right, then searched black and it came up with the msgbox.

Then searched the colour 0055E6 and it didn't find it either.

Edit: Have to go to school now. Will get on a computer if I can. Thanks for your help.

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