Jump to content
Sign in to follow this  
Queener

open windows

Recommended Posts

Queener

I notice that you can check and see if window exist, but how do you put a permanent check to see if the window close? If it close then re-open. Say for example, I use teamviewer and once in awhile it closes the connection on me if I'm idle for certain amount of time. I want it to automatic open a new session with the id and pw I provided if teamviewer close.


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites
FireFox

Hi,

If the program re-creates a window each time, then you only need to check for its handle.

Local $hWnd = WinGetHandle("My Wnd")

While WinExists($hWnd) = 1
Sleep(10)
WEnd

ConsoleWrite("Window closed." & @CrLf)
If NOT, then you will need to check for the window's state (using WinGetState).

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
czardas

Based on Firefox's example above, This script keeps opening notepad every time you close it, until you hit the escape key. It might help you get started.

;

HotKeySet("{ESC}", "_Quit")

Local $hWnd

While 1
    Run ("Notepad.exe")
    WinWait("Untitled - Notepad")
    $hWnd = WinGetHandle("Untitled - Notepad")

    While WinExists($hWnd)
        Sleep(10)
    WEnd
    ;ConsoleWrite("Window closed." & @CrLf)
WEnd

Func _Quit()
    Exit
EndFunc
Edited by czardas

Share this post


Link to post
Share on other sites
Queener

thanks firefox and czardas. Will give czardas example a try. Looks very like a very good example I can start off.


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites
Queener

czardas - tested your code, but it doesn't open notepad when it's closed. I removed the ";" before consolewrite code,


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites
FireFox

Basic example :

HotKeySet("{ESC}", "_Quit")
 
While 1
    Run("Notepad.exe")
    WinWait("[CLASS:Notepad]")
    WinWaitClose("[CLASS:Notepad]")
WEnd
 
Func _Quit()
    Exit
EndFunc

 

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
czardas

czardas - tested your code, but it doesn't open notepad when it's closed. I removed the ";" before consolewrite code,

 

Sorry. It worked on my machine. It was a quick example to which I didn't give much thought. Firefox's example is much better anyway. The method I used is taken from the helpfile tutorial, so I am now a little confused why it worked on my computer and not on yours. The helpfile tutorial gives this code:

;

Run("notepad.exe")
WinWaitActive("Untitled - Notepad") ; This is the syntax which fooled me
Send("This is some text.")

;

Please could someone confirm that my >earlier example is broken, because it works perfectly for me.

Edit


I think this has to do with language settings - and the helpfile may need amending.

Edited by czardas

Share this post


Link to post
Share on other sites
Queener

can one of you guys compile that code to executable so I can try it out? The main problem atm is I switched from notepad to notepad++. But that shouldn't affect.

nevermind; it works... Thanks guys

Changed class to notepad++ and it worked.

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

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  

×