Sign in to follow this  
Followers 0
Wolfgang2

WinWaitAtive swichts the script into the pause mode ...

7 posts in this topic

Hello

First, I’ve download AutoIt Friday last week and used it my first time. Compared to the WSH it is a very powerful tool and therefore thanks for all participants. My favorite command is WinWaitActive and this was the reason to leave WSH and to look for something else.

Actually I’ve written a script at my client pc, compiled it and moved it onto a server. To this server I’ve opened a remote connection, started the script and changed back to my computer. The idea is to run the script on the other pc and some hours later to go back to the remote pc to investigate the results.

My problems are joined to the WinWaitActive commands in the script. If I start the script, and switch the remote connection to my computer directly, the operation system on the server will switch the script evaluation into a “pause mode” at the next WinWaitActive-command. If the connection is not terminated, or better if I stay on sitting “in front of the server pc”, the program continues.

Actually I do not know how to handle such a problem. First ideas are:

  • Is there any command or parameter in AutoID to change this behavior?
  • Shall I start the script.exe program using a special command and a special parameter?
  • Shall I change any operation system parameter?

So, of course, it is possible that my question is out of placed. Sorry, but I really do not know.

Thanks for any help.

Best regards

Wolfgang

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

I don't understand your problem, do you want to say that when you use the function WinWaitActive, the script pauses until the wnd is active?

If so you have two options :

;1.deal with the timeout :
_WaitWnd("toto")

While 1
    Sleep(1000)
WEnd

Func _WaitWnd($vWnd, $iTimeOut = 1)
    WinWaitActive($vWnd, "", $iTimeOut)

    If Not WinActive($vWnd) Then
        ConsoleWrite("wnd not active" & @CRLF)
        _WaitWnd($vWnd, $iTimeOut)
    EndIf
EndFunc   ;==>_WaitWnd

;2.check with WinActive
_WaitWnd("toto")

While 1
    Sleep(1000)
WEnd

Func _WaitWnd($vWnd)
    If Not WinActive($vWnd) Then
        ConsoleWrite("wnd not active" & @CRLF)

        Sleep(1000)
        _WaitWnd($vWnd)
    EndIf
EndFunc   ;==>_WaitWnd

Edit : You can also check it by the main loop.

Hope that helps.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Hello Firefox

First - Sorry I cannot use the Editor because java script does not work completely. There are some restrictions on my computer.

Let us see the AutoIt-Lines:

---

$hndlWinMain = WinWaitActive("[REGEXPTITLE:something:.*]")

ConsoleWrite("Hello")

---

In this case the routine will never leave the WinWaitActive routine. The window appears but nothing is done to the console. It seems that the script does not get anymore cpu time.

Best regards

Wolfgang

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

In this case the routine will never leave the WinWaitActive routine. The window appears but nothing is done to the console.

Firstly if you are not using SciTE, how can you see if something is appearing in the console? Try MsgBox instead.

If the routine is blocked on your WinWaitActive that's because it does not detect your window, just put the title or the class instead of the regexp.

WinWaitActive("title1")
WinWaitActive("[CLASS:class1]")
WinWaitActive("[TITLE:title1;CLASS:class1]")

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

> Firstly if you are not using SciTE, how can you see if something is appearing in the console?

My Notepad is my console, I wanted to reduce the size of my posting - sorry.

---

Run("notepad.exe")

$hndlWinNotepad = WinWaitActive("Untitled - Notepad")

WinActivate("Untitled - Notepad")

Send("Start")

Run("""C:Program Files...myProgram.exe"" -user ""***"" -password ""***")

$hndlWinMain = WinWaitActive("[REGEXPTITLE:Some Text:.*]")

WinActivate("Untitled - Notepad")

Send("Started")

if ($hndlWinMain <> 0) Then

Send("InLoop")

$oDoors = ObjCreate("MyProgram.Application")

$oDoors.runFile("C:app...MyScript.dxl")

$oDoors.runStr("exit_")

EndIf

---

In normal case: Connection to the server is not minimized - all strings "Start", "Started" and "InLoop" are written to the editor.

If I minimize the screen, only "Start" will appear.

The program works well, and WinWaitActive finds the correct window, that is really not a problem. The problem is: WinWaitActive sets the program into the sleep mode.

Share this post


Link to post
Share on other sites

Please use autoit tags to post your code.

I don't understand why you don't want the script to be paused.

1. The script must be paused to wait for the window.

2. In case it's not paused, what will you script do ?, because it needs the window to be active to continue.

3. If you do as I showed you before, you will need to check by a boolean var (for example) if the window has been activated and if so, stop what you are doing and restart at the point where you wanted the window to be active.

In conclusion it's not possible.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

If you're running the script, while not connected to the server, the windows will never be active which is probably why it's not getting past the WinWaitActive part of the script. If you're still connected, but the RDP screen isn't the active window you might have the same problem.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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