FastHelper Posted June 8, 2008 Share Posted June 8, 2008 how can i close a window which is not associate with any program? like if any folder or drive is opened. i know i can do like this: if winexists("Name") Then WinClose ("Name") 'or WinKill EndIf but how can i close all opened folders? or drives. thanks for the help sorry for my spelling mistakes. its due to be fast !!! Link to comment Share on other sites More sharing options...
martin Posted June 8, 2008 Share Posted June 8, 2008 how can i close a window which is not associate with any program? like if any folder or drive is opened. i know i can do like this: if winexists("Name") Then WinClose ("Name") 'or WinKill EndIf but how can i close all opened folders? or drives. thanks for the helpYou might consider that this is a bit drastic but ProcessClose("explorer.exe") Sleep(3000) ShellExecute("explorer.exe") 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. Link to comment Share on other sites More sharing options...
monoceres Posted June 8, 2008 Share Posted June 8, 2008 (edited) Maybe this? $array=WinList() $ePID=ProcessExists("explorer.exe") For $i=1 To Ubound($array)-1 If WinGetProcess($array[$i][0])=$ePID Then WinClose($array[$i][0]) EndIf Next Edited June 8, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
martin Posted June 8, 2008 Share Posted June 8, 2008 Maybe this? $array=WinList() $ePID=ProcessExists("explorer.exe") For $i=1 To Ubound($array)-1 If WinGetProcess($array[$i][0])=$ePID Then WinClose($array[$i][0]) EndIf Next That's much better monoceres Shearing the sheep is better than shooting it I suppose. 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. Link to comment Share on other sites More sharing options...
FastHelper Posted June 8, 2008 Author Share Posted June 8, 2008 Maybe this? $array=WinList() $ePID=ProcessExists("explorer.exe") For $i=1 To Ubound($array)-1 If WinGetProcess($array[$i][0])=$ePID Then WinClose($array[$i][0]) EndIf Next thanks for the help but after closing the folder window it prompts for shutdown. how can i avoid not to ask for shutdown. sorry for my spelling mistakes. its due to be fast !!! Link to comment Share on other sites More sharing options...
FastHelper Posted June 8, 2008 Author Share Posted June 8, 2008 @ monocers shutdown problem fixed by this: $array=WinList() $ePID=ProcessExists("explorer.exe") For $i=1 To Ubound($array)-1 If WinGetProcess($array[$i][0])=$ePID Then WinClose($array[$i][0]) if WinExists("") Then send("{Esc}") EndIf EndIf Next but still want to know you idea because i know sending esc may close some running apps. sorry for my spelling mistakes. its due to be fast !!! Link to comment Share on other sites More sharing options...
food Posted June 8, 2008 Share Posted June 8, 2008 how can i close a window which is not associate with any program? like if any folder or drive is opened. i know i can do like this: if winexists("Name") Then WinClose ("Name") 'or WinKill EndIf but how can i close all opened folders? or drives. thanks for the helpwhen you open autoit windows info you will find "class" of programe you want close after write code if winexists("Name") Then WinClose ("Name") 'or WinKill EndIf ex: notepad is [class:Notepad] and write: if winexists("[class:Notepad]") then winclose("[class:Notepad]") endif Link to comment Share on other sites More sharing options...
Bert Posted June 8, 2008 Share Posted June 8, 2008 You have more than one thread basically on the same subject - how to close windows. What is your goal with your current project? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
FreeFry Posted June 8, 2008 Share Posted June 8, 2008 He could use something like this: #include <WinAPI.au3> $aWindows = _ProcessGetWinEx("explorer.exe", "CabinetWClass") For $i = 1 To $aWindows[0] WinClose($aWindows[$i]) Next Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "") $ivPid = ProcessExists($ivPid) If Not $ivPid Then Return(SetError(1, 0, 0)) Local $avwArray = WinList() Local $avRet[1] = [0] For $i = 1 To $avwArray[0][0] ;~ ConsoleWrite($avwArray[$i][0] & @LF) If WinGetProcess($avwArray[$i][1]) = $ivPid Then If $svClass = "" Or _WinAPI_GetClassName($avwArray[$i][1]) = $svClass Then If ($svTitle = "" Or $avwArray[$i][0] = $svTitle) And ($svText = "" Or StringInStr(WinGetText($avwArray[$i][1]), $svText)) Then $avRet[0] += 1 ReDim $avRet[$avRet[0]+1] $avRet[$avRet[0]] = $avwArray[$i][1] EndIf EndIf EndIf Next Return $avRet EndFunc Link to comment Share on other sites More sharing options...
FastHelper Posted June 8, 2008 Author Share Posted June 8, 2008 He could use something like this: #include <WinAPI.au3> $aWindows = _ProcessGetWinEx("explorer.exe", "CabinetWClass") For $i = 1 To $aWindows[0] WinClose($aWindows[$i]) Next Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "") $ivPid = ProcessExists($ivPid) If Not $ivPid Then Return(SetError(1, 0, 0)) Local $avwArray = WinList() Local $avRet[1] = [0] For $i = 1 To $avwArray[0][0] ;~ ConsoleWrite($avwArray[$i][0] & @LF) If WinGetProcess($avwArray[$i][1]) = $ivPid Then If $svClass = "" Or _WinAPI_GetClassName($avwArray[$i][1]) = $svClass Then If ($svTitle = "" Or $avwArray[$i][0] = $svTitle) And ($svText = "" Or StringInStr(WinGetText($avwArray[$i][1]), $svText)) Then $avRet[0] += 1 ReDim $avRet[$avRet[0]+1] $avRet[$avRet[0]] = $avwArray[$i][1] EndIf EndIf EndIf Next Return $avRet EndFunc thanks buddy, its working perfect. sorry for my spelling mistakes. its due to be fast !!! 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