Jump to content
Sign in to follow this  
ffdshow

Problem with the default internet browser

Recommended Posts

ffdshow

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?

Share this post


Link to post
Share on other sites
BrettF
ffdshow

Use WinClose () to close it and Opt ("WinTitleMatchMode", 2) to should do the trick.

Can you be more explicative?

Share this post


Link to post
Share on other sites
MrCreatoR

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

Share this post


Link to post
Share on other sites
BrettF
smashly

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

Share this post


Link to post
Share on other sites
ptrex

@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

Share this post


Link to post
Share on other sites
BrettF
ffdshow

@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.

Share this post


Link to post
Share on other sites
smashly

@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

Share this post


Link to post
Share on other sites
BrettF
ffdshow

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

Share this post


Link to post
Share on other sites
ffdshow

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

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
ffdshow

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

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
ffdshow

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

Share this post


Link to post
Share on other sites
ffdshow

Well, no other ideas that it works?

Share this post


Link to post
Share on other sites
BrettF

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

Share this post


Link to post
Share on other sites
crzftx

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.

Share this post


Link to post
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
Sign in to follow this  

×