autohotkey脚本 快捷键 一键打开和隐藏程序,目前支持sublime和微信

#SingleInstance,force
#NoTrayIcon ;无菜单栏图标

ProcessExist(exe){			;一个自定义函数,根据自定义函数的返回值作为#if成立依据原GetPID
	Process, Exist,% exe
	return ErrorLevel
}

;ctrl + shift+alt+s 打开sublime
^!+s::
sublime:="ahk_class PX_WINDOW_CLASS"
sublime_path:="C:\sublime_text_4\sublime_text.exe"
 
if ProcessExist("sublime_text.exe")=0
	Run, %sublime_path%
else
{
	WinGet,wxhwnd,ID,%sublime%
	if strlen(wxhwnd)=0
	{
		winshow,%sublime%
		winactivate,%sublime%
	}
	else
	{
		winhide,%sublime%
	}
}
return
 

;ctrl + shift+alt+w 打开微信
^!+w::
WeChat:="ahk_class WeChatMainWndForPC"
WeChat_path:="C:\Program Files (x86)\Tencent\WeChat\WeChat.exe"
 
if ProcessExist("WeChat.exe")=0
	Run, %WeChat_path%
else
{
	WinGet,wxhwnd,ID,%WeChat%
	if strlen(wxhwnd)=0
	{
		winshow,%WeChat%
		winactivate,%WeChat%
	}
	else
	{
		winhide,%WeChat%
	}
}
return
 

  

上一篇:VBS脚本合集(自制脚本)


下一篇:利用Xtrabackupex在线添加Slave-MHA