Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Farr Custom Browser Launch
- ; Start Date: 12/04/2010 :: ; Last Updated: 12/04/2010
- ; An AHK script to launch Urls in a custom browser and depending on which is open
- ; Set this script as the browser in Farr's "External Tools" section
- ; by lanux128
- ; thanks to ewemoa for the suggestions
- ;#Persistent
- #SingleInstance force
- #NoEnv
- SetWorkingDir %A_ScriptDir%
- ;the workflow is like this:
- ;1. open all urls in the default browser (A)
- ;2. however if browser B is already open, then divert all urls to browser B
- ;; Parse command-line
- If 0 < 2
- {
- geturi := %0% ; Fetch the contents of the command-line
- Gosub, Get_INI
- ;; Check for existing browser (secondary browser)
- SplitPath, BrowserB, BrowserB_Exe
- Process, Exist, %BrowserB_Exe%
- NewPID = %ErrorLevel% ; Save since ErrorLevel often changes.
- If NewPID <> 0 ;
- Run %BrowserB% %geturi%
- Else
- Run %BrowserA% %geturi%
- }
- Else
- MsgBox, 16,, Error parsing the url parameter.
- Return
- Get_INI:
- SplitPath, A_ScriptFullPath, , , , ScriptIni
- IfNotExist, %ScriptIni%.ini
- {
- comments=
- comments=`;%A_Space%Ini settings for %ScriptIni% program.
- comments=%comments%`n`;%A_Space%
- comments=%comments%`n`;%A_Space%This file contains some of the configurable settings.
- comments=%comments%`n`;%A_Tab%
- comments=%comments%`n`;%A_Space%--------------------------------------
- comments=%comments%`n`;%A_Space%You may edit this file but not while the script is running.
- comments=%comments%`n`;
- FileAppend,%comments%,%ScriptIni%.ini
- BrowserA=%ProgramFiles%\Mozilla Firefox\firefox.exe
- BrowserB=%ProgramFiles%\K-Meleon\k-meleon.exe
- IniWrite,%BrowserA%,%ScriptIni%.ini,Settings,BrowserA
- IniWrite,%BrowserB%,%ScriptIni%.ini,Settings,BrowserB
- FileAppend,`n,%ScriptIni%.ini
- }
- Else ;INI file exists, read from it
- {
- IniRead,BrowserA,%ScriptIni%.ini,Settings,BrowserA,iexplore.exe
- IniRead,BrowserB,%ScriptIni%.ini,Settings,BrowserB,iexplore.exe
- }
- Return
Add Comment
Please, Sign In to add comment