Trying to select Default Browser Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SilverGaiden
Posts: 13
Joined: 08 Jun 2018, 01:39

Trying to select Default Browser

08 Jun 2018, 02:02

Hello!

First time poster and I appreciate everything in advance. not the best but have been tinkering over the past 3 days and came into a snag.

I and making a diagnostics tool for my work and several people stated they want the ability to have the script switch between browsers. I have the obvious one for "Run chrome.exe" and Run firefox.exe". But I have the an If variable for %PassthroughBrowser% so If I make the "Default Browser" selection with nothing, it gives an error.

I had to cut out most of the propietary stuff from my work but here is the core of the code im am working with.

Again, Thank you in advance!

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Gui -MaximizeBox

Gui Font, s10 Bold, Segoe UI
Gui Add, Button, x3 y90 w110 h23, Domain Name
Gui Font
Gui Add, Edit, vdomain x115 y90 w180 h20

Gui Add, DropDownList, x175 y120 gBrowserType vSelectedBrowser, Default Browser||Firefox|Chrome

Gui, Add, CheckBox, x205 y155 gAlwaysOnTop vCheck, Always on Top

Gui Font, s10 Bold, Segoe UI +Center
Gui Add, Text, x120 y200 w110 h20, Tools
Gui Font
Gui Add, Button, x10 y130 w50 h50, Dig
GUI Add, Button, xp+65 yp+0 w50 h50, Browser



Gui Show, w300, Tool Board
Return



GuiEscape:
GuiClose:
    ExitApp
    
    
ButtonBrowser:
Gui, submit, nohide
Run %PassthroughBrowser% %domain%
return

ButtonDig:
Gui, submit, nohide
run %PassthroughBrowser% http://www.digwebinterface.com/?hostnames=%domain%&type=ANY&useresolver=8.8.4.4&ns=all&nameservers=
return

AlwaysOnTop:
    Gui, Submit, NoHide
    If Check = 1
    {
        Gui, +AlwaysOnTop
    }
    else
    {
        Gui, -AlwaysOnTop
    }
Return

BrowserType:
    Gui, Submit, NoHide
    If SelectedBrowser = Default Browser
    {
        PassthroughBrowser = 
    }
    If SelectedBrowser = Firefox
    {
        PassthroughBrowser = firefox.exe
    }
    If SelectedBrowser = Chrome
    {
        PassthroughBrowser = chrome.exe
    }
Return
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Trying to select Default Browser

08 Jun 2018, 20:26

In this Line: run %PassthroughBrowser% http://www.digwebinterface.com/?hostnam ... meservers= the string domain is considered a variable because it's enclosed in percent sign, use an escape char `.

Should be:
run %PassthroughBrowser% http://www.digwebinterface.com/?hostnam ... meservers=


Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Gui -MaximizeBox

Gui Font, s10 Bold, Segoe UI
Gui Add, Button, x3 y90 w110 h23, Domain Name
Gui Font
Gui Add, Edit, vdomain x115 y90 w180 h20

Gui Add, DropDownList, x175 y120 gBrowserType vSelectedBrowser, Default Browser||Firefox|Chrome

Gui, Add, CheckBox, x205 y155 gAlwaysOnTop vCheck, Always on Top

Gui Font, s10 Bold, Segoe UI +Center
Gui Add, Text, x120 y200 w110 h20, Tools
Gui Font
Gui Add, Button, x10 y130 w50 h50, Dig
GUI Add, Button, xp+65 yp+0 w50 h50, Browser



Gui Show, w300, Tool Board
Return



GuiEscape:
GuiClose:
ExitApp


ButtonBrowser:
Gui, submit, nohide
Run %PassthroughBrowser% %domain%
return

ButtonDig:
Gui, submit, nohide
run %PassthroughBrowser% http://www.digwebinterface.com/?hostnames=`%domain`%&type=ANY&useresolver=8.8.4.4&ns=all&nameservers=
return

AlwaysOnTop:
Gui, Submit, NoHide
If Check = 1
{
Gui, +AlwaysOnTop
}
else
{
Gui, -AlwaysOnTop
}
Return

BrowserType:
Gui, Submit, NoHide
If SelectedBrowser = Default Browser
{
PassthroughBrowser =
}
If SelectedBrowser = Firefox
{
PassthroughBrowser = firefox.exe
}
If SelectedBrowser = Chrome
{
PassthroughBrowser = chrome.exe
}
Return
Outsourcing Clicks & Presses Since 2004.
garry
Posts: 3787
Joined: 22 Dec 2013, 12:50

Re: Trying to select Default Browser  Topic is solved

09 Jun 2018, 03:54

same question here :
https://autohotkey.com/boards/viewtopic.php?f=5&t=50267

short example :

Code: Select all

url=https://autohotkey.com/boards/
ixe:=""                                                       ;- my default browser ( firefox )
;ixe:=A_programfiles . "\internet explorer\iexplore.exe "
run,%ixe%%url%
return
SilverGaiden
Posts: 13
Joined: 08 Jun 2018, 01:39

Re: Trying to select Default Browser

09 Jun 2018, 17:55

brutus_skywalker wrote:In this Line: run %PassthroughBrowser% http://www.digwebinterface.com/?hostnam ... meservers= the string domain is considered a variable because it's enclosed in percent sign, use an escape char `.

Should be:
run %PassthroughBrowser% http://www.digwebinterface.com/?hostnam ... meservers=
no that part needed to be a variable based off of the following

Code: Select all

Gui Font, s10 Bold, Segoe UI
Gui Add, Text, x3 y90 w110 h23, Domain Name
Gui Font
Gui Add, Edit, vdomain x115 y90 w180 h20


So dig web interface would pull the domain I type in the Domain field, by replacing the variable in the command
SilverGaiden
Posts: 13
Joined: 08 Jun 2018, 01:39

Re: Trying to select Default Browser

09 Jun 2018, 18:05

garry wrote:same question here :
https://autohotkey.com/boards/viewtopic.php?f=5&t=50267

short example :

Code: Select all

url=https://autohotkey.com/boards/
ixe:=""                                                       ;- my default browser ( firefox )
;ixe:=A_programfiles . "\internet explorer\iexplore.exe "
run,%ixe%%url%
return
My bad, Thank you garry. I'll use the other other post as it is cleaner with the code snippet. I found out that the error only happens when I try to run your example with a blank space and without http:// and just run the domain so the end result become,

Code: Select all

Run, "  google.com"
When you try to use Run google.com, it doesn't translate to a browser. looking for user redundancy and I think I may have to detect if http:// or https:// has been entered or not, to auto add the text in.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Giresharu, RussF and 195 guests