Sign in to follow this  
Followers 0
amokoura

Message when a window closes

11 posts in this topic

#1 ·  Posted (edited)

Is it possible for a script to receive a message when a certain window closes?

EDIT: This question was stupid. More detailed in this reply

Edited by amokoura

Share this post


Link to post
Share on other sites



Is it possible for a script to receive a message when a certain window closes?

(tried searching..)

WinClose() will attempt to close a window and will return 1 if successful. WinWaitClose() simply waits for a window to close and returns 1 when the window closes. You can also add a timeout to WinWaitClose().

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

You can do something like:

While WinExists("My window title")
    Sleep(250)
WEnd

;window is closed, do something

Share this post


Link to post
Share on other sites

While WinExists("My window title")
    Sleep(250)
WEnd

;window is closed, do somethingoÝ÷ Ù8b²+-ëæ¬jëh×6WinWaitClose("My window title")

;window is closed, do something


Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

This is the same as:

Well actually, there is a slight difference. A While loop with WinExists is not blocking. So you can perform other tasks within the While loop without waiting until that window is closed.

Share this post


Link to post
Share on other sites

Well actually, there is a slight difference. A While loop with WinExists is not blocking. So you can perform other tasks within the While loop without waiting until that window is closed.

True. If the only purpose is to wait until the window closes, then they are identical. We would need to know more about the OP's intentions to recommend the best solution.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

more about the OP's intentions

Thanks for replies.

My intention was the "Window Close Waiter" to run in background of the script. The script is doing it's own thing and immediately after a certain window closes, the script would be notified of it. Maybe some global variable changes or something.

Optionally a function would be called if a window message like WM_CLOSE happened. I haven't used messages before so I don't know if it could work. It would be nice if I could save the adlib for some other use.

Could this work for example:

global $isClosed = false

AdlibEnable ("closeWaiter")

while true
    ; ...
    ; main code here
    ; ...

    if $isClosed then
        ; ...
        ; Window closed, react!
        ; ...
    endif   
wend

func closeWaiter
    if winwaitclose("window title") then
        $isClosed = true
    endif   
endfunc
Edited by amokoura

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

global $isClosed = false

AdlibEnable ("closeWaiter")

while true
    ; ...
    ; main code here
    ; ...

    if $isClosed then
        ; ...
        ; Window closed, react!
        ; ...
    endif   
wend

func closeWaiter
    if winwaitclose("window title") then
        $isClosed = true
    endif   
endfuncoÝ÷ Ù¬¶¬Â)eiÇ(b²!jܨ¹ªÞÁ©íx¢íýYÞyÛhr§âZ)Öj+B|¨º·îËb¢{h!óhµh§¬¶Ëa¢è!jëh×6global $isClosed = false

AdlibEnable ("closeWaiter")

while true
    ; ...
    ; main code here
    ; ...

    if $isClosed then
        ; ...
        ; Window closed, react!
        ; ...
    endif   
wend

func closeWaiter
    If Not WinExists("window title") then
        $isClosed = true
    endif   
endfunc

Edited by Airwolf123

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

Thanks!

Would it be possible to do it without adlib? I'm doing this for a helper function library so it would be nice to spare the adlib for the main scripts.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks!

Would it be possible to do it without adlib? I'm doing this for a helper function library so it would be nice to spare the adlib for the main scripts.

Not without using multiple scripts, or a UDF that I don't know about. Edited by Airwolf123

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt

Share this post


Link to post
Share on other sites

amokoura

Would it be possible to do it without adlib? I'm doing this for a helper function library so it would be nice to spare the adlib for the main scripts.

Use _Timer_SetTimer() function.

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