部分script没办法运行
Posted: 03 May 2023, 14:40
FileCopy之后的line都在 ActiveTitle = "Macrium Reflect"出现后停止工作了. 我想让我的屏幕在文件传输的时候关掉, 传输完成后再开启, 给我msgbox 确认关机. 但是ActiveTitle = "Macrium Reflect" 出现后, 不止5秒内不关闭屏幕, msgbox也不显示了. 完全找不到问题在哪里, 求助, 谢了!
Code: Select all
; Wait till Window Title found
#Persistent
SetTimer, WaitForText, 100
return
WaitForText:
WinGetActiveTitle, ActiveTitle
TrayTip, active title, %ActiveTitle%, 3
If (ActiveTitle = "Macrium Reflect") ; change this to match the title of the confirmation message box
{
SetTimer, WaitForText, Off
Loop, Files, D:\*.*, F
{
FormatTime, CurrentDateTime,, MM-dd-yyyy
; Rename files in D drive with date as prefix
FileMove, % A_LoopFileFullPath, % "D:\" CurrentDateTime "_" A_LoopFileName
; Copy those files to V drive
FileCopy, % "D:\" CurrentDateTime "_" A_LoopFileName, % "V:\Backup\" CurrentDateTime "_" A_LoopFileName
}
;-----------------------------------------------------------------------------------------------------------
; EVERYTHING BELOW STOPPED WORKING after ActiveTitle = "Macrium Reflect"
; trying to turn on screen after file transfer is completed
SetTimer IdleChk, Off
Sleep, 5000
SendMessage, 0x112, 0xF170, -1, , Program Manager
Sleep, 2000
Send, {1}
Sleep, 2000
; trying to shutdown pc with msgbox
Secs := 10
SetTimer, CountDown, 1000
MsgBox, 4, System Shutdown, Shutdown in %Secs%?, %Secs%
SetTimer, CountDown, Off
IfMsgBox, No
WinClose,Back up.ahk ahk_exe AutoHotkey.exe
IfMsgBox Timeout
Shutdown, 1
IfMsgBox Yes
Shutdown, 1
CountDown:
Secs -= 1
ControlSetText,Static1,Allow Auto Shutdown in %Secs%?,System Shutdown ahk_class #32770
return
}
; 3. Checks every 3 sec, if idle for more than 3 sec, turn off monitor
SetTimer IdleChk,3000
IdleChk:
if (A_TimeIdlePhysical > 3000)
SendMessage 0x112, 0xF170, 2,,Program Manager
RETURN