UEZ Posted November 10, 2013 Share Posted November 10, 2013 (edited) @timmy2: in your code from post#1 you forgot to add AutoItSetOption("GUIOnEventMode", 1) because your code runs in GUIOnEventMode! Just add the line to the top of your code just after the includes. Best, add both lines: AutoItSetOption("GUIOnEventMode", 1) OnAutoItExitRegister("_VisualizerExit") The disadvantage of the idea in post#12 is that you can also exit the visualization by pressing ESC key. Br, UEZ Edited November 10, 2013 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
guinness Posted November 10, 2013 Share Posted November 10, 2013 _WinAPI_EnumProcessWindows() timmy2 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
timmy2 Posted November 11, 2013 Author Share Posted November 11, 2013 _WinAPI_EnumProcessWindows() Thank you for the tip, Guinness. That UDF appears to be a goldmine. Link to comment Share on other sites More sharing options...
timmy2 Posted November 11, 2013 Author Share Posted November 11, 2013 @timmy2: in your code from post#1 you forgot to add AutoItSetOption("GUIOnEventMode", 1) because your code runs in GUIOnEventMode! Just add the line to the top of your code just after the includes. Best, add both lines: AutoItSetOption("GUIOnEventMode", 1) OnAutoItExitRegister("_VisualizerExit") The disadvantage of the idea in post#12 is that you can also exit the visualization by pressing ESC key. Br, UEZ Thank you for your continued help, UEZ. Any references to GuiOnEventMode were left over from testing the FFT visualizer manually. I've removed all references to it. One thing you did not verify and I'd appreciate it if you would is: should I insert your recommended "If GUIGetMsg() = -3" in the FFT Visualizer While/WEnd loop like this? While _BASS_ChannelIsActive($hStream) If GUIGetMsg() = -3 Then _VisualizerExit() _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBmpBk, 0, 0) _BASS_EXT_ChannelGetFFT($hStream, $aFFT, 6) If Not @error Then DllCall($ghGDIPDll, "int", "GdipFillPolygonI", "handle", $hGfxBuffer, "handle", $hBrushFFT, "ptr", $aFFT[0], "int", $aFFT[1], "int", "FillModeAlternate") _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0) Sleep(30) WEnd Link to comment Share on other sites More sharing options...
timmy2 Posted November 11, 2013 Author Share Posted November 11, 2013 (edited) What you can do is to start the script from the main script and close it with WinClose() when ever you want. Prerequisite is that the child process is closeable with WinClose -> GUIGetMsg() = $GUI_EVENT_CLOSE. Further on child script you have to use OnAutoItExitRegister() to cleanup resouces on exit. Example: Main.au3 #include <WinAPIProc.au3> #include <Array.au3> $iPid = Run("Child.exe") Local $aData = _WinAPI_EnumProcessWindows($iPid, 0) ConsoleWrite($aData[1][0] & @LF) Sleep(2000) WinClose($aData[1][0]) Child.au3#NoTrayIcon OnAutoItExitRegister("_Exit") $hGUI = GUICreate("Test") GUISetState() Do If GUIGetMsg() = -3 Then _Exit() Until Not Sleep(1000) Func _Exit() MsgBox(0, "Information", "Exit", 10) Exit EndFunc Compile Child.au3 and start Main.au3. Both should be in same dir. _WinAPI_EnumProcessWindows requires beta version. Br, UEZ UEZ, I was curious to test your basic examples of using WinClose. I modified the Main script to use the WinAPIEx UDF because I'm not using the Beta AutoIt. When I run the Main script there's a long delay between the Main program's WinClose and the Child program actually closing -- at least on my PC. Also, the MsgBox that indicates the Child program is exiting needs to be clicked twice to close. Can you explain these behaviors to me, please? "MAIN" script #Include <WinAPIEx.au3> #include <Array.au3> $iPid = Run("Child.exe") Local $aData = _WinAPI_EnumProcessWindows($iPid, 0) ConsoleWrite($aData[1][0] & @LF) ; show the handle, but how do I know if it's correct? sleep(1000) ;leave Child window alone for 2 seconds before winmove WinMove($aData[1][0],"", 20,20) ;visible test to see if handle is valid Sleep(1000) ; $result = WinClose($aData[1][0]) ConsoleWrite ("Result of WinClose = " & $result & @LF) Exit "CHILD" script #NoTrayIcon OnAutoItExitRegister("_Exit") $hGUI = GUICreate("Child") GUISetState() Do If GUIGetMsg() = -3 Then ToolTip("Trigger received !") ;so I can see when Child.exe is told to close sleep (2000) _Exit() EndIf Until Not Sleep(1000) Func _Exit() MsgBox(0, "Information", "Exit") Exit EndFunc I apologize if this is a dumb question. Edited November 11, 2013 by timmy2 Link to comment Share on other sites More sharing options...
UEZ Posted November 11, 2013 Share Posted November 11, 2013 The reason why it has to closed twice is that the _Exit() function is called twice. One within the If Then check and the second caused by OnAutoItExitRegister().In this case you can disable OnAutoItExitRegister().Regading the delay I cannot say anything.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
timmy2 Posted November 11, 2013 Author Share Posted November 11, 2013 The reason why it has to closed twice is that the _Exit() function is called twice. One within the If Then check and the second caused by OnAutoItExitRegister(). In this case you can disable OnAutoItExitRegister(). Regading the delay I cannot say anything. Br, UEZ Ah, then perhaps I'm back at the beginning: Would OnAutoItExitRegister() be effective if the Main program had gotten the PID when Running Child.exe and then issued a ProcessClose(Child's PID)? The delay caught my attention because it made me wonder if your suggested approach (WinClose in combination with GUIGetMsg) is a reliable air-tight solution (not to dis it, but all things must be tested, especially by toddlers and noobs). Link to comment Share on other sites More sharing options...
UEZ Posted November 11, 2013 Share Posted November 11, 2013 ProcessClose() is the hard way to close the script and OnAutoItExitRegister will not work in this.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
guinness Posted November 11, 2013 Share Posted November 11, 2013 A worth while read would be >> http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
timmy2 Posted November 11, 2013 Author Share Posted November 11, 2013 A worth while read would be >> http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx Thank you, Guinness. I'll add it to my reading list. Link to comment Share on other sites More sharing options...
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