lanux128

Farr Custom Browser Launcher

Apr 12th, 2010
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Farr Custom Browser Launch
  2. ; Start Date: 12/04/2010 :: ; Last Updated: 12/04/2010
  3. ; An AHK script to launch Urls in a custom browser and depending on which is open
  4. ; Set this script as the browser in Farr's "External Tools" section
  5. ; by lanux128
  6. ; thanks to ewemoa for the suggestions
  7.  
  8. ;#Persistent
  9. #SingleInstance force
  10. #NoEnv
  11. SetWorkingDir %A_ScriptDir%
  12.  
  13. ;the workflow is like this:
  14. ;1. set browser A as default
  15. ;2. open all urls in browser A
  16. ;3. however if browser B is already open, then divert all urls to browser B
  17.  
  18. ;; Parse command-line
  19. If 0 < 2
  20. {
  21.   geturi := %0%  ; Fetch the contents of the command-line
  22.   Gosub, Get_INI
  23.   ;; Check for existing browser (secondary browser)
  24.   SplitPath, BrowserB, BrowserB_Exe
  25.   Process, Exist, %BrowserB_Exe%
  26.   NewPID = %ErrorLevel%   ; Save since ErrorLevel often changes.
  27.   If NewPID <> 0          ;
  28.     Run %BrowserB% %geturi%
  29.   Else
  30.     Run %BrowserA% %geturi%
  31. }
  32. Else
  33.     MsgBox, 16,, Error parsing the url parameter.
  34. Return
  35.  
  36. Get_INI:
  37. SplitPath, A_ScriptFullPath, , , , ScriptIni
  38. IfNotExist, %ScriptIni%.ini
  39.   {
  40.   comments=
  41.   comments=`;%A_Space%Ini settings for %ScriptIni% program.
  42.   comments=%comments%`n`;%A_Space%
  43.   comments=%comments%`n`;%A_Space%This file contains some of the configurable settings.
  44.   comments=%comments%`n`;%A_Tab%
  45.   comments=%comments%`n`;%A_Space%--------------------------------------
  46.   comments=%comments%`n`;%A_Space%You may edit this file but not while the script is running.
  47.   comments=%comments%`n`;
  48.   FileAppend,%comments%,%ScriptIni%.ini
  49.   BrowserA=%ProgramFiles%\Mozilla Firefox\firefox.exe
  50.   BrowserB=%ProgramFiles%\K-Meleon\k-meleon.exe
  51.   IniWrite,%BrowserA%,%ScriptIni%.ini,Settings,BrowserA
  52.   IniWrite,%BrowserB%,%ScriptIni%.ini,Settings,BrowserB
  53.   FileAppend,`n,%ScriptIni%.ini
  54.   }
  55. Else  ;INI file exists, read from it
  56.   {
  57.   IniRead,BrowserA,%ScriptIni%.ini,Settings,BrowserA,iexplore.exe
  58.   IniRead,BrowserB,%ScriptIni%.ini,Settings,BrowserB,iexplore.exe
  59.   }
  60. Return
Add Comment
Please, Sign In to add comment