Hi,
下面有一段請各位前輩們指教,當我按下ButtonSTOP時,照理應該是過6秒後關閉backup。
但是實際上是直接關閉Backup.exe,沒有經過六秒,請問是哪裡寫錯呢?
謝謝。
ButtonSTOP:
WinActivate, ahk_id %k_ID%
Clipboard = STOP
SendInput STOP
S = "2015/10/10"
E = "2015/12/30"
If Now > CDate(S) And Now < CDate(E)
Sleep, 6000
Process, Close, Backup.exe
Return
Sleep
Moderators: tmplinshi, arcticir
-
- Posts: 168
- Joined: 23 Sep 2015, 19:15
Re: Sleep
about date
brackets { } missing
Code: Select all
S := 20151010
E := 20151231
stringmid,now,a_now,1,8
now:=now
If (Now >=S AND Now<=E)
msgbox, %now%-date is between`n %s% and %e%
else
msgbox,%now%-date is NOT between`n %s% and %e%
return
Code: Select all
;........
If Now > CDate(S) And Now < CDate(E)
{
Sleep, 6000
Process, Close, Backup.exe
}
Return
-
- Posts: 168
- Joined: 23 Sep 2015, 19:15
Re: Sleep
Hi Garry,
經測試下列寫法會變成按下STOP之後無法刪除Backup, 我是否漏了什麼? 請指教。
ButtonSTOP:
WinActivate, ahk_id %k_ID%
Clipboard = STOP
SendInput STOP
S = "2015/10/10"
E = "2015/12/30"
If Now > CDate(S) And Now < CDate(E)
{
Sleep, 6000
Process, Close, Backup.exe
}
Return
經測試下列寫法會變成按下STOP之後無法刪除Backup, 我是否漏了什麼? 請指教。
ButtonSTOP:
WinActivate, ahk_id %k_ID%
Clipboard = STOP
SendInput STOP
S = "2015/10/10"
E = "2015/12/30"
If Now > CDate(S) And Now < CDate(E)
{
Sleep, 6000
Process, Close, Backup.exe
}
Return
Re: Sleep
sorry, I didn't understand the script
tmplinshi or other users can help
tmplinshi or other users can help
-
- Posts: 168
- Joined: 23 Sep 2015, 19:15
Re: Sleep
Hi Garry,
Thank you so much.
Dears,
如果寫成以下這樣是可以在六秒後關閉程式,但如果加上HHSS就無法使用。
經測試後無法使用:
ButtonSTOP:
WinActivate, ahk_id %k_ID%
S := 20151008101010
E := 20151230101010
stringmid,now,a_now,1,8
now:=now
If (Now >=S AND Now<=E)
SendInput STOP
Else
SendInput {}
Sleep, 6000
Process, Close, Backup.exe
Return
經測試後可以使用:
ButtonSTOP:
WinActivate, ahk_id %k_ID%
S := 20151008
E := 20151213
stringmid,now,a_now,1,8
now:=now
If (Now >=S AND Now<=E)
SendInput STOP
Else
SendInput {}
Sleep, 6000
Process, Close, Backup.exe
Return
Thank you so much.
Dears,
如果寫成以下這樣是可以在六秒後關閉程式,但如果加上HHSS就無法使用。
經測試後無法使用:
ButtonSTOP:
WinActivate, ahk_id %k_ID%
S := 20151008101010
E := 20151230101010
stringmid,now,a_now,1,8
now:=now
If (Now >=S AND Now<=E)
SendInput STOP
Else
SendInput {}
Sleep, 6000
Process, Close, Backup.exe
Return
經測試後可以使用:
ButtonSTOP:
WinActivate, ahk_id %k_ID%
S := 20151008
E := 20151213
stringmid,now,a_now,1,8
now:=now
If (Now >=S AND Now<=E)
SendInput STOP
Else
SendInput {}
Sleep, 6000
Process, Close, Backup.exe
Return
Re: Sleep
need brackets , if you have more then ONE line after if ... else
example :
I think after 'else' in your example needs brackets
example :
Code: Select all
pr=calc.exe
run,%pr%
sleep,2000 ; maybe see ifwinexist / IfWinNotActive / WinActivate / WinWaitActive
Process, Exist, %pr%
if (ErrorLevel <> 0)
{
sleep,5000
Process, Close, %pr% ; - close calc.exe after 5 seconds
}
else
msgbox,%pr% not active
return
Code: Select all
;....
Else
{
;-- ( maybe use errorlevel if backup.exe exist / see above )
;SendInput {} ;- (?)
Sleep, 6000
Process, Close, Backup.exe
Return
}
return
Re: Sleep
保持时间变量与S和E的长度相同,这样就没问题了。可以先获取S的长度取时间变量,就行了。Marcosa1020 wrote: 如果寫成以下這樣是可以在六秒後關閉程式,但如果加上HHSS就無法使用。
經測試後無法使用:
ButtonSTOP:
WinActivate, ahk_id %k_ID%
S := 20151008101010
E := 20151230101010
stringmid,now,a_now,1,8
now:=now
If (Now >=S AND Now<=E)
SendInput STOP
Else
SendInput {}
Sleep, 6000
Process, Close, Backup.exe
Return
Who is online
Users browsing this forum: No registered users and 11 guests