Sign in to follow this  
Followers 0
xuzo

If window is there do X if window is not open do Y, need help on if/else

5 posts in this topic

#1 ·  Posted (edited)

My post title is not quite right let me reformulate:

  • If window is there:
  • show a pop to confirm it's there
  • If window is not there:
  • show a pop to say it's not there

I'm missing some very basic syntax to get this done. I'm missing something in the else, not sure what!

Run("notepad.exe")
Sleep(1000)
If WinExists("[CLASS:Notepad]") Then
MsgBox(0, "", "Window exists")
EndIf
Sleep(1000)
WinClose("[CLASS:Notepad]", "")
Send("!n")
;now the same steps but without Notepad being open
Sleep(1000)
If WinExists("[CLASS:Notepad]") Then
MsgBox(0, "", "Window exists")
;ElseIf windows does not exit Then
MsgBox(0, "", "Window Doesn't exist")
EndIf

Thanks,

Edited by xuzo

Share this post


Link to post
Share on other sites



Try this:

Run("notepad.exe")
Sleep(1000)
If WinExists("[CLASS:Notepad]") Then
MsgBox(0, "", "Window exists")
EndIf
Sleep(1000)
WinClose("[CLASS:Notepad]", "")
Send("!n")
;now the same steps but without Notepad being open
Sleep(1000)
If WinExists("[CLASS:Notepad]") Then
MsgBox(0, "", "Window exists")
Else
MsgBox(0, "", "Window Doesn't exist")
EndIf

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

This is working:

Run("notepad.exe")
Sleep(1000)
If WinExists("[CLASS:Notepad]") Then
MsgBox(0, "", "Window exists")
Else
MsgBox(0, "", "Window Doesn't exist")
EndIf

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Hi MKISH,

This works 100%, thank you so much!

However, I'm trying to control the script so the pop ups don't come up to quickly, seems like they sometimes make the sound before the pop up shows... up...

It there a way to pace things a little better without sleeps of X millisecondes in between steps?

:ILA2:

Share this post


Link to post
Share on other sites

[solved]

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