AutoHotkey如何隐藏运行其他程序
1、运行记事本
Run,notepad
2、隐藏运行记事本
Run,notepad,,Hide
3、运行RaiDrive ver 1.3.8
Run,C:Program FilesOpenBoxLabRaiDriveRaiDrive.exe
4、隐藏运行RaiDrive ver 1.3.8失败
Run,C:Program FilesOpenBoxLabRaiDriveRaiDrive.exe,,Hide
分析失败原因
Run中的Hide只在很短的时间之内有效,启动时间比较长的程序就会错过Hide时机
AutoHotkey已经发出Hide动作但是目标窗口还没有创建完毕,
等目标窗口创建完毕之后AutoHokey就不在补做Hide动作了,
因为AutoHotkey以为已经Hide成功了,其实Hide目标不存在,没有Hide成功
5、改进隐藏代码,这次终于成功了
Run,C:Program FilesOpenBoxLabRaiDriveRaiDrive.exe,,Hide
WinWait,ahk_exe RaiDrive.exe
WinHide,ahk_exe RaiDrive.exe
6、进一步改进隐藏代码
Run,C:Program FilesOpenBoxLabRaiDriveRaiDrive.exe,,Hide
WinWait,ahk_exe RaiDrive.exe,,9
WinHide,ahk_exe RaiDrive.exe
7、由于没有能力分析 AutoHotkey 的Run,,,Hide代码段落的实现源代码原理所以只能改进到此了
#NoEnv
#SingleInstance Ignore
#Persistent
global i
i:=1
Run,C:Program FilesOpenBoxLabRaiDriveRaiDrive.exe,,Hide
SetTimer,HideRaiDrive,10
return
HideRaiDrive()
{
WinHide,ahk_exe RaiDrive.exe
if(i>500)
{
SetTimer,HideRaiDrive,Delete
ExitApp
}
i++
}
#NoEnv
#SingleInstance Ignore
#Persistent
global i
i:=1
Run,C:Program FilesOpenBoxLabRaiDriveRaiDrive.exe,,Hide
SetTimer,HideRaiDrive,10
return
HideRaiDrive()
{
WinHide,ahk_exe RaiDrive.exe
if(i>500)
{
SetTimer,HideRaiDrive,Delete
ExitApp
}
i++
}
#NoEnv
#SingleInstance Ignore
#Persistent
global i
i:=1
Run,C:/Program Files/OpenBoxLab/RaiDrive/RaiDrive.exe,,Hide
SetTimer,HideRaiDrive,10
return
HideRaiDrive()
{
WinHide,ahk_exe RaiDrive.exe
if(i>500)
{
SetTimer,HideRaiDrive,Delete
ExitApp
}
i++
}