Jump to content

open windows


Recommended Posts

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.")
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.")
Link to comment
Share on other sites

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.")
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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