Sign in to follow this  
Followers 0
shaggy

WinWaitActive and @error

3 posts in this topic

From helpfile:

Function Reference

WinWaitActive ( "title", ["text"], [timeout] )

Return Value

Success: Returns 1.

Failure: Returns 0 if timeout occurred.

but it doesn't work!

I need to trace windows with changing header. For example, Windows Explorer and ACDSee header may be "test" or "C:\test" on difference computers. It depends on program option, that users can change. (Its easy with RegExp, but i didn't found it in AutoIt3). So i start explorer c:\test and use WinWaitActive("C:\test", "", 10) before other actions. BUT, in case of WinWaitActive timeout, i need to check for windows with name "test", that is Explorer, too. And i can't do it, because i always get @error = 0.

You can check it with this script (folder C:\test needs to be created):

Run("explorer.exe /e,c:\test")
WinWaitActive("C:\test", "", 10)
If @error = 0 Then
   MsgBox(0, "1:exit with", @error)
Else
   MsgBox(0, "2:exit with", @error)
EndIf

Run this script, then in WinWaitActive change C:\test on any not existing folder. In both cases you'll see: 1:exit with 0

I only may be wrong, if return value is not placed in @error. But where?

AutoIt v 3.1.1.0 April 7th 2005

System windows xp sp2

Share this post


Link to post
Share on other sites



Opt("WinTitleMatchMode",2)
Run("explorer.exe /e,c:\test")
$ret = WinWaitActive("test", "", 10)
If $ret = 0 Then
   MsgBox(0, "1:exit with", $ret)
Else
   MsgBox(0, "2:exit with", $ret)
EndIf


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Use Gary's code for this need.

It will match a substring within a title as you requested.

As for RegExp, see this post:

http://www.autoitscript.com/forum/index.ph...964entry92964

As for the "bug" - try this code:

Run("explorer.exe /e,c:\test")
$var = WinWaitActive("C:\test", "", 10)
If $var = 1 Then
    MsgBox(0, "Success: Returns 1. ", $var)
Else
    MsgBox(0, "Failure: Returns 0 if timeout occurred. ", $var)
EndIf

later....


[size="1"][font="Arial"].[u].[/u][/font][/size]

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