lanux128

Untitled

Apr 28th, 2010
226
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. open all urls in the default browser (A)
  15. ;2. however if browser B is already open, then divert all urls to browser B
  16.  
  17. ;; Parse command-line
  18. If 0 < 2
  19. {
  20.   geturi := %0%  ; Fetch the contents of the command-line
  21.   Gosub, Get_INI
  22.   ;; Check for existing browser (secondary browser)
  23.   SplitPath, BrowserB, BrowserB_Exe
  24.   Process, Exist, %BrowserB_Exe%
  25.   NewPID = %ErrorLevel%   ; Save since ErrorLevel often changes.
  26.   If NewPID <> 0          ;
  27.     Run %BrowserB% %geturi%
  28.   Else
  29.     Run %BrowserA% %geturi%
  30. }
  31. Else
  32.     MsgBox, 16,, Error parsing the url parameter.
  33. Return
  34.  
  35. Get_INI:
  36. SplitPath, A_ScriptFullPath, , , , ScriptIni
  37. IfNotExist, %ScriptIni%.ini
  38.   {
  39.   comments=
  40.   comments=`;%A_Space%Ini settings for %ScriptIni% program.
  41.   comments=%comments%`n`;%A_Space%
  42.   comments=%comments%`n`;%A_Space%This file contains some of the configurable settings.
  43.   comments=%comments%`n`;%A_Tab%
  44.   comments=%comments%`n`;%A_Space%--------------------------------------
  45.   comments=%comments%`n`;%A_Space%You may edit this file but not while the script is running.
  46.   comments=%comments%`n`;
  47.   FileAppend,%comments%,%ScriptIni%.ini
  48.   BrowserA=%ProgramFiles%\Mozilla Firefox\firefox.exe
  49.   BrowserB=%ProgramFiles%\K-Meleon\k-meleon.exe
  50.   IniWrite,%BrowserA%,%ScriptIni%.ini,Settings,BrowserA
  51.   IniWrite,%BrowserB%,%ScriptIni%.ini,Settings,BrowserB
  52.   FileAppend,`n,%ScriptIni%.ini
  53.   }
  54. Else  ;INI file exists, read from it
  55.   {
  56.   IniRead,BrowserA,%ScriptIni%.ini,Settings,BrowserA,iexplore.exe
  57.   IniRead,BrowserB,%ScriptIni%.ini,Settings,BrowserB,iexplore.exe
  58.   }
  59. Return
Add Comment
Please, Sign In to add comment