Ontosy Posted June 3, 2012 Share Posted June 3, 2012 when i use processclose with Foobar2000 i have a error on restart in the configuration file. Do it is possibile to send a generic message to a application to exit instead to brute force close? Link to comment Share on other sites More sharing options...
Inverted Posted June 3, 2012 Share Posted June 3, 2012 WinClose("foobar") Link to comment Share on other sites More sharing options...
Ontosy Posted June 3, 2012 Author Share Posted June 3, 2012 WinClose("foobar") It would be nice if you could also use it with the file name. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 3, 2012 Moderators Share Posted June 3, 2012 (edited) Ontosy,guinness has posted something which gets the GUI handle from the process name - have a search and see if you can find it. M23Edit:I found this from SmOke_N in the Snippets Wiki: expandcollapse popup#include <array.au3> Local $a1, $a2, $a3, $a4 $a1 = _WinGetHandleByPID(232) $a2 = _WinGetHandleByPID("scite.exe", -1) $a3 = _WinGetHandleByPID("scite.exe", 0) $a4 = _WinGetHandleByPID("scite.exe", 1) _ArrayDisplay($a1, "1") _ArrayDisplay($a2, "2") _ArrayDisplay($a3, "3") _ArrayDisplay($a4, "4") ;$nVisible = -1 "All (Visble or not)", $nVisible = 0 "Not Visible Only", $nVisible = 1 "Visible Only" Func _WinGetHandleByPID($vProc, $nVisible = 1) $vProc = ProcessExists($vProc); If Not $vProc Then Return SetError(1, 0, 0) Local $aWL = WinList() Local $aTemp[UBound($aWL)][2], $nAdd = 0 For $iCC = 1 To $aWL[0][0] If $nVisible = -1 And WinGetProcess($aWL[$iCC][1]) = $vProc Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible = 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And _ BitAND(WinGetState($aWL[$iCC][1]), 2) = 0 Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible > 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And _ BitAND(WinGetState($aWL[$iCC][1]), 2) Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] EndIf Next If $nAdd = 0 Then Return SetError(2, 0, 0);No windows found ReDim $aTemp[$nAdd + 1][2] $aTemp[0][0] = $nAdd Return $aTemp EndFuncLooks like setting the parameter to 1 should get you what you want. M23 Edited June 3, 2012 by Melba23 Found example  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Mordred Posted August 20, 2012 Share Posted August 20, 2012 (edited) Just wanted to say that this solution worked great for me with foobar2000 (because the Window title is completely different depending on what's playing). Here's my script for the lazy: Edit: Turns out this didn't work in all situations. I modified the script above so that it only finds the foobar2000.exe process window if it is visible or if it is minimized. This means it's not attempting to close any of the multiple hidden windows that foobar scripts could have. expandcollapse popup#include <array.au3> Local $a1 $PID = ProcessExists("foobar2000.exe") ; Will return the PID or 0 if the process isn't found. If $PID Then $a1 = _WinGetHandleByPID($PID, 3) ;_ArrayDisplay($a1) For $i = 1 To $a1[0][1]+1 WinClose($a1[$i][1]) Next EndIf Exit ;$nVisible = -1 "All (Visble or not)", $nVisible = 0 "Not Visible Only", $nVisible = 1 "Visible Only", 2 = "Minimized", 3 = "Visible or Minimized" Func _WinGetHandleByPID($vProc, $nVisible = 1) $vProc = ProcessExists($vProc); If Not $vProc Then Return SetError(1, 0, 0) Local $aWL = WinList() Local $aTemp[UBound($aWL)][2], $nAdd = 0 For $iCC = 1 To $aWL[0][0] If $nVisible = -1 And WinGetProcess($aWL[$iCC][1]) = $vProc Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible = 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And BitAND(WinGetState($aWL[$iCC][1]), 2) = 0 Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible = 1 And WinGetProcess($aWL[$iCC][1]) = $vProc And _ BitAND(WinGetState($aWL[$iCC][1]), 2) Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible = 2 And WinGetProcess($aWL[$iCC][1]) = $vProc And BitAND(WinGetState($aWL[$iCC][1]),16) Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] ElseIf $nVisible = 3 And WinGetProcess($aWL[$iCC][1]) = $vProc And (BitAND(WinGetState($aWL[$iCC][1]),16) Or BitAND(WinGetState($aWL[$iCC][1]), 2)) Then $nAdd += 1 $aTemp[$nAdd][0] = $aWL[$iCC][0] $aTemp[$nAdd][1] = $aWL[$iCC][1] EndIf Next If $nAdd = 0 Then Return SetError(2, 0, 0);No windows found ReDim $aTemp[$nAdd + 1][2] $aTemp[0][0] = $nAdd Return $aTemp EndFunc Edited August 23, 2012 by Mordred 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