AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

getDefaultInternetClient() / Browser from Registry
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Sat Mar 22, 2008 8:04 pm    Post subject: getDefaultInternetClient() / Browser from Registry Reply with quote

EDIT: jbally made better working code: http://www.autohotkey.com/forum/viewtopic.php?t=62504
Code:
getDefaultInternetClient()
{
    RegRead, Client, HKEY_LOCAL_MACHINE, SOFTWARE\Clients\StartMenuInternet
    RegRead, Client, HKEY_LOCAL_MACHINE, SOFTWARE\Clients\StartMenuInternet\%Client%\shell\open\command
    IfNotExist, %Client%
        RegRead, Client, HKEY_LOCAL_MACHINE, SOFTWARE\Clients\StartMenuInternet\iexplorer.exe\shell\open\command
    Return Client
}


It looks in the Registry for the path of current default Browser. The default Browser is that one, which is showed in Start Menu of Windows also. May be this helps someone.

Its not required to have, but as a sidenote, I am using Windows XP.


Last edited by Tuncay on Wed Jun 15, 2011 1:49 am; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
neXt



Joined: 18 Mar 2007
Posts: 504

PostPosted: Sun Mar 23, 2008 6:12 pm    Post subject: Reply with quote

Client returns blank in Vista.
Back to top
View user's profile Send private message
jballi



Joined: 01 Oct 2005
Posts: 748
Location: Texas, USA

PostPosted: Mon Mar 24, 2008 7:42 pm    Post subject: Reply with quote

neXt wrote:
Client returns blank in Vista.

It works for me but I'm also using Windows XP.

Finding the default web browser may be a devil's errand. Every web browser program has a slightly different way of becoming the "default" web browser and this method can change from program version and by OS version.

My version of Tuncay's solution looks in different registry locations. I'm curious to see if this will find anything in Vista. The code still in development and is full of debug code but here it is anyway:

Code:
#NoEnv
#SingleInstance Force
;;;;;#Persistent


;-----------------
;-- Document type
;-----------------
outputdebug
    ,Searching for the following registry key: HKEY_CLASSES_ROOT\.htm\

RegRead
    ,$DocumentType
    ,HKEY_CLASSES_ROOT
    ,.htm\

if not ErrorLevel
    outputdebug -- Found the following value: %$DocumentType%
 else
    {
    msgbox,
       (ltrim
        Routine halted.  Error reading the following registry key:
        HKEY_CLASSES_ROOT\.htm\
       )
    return
    }


;-------------------------
;-- Default shell command
;--   for document type
;-------------------------
outputdebug,
   (ltrim join
    Searching for the following registry key:%A_Space%
    HKEY_CLASSES_ROOT\
    %$DocumentType%\
    shell\
   )

RegRead
    ,$DefaultShellCommand
    ,HKEY_CLASSES_ROOT
    ,%$DocumentType%\shell\

if not ErrorLevel
    outputdebug -- Found the following value: %$DefaultShellCommand%
 else
    {
    outputdebug -- NOT found.  Setting to "open"
    $DefaultShellCommand=open
    }


;-----------------------
;-- Default web browser
;-----------------------
outputdebug,
   (ltrim join
    Searching for the following registry key:%A_Space%
    HKEY_CLASSES_ROOT\
    %$DocumentType%\
    shell\
    %$DefaultShellCommand%\
    command
   )

RegRead
    ,$WebBrowserCommand
    ,HKEY_CLASSES_ROOT
    ,%$DocumentType%\shell\%$DefaultShellCommand%\command

if not ErrorLevel
    outputdebug -- Found the following value: %$WebBrowserCommand%
 else
    {
    msgbox,
       (ltrim join
        Routine halted.  Error reading the following registry key:%A_Space%
        HKEY_CLASSES_ROOT\
        %$DocumentType%\
        shell\
        %$DefaultShellCommand%\
        command
       )
    return
    }


;-----------------------
;-- Extract information
;-----------------------
outputdebug Before cleanup - $WebBrowserCommand=%$WebBrowserCommand%

