Jump to content

Problem with the default internet browser


Recommended Posts

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

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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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 by smashly
Link to comment
Share on other sites

@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

Link to comment
Share on other sites

Link to comment
Share on other sites

@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

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 by ffdshow
Link to comment
Share on other sites

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 by smashly
Link to comment
Share on other sites

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 by ffdshow
Link to comment
Share on other sites

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

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 by ffdshow
Link to comment
Share on other sites

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... :)

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...