部分script没办法运行

遇到了问题?请先进行搜索(中文和英文),然后在此提问

Moderators: tmplinshi, arcticir

haomingchen1998
Posts: 176
Joined: 20 Feb 2023, 16:37

部分script没办法运行

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
WKen
Posts: 187
Joined: 21 Feb 2023, 00:01

Re: 部分script没办法运行

07 May 2023, 04:44

切换到标题为Macrium Reflect的窗口,除了关闭屏幕不起作用,在Windows 11,文件操作和msgbox正常。

Return to “请求帮助”

Who is online

Users browsing this forum: No registered users and 3 guests