| View previous topic :: View next topic |
| Author |
Message |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Sat Mar 22, 2008 8:04 pm Post subject: getDefaultInternetClient() / Browser from Registry |
|
|
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 |
|
 |
neXt
Joined: 18 Mar 2007 Posts: 504
|
Posted: Sun Mar 23, 2008 6:12 pm Post subject: |
|
|
| Client returns blank in Vista. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 748 Location: Texas, USA
|
Posted: Mon Mar 24, 2008 7:42 pm Post subject: |
|
|
| 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 |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Mon Mar 24, 2008 8:57 pm Post subject: |
|
|
I am currently in an internet explorer ... umm I mean Internet Cafe. 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 |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 748 Location: Texas, USA
|
Posted: Mon Mar 24, 2008 9:13 pm Post subject: |
|
|
| 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 |
|
 |
Guest
|
Posted: Tue Mar 25, 2008 1:00 am Post subject: |
|
|
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
|
Posted: Tue Mar 25, 2008 2:18 pm Post subject: |
|
|
| 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 |
|
 |
maximo3491
Joined: 10 Feb 2007 Posts: 92
|
Posted: Tue Mar 25, 2008 4:50 pm Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Mon Jun 13, 2011 11:52 pm Post subject: |
|
|
This doesn't work for me, Windows XP
MsgBox, % FunctionName() doesn't return anything |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jun 14, 2011 1:13 am Post subject: |
|
|
| I use chrome, maybe that's why? |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 748 Location: Texas, USA
|
Posted: Tue Jun 14, 2011 3:14 am Post subject: |
|
|
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 |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 748 Location: Texas, USA
|
Posted: Wed Jun 15, 2011 1:08 am Post subject: |
|
|
| 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 |
|
 |
zzzooo10
Joined: 19 Dec 2010 Posts: 229
|
Posted: Wed Jun 15, 2011 1:34 am Post subject: |
|
|
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 |
|
 |
|