Sign in to follow this  
Followers 0
Sc1

Variable problems

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



Hi!

You're not using the color in the input control, you're using the control id :P

Use GUICtrlRead($box) instead :P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

The latter, and it should work. It does for me. :P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


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
Sign in to follow this  
Followers 0