notbillcosby Posted March 4, 2005 Posted March 4, 2005 I'm wondering if there's a way to make a script do something right before it closes... or pauses even. I've made a script that hides a certain window, and I'd like it to show the window again when the script is closed or paused. Is there a way to do it?
MHz Posted March 4, 2005 Posted March 4, 2005 This will be the function called when exit of the script, is performed. Just replace 'FuncName' with the name of the function that you choose for the task. Opt('OnExitFunc', 'FuncName') Func FuncName() ; Last lines of code to run. EndFunc
Insolence Posted March 4, 2005 Posted March 4, 2005 I had no idea that existed! Thanks MHz "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
notbillcosby Posted March 7, 2005 Author Posted March 7, 2005 This will be the function called when exit of the script, is performed. Just replace 'FuncName' with the name of the function that you choose for the task.Opt('OnExitFunc', 'FuncName') Func FuncName() ; Last lines of code to run. EndFunc <{POST_SNAPBACK}>I'm probably being both ignorant and stupid, but i'm really having a hard time understaning how this works (even after trying to read up on OnExitFunc as well as Func itself...) well enough to make my damn script work.I'm just trying to get a damn internet explorer window, that is hidden at the beginning of the script, to unhide itself when you close the script. Upon exit, i just need it to undo this:While 1 If WinActive("The next page will") Then WinSetState ("The next page will", "", @SW_HIDE) ;I know I'll need WEnd at the end.Little help? Thanks...
MHz Posted March 7, 2005 Posted March 7, 2005 Opt('OnExitFunc', 'FuncName'); Place at top of script. Func FuncName() If WinExists("The next page will") Then WinSetState ("The next page will", "", @SW_SHOW) EndFunc Give this a try. It should work, if the title is correct?
notbillcosby Posted March 7, 2005 Author Posted March 7, 2005 Opt('OnExitFunc', 'FuncName'); Place at top of script. Func FuncName() If WinExists("The next page will") Then WinSetState ("The next page will", "", @SW_SHOW) EndFuncGive this a try. It should work, if the title is correct?<{POST_SNAPBACK}>I think that's pretty much what I was doing... I get the same error message when i copy and paste your code as i did when I was doing it myself, so maybe it isn't just me... Here's what I have for code:While 1 = 1 Opt('OnExitFunc', 'FuncName'); Place at top of script. If WinActive("The next page will") Then WinSetState ("The next page will", "", @SW_HIDE) Func FuncName() If WinExists("The next page will") Then WinSetState ("The next page will", "", @SW_SHOW) EndFunc WEndThe error message that shows reads:Line 7 (File "C:\ big long path\autohider.AU3"):Func FuncName()Error: "While" statement has no matching "Wend" statement.I don't know why, or where, it wants another Wend statement...
MHz Posted March 7, 2005 Posted March 7, 2005 I cannot think of any reason, why you would put, any of that code within a while loop? Especially a User Defined Function.
therks Posted March 7, 2005 Posted March 7, 2005 Your stuff is all out of order. Try this: Opt('OnExitFunc', 'FuncName'); Place at top of script. While 1 If WinActive("The next page will") Then WinSetState ("The next page will", "", @SW_HIDE) WEnd Func FuncName() If WinExists("The next page will") Then WinSetState ("The next page will", "", @SW_SHOW) EndFunc MHz, the reason is that he wants his script to constantly keep closing windows with that name. My AutoIt Stuff | My Github
notbillcosby Posted March 7, 2005 Author Posted March 7, 2005 Your stuff is all out of order. Try this:Opt('OnExitFunc', 'FuncName'); Place at top of script. While 1 If WinActive("The next page will") Then WinSetState ("The next page will", "", @SW_HIDE) WEnd Func FuncName() If WinExists("The next page will") Then WinSetState ("The next page will", "", @SW_SHOW) EndFuncMHz, the reason is that he wants his script to constantly keep closing windows with that name.<{POST_SNAPBACK}>That did the trick, thanks!And yes... That's why i had the while loop.
djek Posted March 7, 2005 Posted March 7, 2005 I'm wondering if there's a way to make a script do something right before it closes... or pauses even. I've made a script that hides a certain window, and I'd like it to show the window again when the script is closed or paused. Is there a way to do it?<{POST_SNAPBACK}>Func OnAutoItExit() ;say goodbyeEndFuncno need to use Opt('OnExitFunc', 'FuncName')Use the helpfile Luke!
zcoacoaz Posted March 7, 2005 Posted March 7, 2005 yes, but people may prefer to use Opt('OnExitFunc','FuncName') ~~~~~~~~~~~~~~~~~~~~ [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now