;-- Remove double-quotes around the program path (if they exist)
if SubStr($WebBrowserCommand,1,1)=""""
    {
    StringTrimLeft
        ,$WebBrowserCommand
        ,$WebBrowserCommand
        ,1

    ;-- Replace next occurance of DQ
    StringReplace
        ,$WebBrowserCommand
        ,$WebBrowserCommand
        ,"
    }

outputdebug After cleanup -  $WebBrowserCommand=%$WebBrowserCommand%


SplitPath $WebBrowserCommand,$WebBrowserProgram,$WebBrowserPath

;-- Get rid of extraneous parameters                   
t_SPos:=InStr($WebBrowserProgram,A_Space)
if t_SPos
    StringLeft $WebBrowserProgram,$WebBrowserProgram,t_SPos-1
        ;-- Note: Space is a weak delimiter for this test/StringLeft.  Can
        ;   probably be done better looking for an ".exe" in the string...


;---------------
;-- Final value
;---------------
msgbox Default web browser: %$WebBrowserPath%\%$WebBrowserProgram%

return
Back to top
View user's profile Send private message Send e-mail
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Mon Mar 24, 2008 8:57 pm    Post subject: Reply with quote

I am currently in an internet explorer ... umm I mean Internet Cafe. Laughing and tested my code and it does return an empty string. It is a Windows XP computer ... so, don`t understand whats going on here.

BUT of course I tested your code also jballi AND it does show me the correct default Browser. Thx for your working solution. Might it be work under Vista also?? And what about older OS?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jballi



Joined: 01 Oct 2005
Posts: 748
Location: Texas, USA

PostPosted: Mon Mar 24, 2008 9:13 pm    Post subject: Reply with quote

Tuncay wrote:
I tested your code also jballi AND it does show me the correct default Browser. Thx for your working solution. Might it be work under Vista also?? And what about older OS?

Thanks for checking. I'm curious too. Anybody try this on Vista or on an "older than XP" OS?
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Tue Mar 25, 2008 1:00 am    Post subject: Reply with quote

StartMenuInternet doesn't have anything to do with the default browser, for which I'd rather check the protocols.
Code:
HKEY_CLASSES_ROOT\HTTP\shell\open\command
Back to top
paulwarr



Joined: 21 Sep 2006
Posts: 32

PostPosted: Tue Mar 25, 2008 2:18 pm    Post subject: Reply with quote

jballi wrote:
Anybody try this on Vista or on an "older than XP" OS?
Works on Vista, IE7. Haven't tried with either FireFox or Opera configured as default browser, however.
Back to top
View user's profile Send private message
maximo3491



Joined: 10 Feb 2007
Posts: 92

PostPosted: Tue Mar 25, 2008 4:50 pm    Post subject: Reply with quote

On XP...

IE returns
Quote:
C:\Program Files\Internet Explorer\iexplore.exe


FF returns
Quote:
C:\Program Files\Mozilla Firefox\firefox.exe
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Jun 13, 2011 11:52 pm    Post subject: Reply with quote

This doesn't work for me, Windows XP
MsgBox, % FunctionName() doesn't return anything
Back to top
Guest






PostPosted: Tue Jun 14, 2011 1:13 am    Post subject: Reply with quote

I use chrome, maybe that's why?
Back to top
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Tue Jun 14, 2011 1:50 am    Post subject: Reply with quote

Finding the correct browser is very tricky. Did you try jballi`s code some posts under mine? Related threads:

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jballi



Joined: 01 Oct 2005
Posts: 748
Location: Texas, USA

PostPosted: Tue Jun 14, 2011 3:14 am    Post subject: Reply with quote

The latest version of my "DefaultBrowser" function can be found here:
http://www.autohotkey.com/forum/viewtopic.php?t=62504

It can't be considered perfect (or even close) but it does return the correct "default" browser for most configurations.
Back to top
View user's profile Send private message Send e-mail
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Tue Jun 14, 2011 12:08 pm    Post subject: Reply with quote

jballi, I searched for that and could not find it anymore. Thats why keywords should be added...
_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jballi



Joined: 01 Oct 2005
Posts: 748
Location: Texas, USA

PostPosted: Wed Jun 15, 2011 1:08 am    Post subject: Reply with quote

Tuncay wrote:
jballi, I searched for that and could not find it anymore. Thats why keywords should be added...

I'm sorry you had trouble finding it. I never officially released this function (currently posted in the "Ask For Help" forum) because it's kind of a hack and I was very much hoping that someone else would come up with something better. Challenge initiated. Nevertheless, it works most of the time on most PC with most web browsers.

http://www.autohotkey.com/forum/viewtopic.php?t=62504
Back to top
View user's profile Send private message Send e-mail
zzzooo10



Joined: 19 Dec 2010
Posts: 229

PostPosted: Wed Jun 15, 2011 1:34 am    Post subject: Reply with quote

To find a default browser I have just been using this function I made. It works on all of my friends computers(Win7).
Code:
MsgBox % "Defualt browser: " Browser()

Browser() {
    RegRead, browser, HKEY_CURRENT_USER, Software\Classes\http\DefaultIcon\
    Return RegExReplace(browser, "(,[0-9])$")
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group