Sleep

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Sleep

Re: Sleep

Post by amnesiac » 29 Jan 2016, 06:51

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
保持时间变量与SE的长度相同,这样就没问题了。可以先获取S的长度取时间变量,就行了。

Re: Sleep

Post by garry » 13 Dec 2015, 08:01

need brackets , if you have more then ONE line after if ... else
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
I think after 'else' in your example needs brackets

Code: Select all

;....  
Else
  {
  ;--   ( maybe use errorlevel if backup.exe exist / see above )
  ;SendInput {}   ;- (?)
  Sleep, 6000
  Process, Close, Backup.exe
  Return
  }
return  

Re: Sleep

Post by Marcosa1020 » 12 Dec 2015, 20:32

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

Re: Sleep

Post by garry » 12 Dec 2015, 16:37

sorry, I didn't understand the script
tmplinshi or other users can help

Re: Sleep

Post by Marcosa1020 » 11 Dec 2015, 18:35

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

Re: Sleep

Post by garry » 11 Dec 2015, 03:00

about date

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
brackets { } missing

Code: Select all

;........
If Now > CDate(S) And Now < CDate(E)
 {
 Sleep, 6000
 Process, Close, Backup.exe
 }
Return

Sleep

Post by Marcosa1020 » 11 Dec 2015, 00:55

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

Top