Global $SlepSec = 10 ;設定預設延遲秒數(顯示訊息視窗的間隔秒數)
Global $scrFilePath = @WindowsDir & "\" ;設定檔案位置
Global $AppDelayTime = 1000 ;設定檔檢查頻率,預設是1000毫秒,改太短CPU會占滿
Global $iniFilePath = @ScriptDir & "\SET.dll" ;設定檔的位置,不推薦改,用筆記本開啟,然後寫秒數
Global $WAVFilePath = @ScriptDir & "\yobi.wav" ;音效檔名稱
;抓取 SET.dll 檔設定
If FileExists ( $iniFilePath ) Then
FileOpen($iniFilePath,0)
Local $FileContentSec = FileReadLine($iniFilePath,1)
Local $IsDigiStr = StringIsDigit ($FileContentSec)
If $IsDigiStr = 1 Then
$SlepSec = $FileContentSec
Else
MsgBox (64,"設定錯誤訊息", "偵測到設定檔設定的秒數,不是數字:" & $FileContentSec )
endapp()
EndIf
FileClose($iniFilePath)
EndIf
Global $SlepTime = $SlepSec * 1000
Global $iflag = 1
;循環偵測視窗
While $iflag = 1
Sleep ($AppDelayTime) ;檢查時間間隔
Local $iIdleTime = _Timer_GetIdleTime() ;抓取閒置時間
If $iIdleTime >= $SlepTime Then ;當閒置時間大於設定的時間才啟動
Local $sString = WinGetTitle("[ACTIVE]")
Local $sQuery = "*YouTube*"
Local $sPattern = StringRegExpReplace($sQuery, "[\W]", "\\$0") ; Ignore special character meanings
$sPattern = "(?i)(" & StringReplace($sPattern, "\*", ".*") & ")" ; Dot in the pattern signifies any characters may appear.
If StringRegExp($sString, $sPattern) Then
If FileExists ( $WAVFilePath ) Then
SoundPlay ( $WAVFilePath )
EndIf
MsgBox ($MB_TOPMOST , "提示標題", "正在使用「YouTube」" & @CRLF & "提示訊息2!" , 3) ;訊息盒顯示秒數