Sign in to follow this  
Followers 0
Medic873

win window if statement

9 posts in this topic

i am looking for a if statement on the WinWaitActive statement

so i can do somthing like this

if WinWaitActive("google"){

send ("hello");

send ("{enter}");

and then

if WinWaitActive("windows security"){

send ("{tab}");

send ("{enter}");

if you can help me with this that would be great

Share this post


Link to post
Share on other sites



winwaitactive is to pause the script until the specified window is the active window on your desktop.

I think you are looking for

if winactive("google") then

send("hello")

ect.

endif

to use winwaitactive would be:

winwaitactive("windows security")

send("{tab}")

ect.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

You want to do something while you're waiting for the window to come up? That's basically what that's saying. Do you just want it to wait for the window to be active before continuing? If so, try this:

WinActivate("Google")
WinWaitActive("Google")
Send("Hello{ENTER}")

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

You want to do something while you're waiting for the window to come up? That's basically what that's saying. Do you just want it to wait for the window to be active before continuing? If so, try this:

WinActivate("Google")
WinWaitActive("Google")
Send("Hello{ENTER}")

okay all said was a great help but this type of thing still isnt working

if winactive("google") then
    winwaitactive ("google")
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{tab}');
send ('{enter}');
sleep (200);
endif
if winactive ("Security Information") then
    winwaitactive ("Security Information")
sleep (200);
send ('{enter}');
endif

I belive im using the end if function wrong cause i want it to keep reading down the script so is there somthing that isnt end but somthing that will end the if statement but keep reading or maybe im using this wrong..

Thanks for your help by the way.

Share this post


Link to post
Share on other sites

if you have the if winactive you do not need the winwaitactive because the window will be active


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

I'm not sure I quite understand what you're trying to accomplish but I think you may need to loop your winactive checks.

I've added a while 1... which is going to loop your active window check perpetually... you will need to add a way to break the while loop later I'm guessing.

I've also changed you tab lines to send('{tab 9}') which will tab 9 times then press enter... same functionality but cleaner looking.

Hope this helps.

While 1

if winactive("google") then
    winwaitactive ("google")
send ('{tab 9}{enter}')
sleep (200)
endif
if winactive ("Security Information") then
    winwaitactive ("Security Information")
sleep (200)
send ('{enter}')
endif

wend

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

if you have the if winactive you do not need the winwaitactive because the window will be active

He's right, if you're doing this with the window on top, you don't really need WinWaitActive().. if you want to wait for the window to finish loading the page... You're going to have to use IE if you aren't already. I think you can use StatusBarGetText() to rea if the page is 'Done.' loading or not. Another thing you could look at (fairly advanced) if the _IE.au3 UDF. it's sorta confusing to use, but it automates IE very well.

Anywho, StatusBarGetText() to detect when the page is done loading:

Opt("WinTitleMatchMode", 2)

While 1
    WinWaitActive("google")
    While 1
        If StatusbarGetText('Internet Explorer') = 'Done' Then ExitLoop
        Sleep(50)
    WEnd
    Send('{tab 9}{enter}')
    Sleep(200)
    WinWaitActive("Security Information")
    While 1
        If StatusbarGetText('Internet Explorer') = 'Done' Then ExitLoop
        Sleep(50)
    WEnd
    Sleep(200)
    Send('{enter}')
WEnd

If StatusbarGetText() doesn't or isn't = 'Done' you could try StringInStr(StatusbarGetText('Internet Explorer'), "Done"))

Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

Suppose that you've opened IE

if WinActive("Google - Windows Internet Explorer") Then
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{ENTER}")
sleep(200)
else
if WinActive ("Security Information - Windows Internet Explorer") Then    
WinWaitActive("Security Information - Windows Internet Explorer")
sleep (200)
send ("{ENTER}")
Endif

Be sure to place the whole TITLE


First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack. -George Carrette[sub]GD Keylogger Creator (never released)[/sub][sub]Garena Autojoin v3.0[/sub]

Share this post


Link to post
Share on other sites

In my example it sets the win title mode so that it just matches anything in the title. And if the window is selected and in the foreground, it does much matter. He could just leave it blank.


RAWR! I'm hungry :( Feed the panda squirrle

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