Jump to content

Doubt in "If"


Recommended Posts

Hi friends,

I wrote a script like

Opt("WinTitleMatchMode",-2)  
If (( ProcessExists("firefox.exe") or ProcessExists("iexplorer.exe") ) And (WinWaitActive("Hotmail") or WinWaitActive("Google") or WinWaitActive("Gmail")) )Then
MsgBox(0,"","Got it")
EndIf
.It works fine for hotmail window alone.When i open some other window like Gmail(comes second or so) it doesn't produce the output.Please help.Only works if first window is active.

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Link to comment
Share on other sites

Because it uses WinWaitActive, it will wait until the window "Hotmail" comes up, before it tries to wait for the "Google" and "Gmail" windows. (The expression is evaluated left to right)

Use WinExists instead of WinWaitActive in a loop.

Yeah i know that but problem is when hotmail is active it doesn't show the output.Can you please try the script :D

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Link to comment
Share on other sites

WinWaitActive function waits for the window to become active. AutoIt only has one thread. So the interpreter will do this:

If (( ProcessExists("firefox.exe") ; < == Check if firefox exists, return 1 or 0

) or ProcessExists("iexplorer.exe") ; < == Check if iexplore.exe exists, return 1 or 0

And (WinWaitActive("Hotmail") ; < == WAIT FOR HOTMAIL TO EXIST AND DO NOTHING ELSE UNTIL IT ACTUALLY EXISTS

or WinWaitActive("Google") ; < == WAIT FOR GOOGLE TO EXIST AND DO NOTHING ELSE UNTIL IT ACTUALLY EXISTS

or WinWaitActive("Gmail")) )Then ; < == WAIT FOR GMAIL TO EXIST AND DO NOTHING ELSE UNTIL IT ACTUALLY EXISTS

This is how you solve it:

Use WinExists instead of WinWaitActive in a loop.

Opt("WinTitleMatchMode",2)
While 1  
   If (( ProcessExists("firefox.exe") or ProcessExists("iexplorer.exe") ) And (WinExists("Hotmail") or WinExists("Google") or WinExists("Gmail")) )Then
      MsgBox(0,"","Got it")
      ExitLoop
   EndIf
Wend
Link to comment
Share on other sites

Make it:

Opt("WinTitleMatchMode",2)
While 1  
   If (( ProcessExists("firefox.exe") or ProcessExists("iexplore.exe") ) And (WinExists("Hotmail") or WinExists("Google") or WinExists("Gmail")) )Then
      MsgBox(0,"","Got it")
      ExitLoop
   EndIf
Wend
[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

WinWaitActive function waits for the window to become active. AutoIt only has one thread. So the interpreter will do this:

If (( ProcessExists("firefox.exe") ; < == Check if firefox exists, return 1 or 0

) or ProcessExists("iexplorer.exe") ; < == Check if iexplore.exe exists, return 1 or 0

And (WinWaitActive("Hotmail") ; < == WAIT FOR HOTMAIL TO EXIST AND DO NOTHING ELSE UNTIL IT ACTUALLY EXISTS

or WinWaitActive("Google") ; < == WAIT FOR GOOGLE TO EXIST AND DO NOTHING ELSE UNTIL IT ACTUALLY EXISTS

or WinWaitActive("Gmail")) )Then ; < == WAIT FOR GMAIL TO EXIST AND DO NOTHING ELSE UNTIL IT ACTUALLY EXISTS

This is how you solve it:

Use WinExists instead of WinWaitActive in a loop.

Opt("WinTitleMatchMode",2)
While 1  
   If (( ProcessExists("firefox.exe") or ProcessExists("iexplorer.exe") ) And (WinExists("Hotmail") or WinExists("Google") or WinExists("Gmail")) )Then
      MsgBox(0,"","Got it")
      ExitLoop
   EndIf
Wend

Tanx man

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Link to comment
Share on other sites

Make it:

Opt("WinTitleMatchMode",2)
While 1  
   If (( ProcessExists("firefox.exe") or ProcessExists("iexplore.exe") ) And (WinExists("Hotmail") or WinExists("Google") or WinExists("Gmail")) )Then
      MsgBox(0,"","Got it")
      ExitLoop
   EndIf
Wend

Tanx dude

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

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...