Jump to content



Photo

OnAutoItExit Handler


  • Please log in to reply
5 replies to this topic

#1 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 30 December 2008 - 08:56 PM

Hi,

This Include-UDF idea was inspired from Feature Request on Bug Tracking System about a better OnAutoItStart/OnAutoItExit handling. So here it is:

Example:
AutoIt         
#include <OnAutoItExit_Handler.au3> _OnAutoItExit_AddFunc("MyTestFunc", "Some data") _OnAutoItExit_AddFunc("MyTestFunc2", "Some other data") Sleep(1000) ;_OnAutoItExit_RemoveFunc("MyTestFunc") Func OnAutoItExit()     ;If we have our own OnAutoItExit function, OnAutoItExit_Handler will add ("pick up") this function to the handler :)     ;It's helpfull when this function is defined by some UDF that we using in our scripts.     MsgBox(64, "Exit Results 1", "Exit Message from OnAutoItExit()") EndFunc Func MyTestFunc($sParam)     MsgBox(64, "Exit Results 2", 'Exit Message from MyTestFunc("' & $sParam & '")') EndFunc Func MyTestFunc2($sParam)     MsgBox(64, "Exit Results 3", 'Exit Message from MyTestFunc("' & $sParam & '")') EndFunc



Notes:
* This include is usefull for the UDF writters, to let them set OnAutoItExit() function to free some resources, perhaps in the future i should add an option to check constantly the Opt("OnExitFunc") and add to the list if new function was set.
* If you are including some UDF that uses OnAutoItExit function, then «OnAutoItExit Handler» UDF will "catch" that function and call it when script is exits.
* OnAutoItStart() function can not be handled as OnAutoItExit() function (due to the lack of ability of changing it's name, and also because when it's called there is no variables declared and we can not add other function calls by func), but we still can add a multiple functions from inside OnAutoItStart function, example:

Func OnAutoItStart()     Local $aOnAutoItStart_Funcs = StringSplit("OnAutoItStart_1|OnAutoItStart_2", "|");Add here as many as you need         For $i = 1 To $aOnAutoItStart_Funcs[0]         If $aOnAutoItStart_Funcs[$i] = "OnAutoItStart" Then ContinueLoop;Prevent recursion error         Call($aOnAutoItStart_Funcs[$i])     Next EndFunc


But it's not so practical (not usefull), since we can't use it to overcome other UDF's defined function (OnAutoItStart()).

========================================================

Download: Attached File  OnAutoItExit_Handler.zip   1.1K   319 downloads
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team








#2 FireFox

FireFox

    Liar using Chrome :>

  • Active Members
  • PipPipPipPipPipPip
  • 3,176 posts

Posted 30 December 2008 - 09:45 PM

@MrCreator
:o dont know why nobody reply to your udf... (same thing for my AVICapture)

But i think its great idea mate :D :)

Cheers, FireFox.
OS : Win XP SP3 / Win 7 SP1 / Win 8 | Autoit version: latest stable / beta

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 | What you've done today | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : IP 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

Updated 22 April, 2013 - If you find dead links please send me a PM, do not post in the topics !

#3 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 30 December 2008 - 11:56 PM

Hi,

This Include-UDF idea was inspired from Feature Request on Bug Tracking System about a better OnAutoItStart/OnAutoItExit handling. So here it is:

Example:

AutoIt         
#include <OnAutoItExit_Handler.au3> _OnAutoItExit_AddFunc("MyTestFunc", "Some data") _OnAutoItExit_AddFunc("MyTestFunc2", "Some other data") Sleep(1000) ;_OnAutoItExit_RemoveFunc("MyTestFunc") Func OnAutoItExit()     ;If we have our own OnAutoItExit function, OnAutoItExit_Handler will add ("pick up") this function to the handler :)     ;It's helpfull when this function is defined by some UDF that we using in our scripts.     MsgBox(64, "Exit Results 1", "Exit Message from OnAutoItExit()") EndFunc Func MyTestFunc($sParam)     MsgBox(64, "Exit Results 2", 'Exit Message from MyTestFunc("' & $sParam & '")') EndFunc Func MyTestFunc2($sParam)     MsgBox(64, "Exit Results 3", 'Exit Message from MyTestFunc("' & $sParam & '")') EndFunc


Notes:
* This include is usefull for the UDF writters, to let them set OnAutoItExit() function to free some resources, perhaps in the future i should add an option to check constantly the Opt("OnExitFunc") and add to the list if new function was set.
* If you are including some UDF that uses OnAutoItExit function, then «OnAutoItExit Handler» UDF will "catch" that function and call it when script is exits.
* OnAutoItStart() function can not be handled as OnAutoItExit() function (due to the lack of ability of changing it's name, and also because when it's called there is no variables declared and we can not add other function calls by func), but we still can add a multiple functions from inside OnAutoItStart function, example:

Func OnAutoItStart()     Local $aOnAutoItStart_Funcs = StringSplit("OnAutoItStart_1|OnAutoItStart_2", "|");Add here as many as you need         For $i = 1 To $aOnAutoItStart_Funcs[0]         If $aOnAutoItStart_Funcs[$i] = "OnAutoItStart" Then ContinueLoop;Prevent recursion error         Call($aOnAutoItStart_Funcs[$i])     Next EndFunc

But it's not so practical (not usefull), since we can't use it to overcome other UDF's defined function (OnAutoItStart()).

========================================================

Download: Attached File  OnAutoItExit_Handler.zip   1.1K   319 downloads

Thanks MrCreatoR, a neat solution to an old irritation. If the OnAutoItExit handling gets improved then we will be able to cope with more than 1 udf which has an OnExit function, meanwhile this is good and covers nearly all requirements IMO.
Now I would be interestd to see you do the same for udfs which have, or should have, things like WM_COMMAND functions :)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#4 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 31 December 2008 - 12:05 AM

Now I would be interestd to see you do the same for udfs which have, or should have, things like WM_COMMAND functions

I am not sure i follow your thought here :) ...
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#5 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 31 December 2008 - 12:25 AM

I am not sure i follow your thought here :) ...

It could be because my thoughts are wrong. Some udfs register their own functions for WM_COMMAND. _EIPListView.au3 is one example. If you use this udf and want to register WM_COMMAND for some reason then you have to modify the udf. It would be better if you could register events for controls by having a function which added cases to a global WM_COMMAND handler. Or have I misunderstood something?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#6 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 31 December 2008 - 09:46 AM

It could be because my thoughts are wrong. Some udfs register their own functions for WM_COMMAND. _EIPListView.au3 is one example. If you use this udf and want to register WM_COMMAND for some reason then you have to modify the udf. It would be better if you could register events for controls by having a function which added cases to a global WM_COMMAND handler. Or have I misunderstood something?

I don't think we can do it. There will be a problem because we can't (?) check the current registered WM_* function and set another one to call the old one. If GUIRegisterMsg() was returning the current function name that is registered to specific message, then it would be possible.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users