AutoHotkey Community

It is currently May 27th, 2012, 4:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: March 22nd, 2008, 9:04 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
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 June 15th, 2011, 2:49 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 23rd, 2008, 7:12 pm 
Offline

Joined: March 19th, 2007, 12:43 am
Posts: 532
Client returns blank in Vista.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2008, 8:42 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2008, 9:57 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
I am currently in an internet explorer ... umm I mean Internet Cafe. :lol: 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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2008, 10:13 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2008, 2:00 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2008, 3:18 pm 
Offline

Joined: September 21st, 2006, 10:04 pm
Posts: 32
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2008, 5:50 pm 
Offline

Joined: February 10th, 2007, 5:18 am
Posts: 92
On XP...

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


FF returns
Quote:
C:\Program Files\Mozilla Firefox\firefox.exe


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2011, 12:52 am 
This doesn't work for me, Windows XP
MsgBox, % FunctionName() doesn't return anything


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2011, 2:13 am 
I use chrome, maybe that's why?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2011, 2:50 am 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
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! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2011, 4:14 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2011, 1:08 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
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! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2011, 2:08 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2011, 2:34 am 
Offline

Joined: December 19th, 2010, 5:32 am
Posts: 235
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])$")
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group