gpt4 book ai didi

autohotkey - 如何使用 Autohotkey 打开一个新的 chrome 选项卡?

转载 作者:行者123 更新时间:2023-12-04 01:18:35 27 4
gpt4 key购买 nike

此代码打开一个新的 chrome 选项卡并将整个 chrome 窗口放在所有其他正在运行的程序后面:

Browser = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
URL = "http://cyberforum.ru"

Name = Mid(Browser, InStrRev(Browser, "\") + 1)
For Each P In GetObject("winmgmts:\\.\root\CIMV2")._
ExecQuery("Select ParentProcessID from Win32_Process Where Name = '" & Name & "'")
PID = P.ParentProcessID : If InStr(PIDs & " ", " " & PID & " ") Then Exit For
PIDs = PIDs & " " & PID
Next

With CreateObject("WScript.Shell")
Set Exe = .Exec(Browser & " " & URL)
If IsEmpty(PID) Then PID = Exe.ProcessID Else WSH.Sleep 1000
Do : A = .AppActivate(PID) : Loop Until A
.SendKeys "%{Esc}"
End With

如何使用 Autohotkey 做同样的事情?

最佳答案

在 AHK 中,您可以使用变量(例如 chromePID)来存储程序的唯一进程 ID (PID),并按如下方式处理:

Browser = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
URL = "http://cyberforum.ru"

IfWinExist ahk_exe chrome.exe
{
WinGet, chromePID, PID, ahk_exe chrome.exe
Run %Browser% "%URL%"
}
else
Run %Browser% "%URL%",,, chromePID
WinWait ahk_pid %chromePID%
WinSet, Bottom,, ahk_pid %chromePID% ; send the window beneath all other windows
return

https://autohotkey.com/docs/commands/WinGet.htm#PID https://autohotkey.com/docs/commands/Run.htm#Parameters https://autohotkey.com/docs/commands/WinSet.htm#Bottom

关于autohotkey - 如何使用 Autohotkey 打开一个新的 chrome 选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53680565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com