Jump to content
Sign in to follow this  
DJ_PSYMON

On Exit?

Recommended Posts

DJ_PSYMON

hi, i need to know if theres a script so that when someone clicks the close button on a window that it runs a script (by window i mean the window where the script is but if possible another window too), thanksyou

Share this post


Link to post
Share on other sites
cdkid

$title = "Window Title Here"
Do
Sleep(100)
Until NOT WinExists($title)
;do the rest of the code here

Replace "Window Title here" with the title of the window, and, ";do the rest of the code here", with whatever code to do.

Or to execute code when the script ends use this:

Func OnAutoItExit()
;Do whatever here
EndFunc

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites
SmOke_N

Func OnAutoItExit()
;Do whatever here
EndFunc

~cdkid

Don't forget:
Opt('OnExitFunc', 'OnAutoItExit')
with that one :)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
DJ_PSYMON

thanks guys! :)

Share this post


Link to post
Share on other sites
DJ_PSYMON

where abouts does that last one go?

is it:

Opt('OnExitFunc', 'OnAutoItExit')
Func OnAutoItExit()
;Do whatever here
EndFunc

Share this post


Link to post
Share on other sites
Jos

Don't forget:

Opt('OnExitFunc', 'OnAutoItExit')
with that one :mellow:
No need for this statement as long as you use the default name OnAutoitExit().

:)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SmOke_N

No need for this statement as long as you use the default name OnAutoitExit().

:mellow:

Guess that's my problem, I never use the default... :), but thanks for the clarification, I did not know that.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
DJ_PSYMON
:) none of those codes worked for me? what im trying to do is so that when someone closes the window (one made in autoit, not another one) it does a fade effect, i got the effect working fine, just i need it to fade when you close it, but whats the script?

Share this post


Link to post
Share on other sites
SmOke_N

:) none of those codes worked for me? what im trying to do is so that when someone closes the window (one made in autoit, not another one) it does a fade effect, i got the effect working fine, just i need it to fade when you close it, but whats the script?

That last part you wrote there is my next question... Where's your script? (maybe we can help from there).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
DJ_PSYMON

i cant be bothered to load up the whole script, but all i need is that lil (im guessing its little) bit of code so that when you press the close button (default close button, what you see in the top right corner of your screen) that it runs my fading script so it fades out then closes, thats it, if it cant be done then..... :)

Share this post


Link to post
Share on other sites
SmOke_N

i cant be bothered to load up the whole script

That's about how I feel about giving an answer I guess...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
DJ_PSYMON

oh guys please trust me, the fading script that i will be using is this

Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 250) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 240) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 230) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 220) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 210) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 200) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 190) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 180) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 170) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 160) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 150) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 140) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 130) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 120) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 110) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 100) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 90) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 80) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 70) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 60) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 50) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 40) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 30) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 20) 
Sleep(50)
Opt("WinTitleMatchMode", 2) 
WinSetTrans("FlashEEE's Ghost Windows", "", 10)

im not making something that when you close it it opens back up agian, im not some sort of simple virus coder. :)

Share this post


Link to post
Share on other sites
seandisanti

That's about how I feel about giving an answer I guess...

nice. i actually think that the approach suggested would not achieve the desired result. i think that the gui is destroyed prior to the OnAutoItExit function running. the way that i would suggest to do it, would be to put it into your loop. depending on whether you're using message loop or onevent mode, you've got code to handle the unloading of the window. just have the fade out processed before the exit.

Share this post


Link to post
Share on other sites
seandisanti

im not making something that when you close it it opens back up agian, im not some sort of simple virus coder. :)

oh, you write complex virii? kidding of course. the responses that you got for not posting your code were not because anyone thought the code was malicious, but because it looked like you wanted people to do your work for you. it's always a good idea to show your code even if it's just to show that you've made some effort of your own.

Share this post


Link to post
Share on other sites
SmOke_N

That certainly wasn't the thought I had (virus coder), it was the audasity to say you 'couldn't be bothered' to do something to 'Help You'.

Func OnAutoItExit()
    Opt("WinTitleMatchMode", 2)
    For $i = 250 To 10 Step - 10
        WinSetTrans("FlashEEE's Ghost Windows", "", $i)
        Sleep(50)
    Next
EndFunc

Edit:

After reading cameronsdads suggesting that you are destroying the GUI ahead of time, that makes sense.

#include <GUICONSTANTS.AU3>
$MAINGUI = GUICreate("FlashEEE's Ghost Windows")

GUISetState()

While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_CLOSE
            FADEOUTFUNCTION()
    EndSelect
    Sleep(10)
WEnd    

Func FADEOUTFUNCTION()
    Opt("WinTitleMatchMode", 2)
    For $i = 250 To 10 Step - 10
        WinSetTrans("FlashEEE's Ghost Windows", "", $i)
        Sleep(50)
    Next
    Exit
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
cdkid

For $i = 255 to 0 step -5
WinSetTrans("Window Title", "", $i)
Sleep(10)
Next
WinClose("Window Title")

There.

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites
DJ_PSYMON

for the other post

er............ ye, i thought so............. :mellow:

look, im new to this, i have just spent ages making a l33t program and all i want is a lil effect so how would i go about doing that script then? please all i need is this one script :)

Edited by DJ_PSYMON

Share this post


Link to post
Share on other sites
cdkid

133t

:)

See the last two posts.


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites
DJ_PSYMON

shup! :) but thankyou guys for the scripts :mellow:

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  

×