我用 AutoScriptWriter 创建了一个小宏,它在我创建后立即运行良好,但后来当我打开它正在工作的程序并启动宏时,它出现在我的系统托盘中,但什么也没发生。我还没有分配热键,只是单击宏来运行它。我究竟做错了什么?
谢谢,艾伦
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
run C:\Program Files\VinylStudio\VinylStudio.exe, , max
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2 ; Allow more flexibility in matching the windows title.
SetTimer, CloseScript, 1000
Return ; stop the script here on startup
CloseScript:
IfWinExist ahk_class VinylStudio_main
Return
ExitApp
#ifWinActive ahk_class VinylStudio_main
^h:: ; Here I assigned the hotkey [Ctrl]+h
WinActivate, VinylStudio
WinWait, VinylStudio, , 3 ; Wait for 3 seconds and then alert user
if ErrorLevel
{
MsgBox, VinylStudio timed out.
return
}
MouseClick, left, 479, 79 ; MouseClicks are less reliable than keyboard shortcuts or ControlSend/ControlClick.
Sleep, 100
MouseClick, left, 421, 40
Sleep, 100
MouseClick, left, 425, 443
Sleep, 100
WinWait, Filter Settings, , 3 ; Wait 3 seconds for pop-up else alert user
if ErrorLevel
{
MsgBox, Filter Settings timed out.
return
}
MouseClick, left, 29, 109
Sleep, 100
WinWait, Define Noise Sample, , 3 ; Wait 3 seconds for pop-up else alert user
if ErrorLevel
{
MsgBox, Define Noise Sample timed out.
return
}
MouseClick, left, 388, 168
Sleep, 100
MouseClick, left, -86, 660, 2
;MouseClick, left, -86, 660
Sleep, 100
WinWait, VinylStudio, , 3 ; Wait 3 seconds for pop-up else alert user
if ErrorLevel
{
MsgBox, VinylStudio timed out.
return
}
MouseClick, left, 200, 675, 2
;MouseClick, left, 200, 675
Sleep, 100
MouseClick, left, 200, 675, 2
;MouseClick, left, 200, 675
Sleep, 100
MouseClick, left, 201, 673
Sleep, 100
MouseClick, left, 203, 673, 2
;MouseClick, left, 203, 673
Sleep, 100
MouseClick, left, 203, 673
Sleep, 100
MouseClick, left, 787, 645
Sleep, 100
Return
#ifwinactive