Jump to content
Sign in to follow this  
mastermc

Need help getting code to work

Recommended Posts

mastermc

This is the code that i made...

CODE
$win_title = "1 - Windows Picture and Fax Viewer"

sleep (2000)

WinActivate($win_title, "1 - Windows Picture and Fax Viewer")

WinSetOnTop($win_title, "1 - Windows Picture and Fax Viewer", 0)

Sleep(1000)

Func Farm_mats()

$coord = PixelSearch( 0, 0, 1024, 768, 0x3C1F0A, 1, 2)

MouseMove($coord[0],$coord[1],0)

Sleep (100)

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

Sleep (500)

EndFunc

While 1

If @error Then

sleep (1000)

Else

Farm_mats()

EndIf

WEnd

I am using the window preview program just to test it. the problem i am having is it doesn't select that program to make it active, and it wont look for that color and click it.

Any one know what wrong with it?

Share this post


Link to post
Share on other sites
Authenticity

Before going into too many problems that might be the case. Make a simple script that use WinWaitActive($win_title) and then some MsgBox() call to see if your script can reach the MsgBox call. Then make your code something like this:

WinActivate($win_title)

WinWaitActive($win_title)

.

.

.

$Coord = PixelSearch( 0, 0, 1024, 768, 0x3C1F0A, 1, 2) ; Might be issue here because it can be matched many times...

If IsArray($Coord) Then...

Of

If Not @error... ; the color was found.

Edit: About the simple script example I think I was enough clear that you need to activate the window yourself.

Edited by Authenticity

Share this post


Link to post
Share on other sites
mastermc

Before going into too many problems that might be the case. Make a simple script that use WinWaitActive($win_title) and then some MsgBox() call to see if your script can reach the MsgBox call. Then make your code something like this:

WinActivate($win_title)

WinWaitActive($win_title)

I did this part and remove everything except this =
CODE
$win_title = "1 - Windows Picture and Fax Viewer"

Func Farm_mats()

$coord = PixelSearch( 0, 0, 1024, 768, 0x3C1F0A, 1, 2)

MouseMove($coord[0],$coord[1],0)

Sleep (100)

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

Sleep (500)

EndFunc

sleep (2000)

WinActivate($win_title)

WinWaitActive($win_title)

Sleep(1000)

And that part worked fine it opened the window.

$Coord = PixelSearch( 0, 0, 1024, 768, 0x3C1F0A, 1, 2) ; Might be issue here because it can be matched many times...

If IsArray($Coord) Then...

Of

If Not @error... ; the color was found.

Edit: About the simple script example I think I was enough clear that you need to activate the window yourself.

this part you lost me a little on, i know at least now that the problem is in the (if -> then part)

i tried this =

CODE

$win_title = "1 - Windows Picture and Fax Viewer"

Func Farm_mats()

$coord = PixelSearch( 0, 0, 1024, 768, 0x3C1F0A, 1, 2)

MouseMove($coord[0],$coord[1],0)

Sleep (100)

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

Sleep (500)

EndFunc

sleep (2000)

WinActivate($win_title)

WinWaitActive($win_title)

Sleep(1000)

While 1

If IsArray($Coord) Then

Farm_mats

If @error

Sleep (2000)

EndIf

WEnd

but that didn't work ether it made the program give line error and not activate window

Share this post


Link to post
Share on other sites
mastermc

Very sorry for double post but i was messing are with it more and got this ===>

CODE
$win_title = "1 - Windows Picture and Fax Viewer"

sleep (2000)

WinActivate($win_title)

WinWaitActive($win_title)

Sleep(1000)

While 1

Sleep (50)

$coord = PixelSearch( 0, 0, 1024, 768, 0x3C1F0A, 1, 2)

If Not @error Then

MouseMove($coord[0],$coord[1],0)

Sleep (100)

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

Sleep (500)

EndIf

WEnd

It actives the window but the mouse doesn't move to that color area any way to fix this?

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  

×