在不同的浏览器中打开URL

  • 本文关键字:URL 浏览器 autohotkey
  • 更新时间 :
  • 英文 :

global AssocArray := {}
Array := []
Loop, Read, links.txt
Array.Push(StrSplit(A_LoopReadLine, ";"))
for index, element in Array {
Browser := Func("Launch").Bind("chrome.exe --options ", "firefox.exe -options ")
Menu, MyMenu, Add, % element.2, % Browser
AssocArray[element.2] := element.3
}
Menu, MyMenu, Show
Launch(BrowserPC1, BrowserPC2, ItemName, ItemPos) {
Browser := A_ComputerName = PC1 ? %BrowserPC1% : %BrowserPC2%
Run, % Browser AssocArray[ItemName]
return
}
Format of links.txt:
;Arrays;https://autohotkey.com/docs/Arrays

如何在Launch中使用不同的浏览器,取决于我是使用PC1还是PC2,以及我为不同的菜单指定了哪些浏览器(这就是为什么我没有在Launch中简单地指定它们(?我得到了一个非法字符错误,因为(我认为(破折号。

错误就在这里:

Browser := A_ComputerName = PC1 ? %BrowserPC1% : %BrowserPC2%

您正在尝试使用动态变量
在表达式语句中,您不会通过将变量封装在%s中的传统AHK方式引用变量。您只需键入它们的名称,如下所示:

Browser := A_ComputerName = PC1 ? BrowserPC1 : BrowserPC2

另一件事。变量PC1应该定义在哪里
您是否打算将其用作文字字符串("PC1"(?

最新更新