Jump to content

problem wit WinActivate()?


Recommended Posts

hi and thanks ahead of time for any help. the problem i am having is i have to windows. "window1" is where i do all the mouseclicks and so forth and the only purpose of "window2" is to check for a certain color. if the color in that window is not the correct color, then it sleeps a little and the checks again. the problem is both windows are active at the same time. instead of one being in the background, neither is. and once the color is correct, it doesnt do anything. any ideas whats wrong? below is the code. thanks again!!

While WinExists($window1)

AutoItSetOption("MouseCoordMode", 0);

Opt("PixelCoordMode", 0);

WinActivate ($window2);

While PixelGetColor(44,65) <> 16777215

Sleep(2000);

WEnd

WinActivate($window1);

.

.

.

Link to comment
Share on other sites

  • Moderators

First off what are the values of $window1 & $window2? I added some troubleshooting lines to your code, try it and see what is written to the console in SciTE.

Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)

$window1 = "Your value here"
$window2 = "Your value here"

While WinExists($window1)
    ConsoleWrite("window1 exists, activating window2." & @CR)
    WinActivate($window2)
    If WinActive($window2) Then
        ConsoleWrite("window2 activated, waiting for color." & @CR)
        While PixelGetColor(44, 65) <> 16777215
            Sleep(2000)
        WEnd
        ConsoleWrite("color found, activating window1." & @CR)
        WinActivate($window1)
    Else
        ConsoleWrite("window2 NOT activated" & @CR)
    EndIf
WEnd
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...