打开 Excel sheet 然后按 Ctrl + Q
Open Excel sheet and press Ctrl + Q
我想打开一个excel sheet然后按Ctrl+Q调用宏。但是 ctrl+q 部分不起作用。到目前为止我尝试了什么:
run, %A_Desktop%\test.xlsm, %A_Desktop%\
Send {Ctrl Down}{Q}{Ctrl Up}
这也不起作用:
run, %A_Desktop%\test.xlsm, %A_Desktop%\
Send ^{Q}
可能'send'速度太快,文件没有完全打开。在 'send'.
之前尝试“sleep”
使用WinWait
等待window出现,WinActivate
和WinWaitActive
在向它发送任何命令之前:
; https://autohotkey.com/docs/commands/Run.htm#RunAs
; If the script is not elevated, relaunch as administrator and kill current instance
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
Run, %A_Desktop%\test.xlsm
WinWait, test.xlsm
WinActivate, test.xlsm
WinWaitActive, test.xlsm
Sleep, 300 ; if the program doesn't react immediately after activating
Send {Ctrl Down}q{Ctrl Up}
将 test.xlsm
替换为 window 的确切标题,如 Window 间谍中所示。
我想打开一个excel sheet然后按Ctrl+Q调用宏。但是 ctrl+q 部分不起作用。到目前为止我尝试了什么:
run, %A_Desktop%\test.xlsm, %A_Desktop%\
Send {Ctrl Down}{Q}{Ctrl Up}
这也不起作用:
run, %A_Desktop%\test.xlsm, %A_Desktop%\
Send ^{Q}
可能'send'速度太快,文件没有完全打开。在 'send'.
之前尝试“sleep”使用WinWait
等待window出现,WinActivate
和WinWaitActive
在向它发送任何命令之前:
; https://autohotkey.com/docs/commands/Run.htm#RunAs
; If the script is not elevated, relaunch as administrator and kill current instance
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
Run, %A_Desktop%\test.xlsm
WinWait, test.xlsm
WinActivate, test.xlsm
WinWaitActive, test.xlsm
Sleep, 300 ; if the program doesn't react immediately after activating
Send {Ctrl Down}q{Ctrl Up}
将 test.xlsm
替换为 window 的确切标题,如 Window 间谍中所示。