ffdshow Posted October 9, 2007 Share Posted October 9, 2007 Hi! I have a program which launch the default internet browser at the end of installation (this can not stopped). For example if Internet Explorer is the default browser I use: ProcessWait("IEXPLORE.EXE") $PID = ProcessExists("IEXPLORE.EXE") If $PID Then ProcessClose($PID) But if the default browser is other (and it may be Firefox, Opera etc.) what script I can use to cover all the possibilities? Link to comment Share on other sites More sharing options...
BrettF Posted October 9, 2007 Share Posted October 9, 2007 Use WinClose () to close it and Opt ("WinTitleMatchMode", 2) to should do the trick. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 Use WinClose () to close it and Opt ("WinTitleMatchMode", 2) to should do the trick.Can you be more explicative? Link to comment Share on other sites More sharing options...
MrCreatoR Posted October 9, 2007 Share Posted October 9, 2007 If the browser is Opera use Opera.exe process name, if Firefox then firefox.exe, and so one But closing a process is not so nice solution, you simple kill the process. Maby you should close all windows of the browser (they might be more then one ). But why you need to close the browser anyway? Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler 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 ProgramUDFs: 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 UDF 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 Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
BrettF Posted October 9, 2007 Share Posted October 9, 2007 Opt ("WinTitleMatchMode", 2) WinClose ("TitleName") Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
smashly Posted October 9, 2007 Share Posted October 9, 2007 (edited) Couldn't you do a registry check to find the default browser being used ? Then do a Winlist for the process of the default browser running. Then you'd know the correct process to be looking for to close.. Edited October 9, 2007 by smashly Link to comment Share on other sites More sharing options...
ptrex Posted October 9, 2007 Share Posted October 9, 2007 @all If I am not mistaken the default browser can be read from here : Func GetBrowser() ;Get Registry Default Browser settings $Browser = RegRead("HKLM\SOFTWARE\Classes\HTTP\shell\","") ConsoleWrite($Browser & @CRLF) EndFunc Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
BrettF Posted October 9, 2007 Share Posted October 9, 2007 @FFDSHOW- When this program finishes, does it load a page in the browser? E.G- it opens a home page/bug log/...etc? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 @FFDSHOW- When this program finishes, does it load a page in the browser? E.G- it opens a home page/bug log/...etc?This program open the browser and goes to the home page. Link to comment Share on other sites More sharing options...
smashly Posted October 9, 2007 Share Posted October 9, 2007 @all If I am not mistaken the default browser can be read from here : Func GetBrowser() ;Get Registry Default Browser settings $Browser = RegRead("HKLM\SOFTWARE\Classes\HTTP\shell\","") ConsoleWrite($Browser & @CRLF) EndFuncoÝ÷ Ù j·l¦ÚÞÇú®¢×jëh×6MsgBox(0,'', RegRead("HKCR\HTTP\shell\open\command\", "")) Cheers Link to comment Share on other sites More sharing options...
BrettF Posted October 9, 2007 Share Posted October 9, 2007 This program open the browser and goes to the home page.Is it the User's default home page? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 Is it the User's default home page?No man. It's the home page of the program (from you can download the program, buy it etc.) Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 (edited) I use this: $var = RegRead("HKCR\HTTP\shell\open\command\", "") Now, another question: how can I extract the name of the executable file from $var to use later in ProcessClose("") And let's say that $var = C:\\PROGRA~1\\MOZILL~1\\FIREFOX.EXE -requestPending -osint -url \"%1\" Edited October 9, 2007 by ffdshow Link to comment Share on other sites More sharing options...
smashly Posted October 9, 2007 Share Posted October 9, 2007 (edited) Crude example...$Def = RegRead("HKCR\HTTP\shell\open\command\", "") If $Def <> "" Then $Def = StringLeft($Def, StringInStr($Def, ".exe", 0, -1) + 4) If $Def <> "" Then $Def = StringMid($Def, StringInStr($Def, "\", 0, -1) + 1) If $Def <> "" Then $PL = ProcessList($Def) If Not @error And $PL[0][0] > 0 Then For $i = 1 To $PL[0][0] ProcessClose($PL[$i][1]) Next EndIf $Def = RegRead("HKCR\HTTP\shell\open\command\", "") If $Def <> "" Then $Def = StringLeft($Def, StringInStr($Def, ".exe", 0, -1) + 4) If FileExists($Def) Then ShellExecute($Def, "http://www.autoitscript.com/forum/index.php?showtopic=54792") EndIf By rights this should kill all browser windows, then bring you back to this thread... Cheers Edited October 9, 2007 by smashly Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 (edited) Crude example...$Def = RegRead("HKCR\HTTP\shell\open\command\", "") If $Def <> "" Then $Def = StringLeft($Def, StringInStr($Def, ".exe", 0, -1) + 4) If $Def <> "" Then $Def = StringMid($Def, StringInStr($Def, "\", 0, -1) + 1) If $Def <> "" Then $PL = ProcessList($Def) If Not @error And $PL[0][0] > 0 Then For $i = 1 To $PL[0][0] ProcessClose($PL[$i][1]) Next EndIf $Def = RegRead("HKCR\HTTP\shell\open\command\", "") If $Def <> "" Then $Def = StringLeft($Def, StringInStr($Def, ".exe", 0, -1) + 4) ShellExecute($Def, "http://www.autoitscript.com/forum/index.php?showtopic=54792") EndIfoÝ÷ Ø«m²Øb²ÈhºWdYZV룯§v,¶§n¸§*.m§$¶aËaæ ®Ïêº^"wÚrܨº»®*m¢§¶¬¶ÞiÖ§uÚ'ßÛdYmê-êðwhÂʶyö®Ö룬X«yú1~ç£n¶É²rÂʬk&¢ëm+ºÇ+ºÚ"µÍÌÍÝHYÔXY ][ÝÒÐÔÌLÒ ÌLÜÚ[ ÌLÛÜ[ÌLØÛÛ[X[ ÌLÉ][ÝË ][ÝÉ][ÝÊ Now, another question: how can I extract the name of the executable file from $var to use later in ProcessClose("") And let's say that $var = C:\\PROGRA~1\\MOZILL~1\\FIREFOX.EXE -requestPending -osint -url \"%1\" Edited October 9, 2007 by ffdshow Link to comment Share on other sites More sharing options...
smashly Posted October 9, 2007 Share Posted October 9, 2007 I'm using firefox ... For me all firefox windows get killed.. But on loading the firefox again I'm prompted if I want to restore the last state that firefox was in before being killed... Maybe you've got the option in firefox set to auto restart from the last state firefox was killed in... Now, another question: how can I extract the name of the executable file from $var to use later in ProcessClose("") And let's say that $var = C:\\PROGRA~1\\MOZILL~1\\FIREFOX.EXE -requestPending -osint -url \"%1\"As for your question, the first part of my code does exactly what your asking how to do... $Def = RegRead("HKCR\HTTP\shell\open\command\", "") If $Def <> "" Then $Def = StringLeft($Def, StringInStr($Def, ".exe", 0, -1) + 4) If $Def <> "" Then $Def = StringMid($Def, StringInStr($Def, "\", 0, -1) + 1) MsgBox(0,'',$Def) Cheers Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 (edited) Ok. This $Def = RegRead("HKCR\HTTP\shell\open\command\", "") If $Def <> "" Then $Def = StringLeft($Def, StringInStr($Def, ".exe", 0, -1) + 4) If $Def <> "" Then $Def = StringMid($Def, StringInStr($Def, "\", 0, -1) + 1) If $Def <> "" Then $PL = ProcessList($Def) If Not @error And $PL[0][0] > 0 Then For $i = 1 To $PL[0][0] ProcessClose($PL[$i][1]) Next EndIf EndIf must close the default browser. But don't. Edited October 9, 2007 by ffdshow Link to comment Share on other sites More sharing options...
ffdshow Posted October 9, 2007 Author Share Posted October 9, 2007 Well, no other ideas that it works? Link to comment Share on other sites More sharing options...
BrettF Posted October 9, 2007 Share Posted October 9, 2007 I'd say my idea would work, as it opens the home page of the program. Like I said, get the title (for example, the title of this thread is "Problem with the default internet browser" and then in FF it has "- Mozilla Firefox". All you need to do is do something similar to this: Opt ("WinTitleMatchMode", 2) WinClose ("TitleName") And you should be set. It seems the most reasonable, and simple way to do it. If you start closing the process, then you may close other windows. My $00.02... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
crzftx Posted October 16, 2007 Share Posted October 16, 2007 Did I miss something? where does he ask to close it? Just use Run("explore.exe website"). This will open it in IE. using ShellExecute(website) should work, but seems to give some error, kill AU3, and then open it anyway (in the default). maybe someone could work that out. 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