首页 » 工作 » 方法 » 正文

Win 一键打开/切换到 App(替代 Alt + Tab)

发布者:站点默认
2020/07/20 浏览数(100) 分类:方法 Win 一键打开/切换到 App(替代 Alt + Tab)已关闭评论

创建 hotkey.ahk 并用 AutoHotKey 打开(功能与这里类似):

; -------------------------------------
; 用“Caps + 字符”打开/切换到指定软件
; # -> Win
; ! -> alt
; ^ -> control
; + -> shift
; -------------------------------------

; 用 CapsLock 代替 Ctrl + Alt + Win (仅组合键时,单按还是 CapsLock)
; via: https://stackoverflow.com/questions/40435980/how-to-emulate-hyper-key-in-windows-10-using-autohotkey
#NoEnv ; recommended for performance and compatibility with future autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input
~Capslock::
    Send {Ctrl DownTemp}{Alt DownTemp}{LWin DownTemp}
    KeyWait, Capslock
    Send {Ctrl Up}{Alt Up}{LWin Up}
return

; 关闭 Office App 的快捷键“Win + Ctrl + Alt + Shift”
; REG ADD HKCU\Software\Classes\ms-officeapp\Shell\Open\Command /t REG_SZ /d rundll32

; 打开/切换到指定软件
; via: https://gist.github.com/realchrisolin/fb10b20c832acb7e54605980afd14836
RunOrActivate(Target, WinTitle = "", Parameters = "")
{
   ; Get the filename without a path
   SplitPath, Target, TargetNameOnly

   Process, Exist, %TargetNameOnly%
   If ErrorLevel > 0
      PID = %ErrorLevel%
   Else
      Run, %Target% "%Parameters%", , , PID

   ; At least one app (Seapine TestTrack wouldn't always become the active
   ; window after using Run), so we always force a window activate.
   ; Activate by title if given, otherwise use PID.
   If WinTitle <> 
   {
      SetTitleMatchMode, 2
      WinWait, %WinTitle%, , 3
      TrayTip, , Activating Window Title "%WinTitle%" (%TargetNameOnly%)
      WinActivate, %WinTitle%
   }
   Else
   {
      WinWait, ahk_pid %PID%, , 3
      TrayTip, , Activating PID %PID% (%TargetNameOnly%)
      WinActivate, ahk_pid %PID%
   }


   SetTimer, RunOrActivateTrayTipOff, 1
}

; Turn off the tray tip
RunOrActivateTrayTipOff:
   SetTimer, RunOrActivateTrayTipOff, off
   TrayTip
Return

; 为软件绑定快捷键
~Capslock & v::RunOrActivate("C:\Users\usr\AppData\Local\Programs\Microsoft VS Code\Code.exe") ;"Visual Studio Code"
~Capslock & g::RunOrActivate("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")    ;"Google Chrome"
~Capslock & f::RunOrActivate("C:\Users\usr\AppData\Local\Fork\Fork.exe")                       ;"Fork"

Mac 一键打开/切换到 App(替代 Cmd + Tab)

点击返回顶部
  1. 留言
  2. 联系方式