|
|
Author |
Message |
the_pillo The Magnificent
 Group: Verified Member Joined: 09 Jul 2009 Donor:  Posts: 1105 Gold: 0.00 Clan: Honor

Status: Warn:  Reputation: 32
|
#1 Posted: 11 May 2010 05:41 pm Post subject: hopefully simple autoit question |
|
|
Ok, i want a sleep timer countdown... like say i want something to sleep for 14000000 ms...
i havent tried it yet but is there a simpler way other than something along the lines of:
Code: |
$sleep = 14000000
do
sleep(1)
$time = $sleep - 1
tooltip ("Sleep Countdown : " & $time & "")
untill $time = 0
|
EDIT:
i tested that code and it doesnt countdown, by all technical means it should right? (and yes i fixed typos first)
Last edited by the_pillo on 11 May 2010 05:55 pm; edited 1 time in total _____________________
Happiness is a disease, and smiling is the cough that spreads it - pillo-
"When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." |
|
Back to top |
|
 |
Cinemax
 Group: Members Joined: 05 Jul 2008 Donor:  Posts: 8361 Gold: 12885.33 Clan: HoD II

Status: Warn:  Reputation: 116
|
#2 Posted: 12 May 2010 01:21 am Post subject: Re: hopefully simple autoit question |
|
|
the_pillo wrote: | Ok, i want a sleep timer countdown... like say i want something to sleep for 14000000 ms...
i havent tried it yet but is there a simpler way other than something along the lines of:
Code: |
$sleep = 14000000
do
sleep(1)
$time = $sleep - 1
tooltip ("Sleep Countdown : " & $time & "")
untill $time = 0
|
EDIT:
i tested that code and it doesnt countdown, by all technical means it should right? (and yes i fixed typos first) |
countdown
{
local OLD_IFS="${IFS}"
IFS=":"
local ARR=( $1 )
local SECONDS=$(( (ARR[0] * 60 * 60) + (ARR[1] * 60) + ARR[2] ))
local START=$(date +%s)
local END=$((START + SECONDS))
local CUR=$START
while [[ $CUR -lt $END ]]
do
CUR=$(date +%s)
LEFT=$((END-CUR))
printf "\r%02d:%02d:%02d" \
$((LEFT/3600)) $(( (LEFT/60)%60)) $((LEFT%60))
sleep 1
done
IFS="${OLD_IFS}"
echo " "
}
countdown "00:07:55"
Or Try this.
countdown()
(
IFS=:
set -- $*
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} ))
while [ $secs -gt 0 ]
do
sleep 1 &
printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60))
secs=$(( $secs - 1 ))
wait
done
echo
) _____________________
|
|
Back to top |
|
 |
|
 |
the_pillo The Magnificent
 Group: Verified Member Joined: 09 Jul 2009 Donor:  Posts: 1105 Gold: 0.00 Clan: Honor

Status: Warn:  Reputation: 32
|
#3 Posted: 12 May 2010 01:30 am Post subject: Re: hopefully simple autoit question |
|
|
Cinemax wrote: | the_pillo wrote: | Ok, i want a sleep timer countdown... like say i want something to sleep for 14000000 ms...
i havent tried it yet but is there a simpler way other than something along the lines of:
Code: |
$sleep = 14000000
do
sleep(1)
$time = $sleep - 1
tooltip ("Sleep Countdown : " & $time & "")
untill $time = 0
|
EDIT:
i tested that code and it doesnt countdown, by all technical means it should right? (and yes i fixed typos first) |
countdown
{
local OLD_IFS="${IFS}"
IFS=":"
local ARR=( $1 )
local SECONDS=$(( (ARR[0] * 60 * 60) + (ARR[1] * 60) + ARR[2] ))
local START=$(date +%s)
local END=$((START + SECONDS))
local CUR=$START
while [[ $CUR -lt $END ]]
do
CUR=$(date +%s)
LEFT=$((END-CUR))
printf "\r%02d:%02d:%02d" \
$((LEFT/3600)) $(( (LEFT/60)%60)) $((LEFT%60))
sleep 1
done
IFS="${OLD_IFS}"
echo " "
}
countdown "00:07:55"
Or Try this.
countdown()
(
IFS=:
set -- $*
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} ))
while [ $secs -gt 0 ]
do
sleep 1 &
printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60))
secs=$(( $secs - 1 ))
wait
done
echo
) |
wow mi amigo, looks like C or something lol
i actually got it and was just about to post what i did to get it.. it was completly syntax failure on my part
I had the variable wrong it should look like this
Code: |
$sleep = 14000000
do
sleep(1000)
$sleep = $sleep - 1
tooltip("Sleep Countdown: " & $sleep & "")
until $sleep = 0
|
My issue was during the $sleep = $sleep - 1 i was trying to add in another variable and it was messing it up somewhere.. This does exactly what i need. Thank you for the effort, mi amigo. Thats crazy code though, i can read and interpret some of it but wow lol, i get lost in some areas. _____________________
Happiness is a disease, and smiling is the cough that spreads it - pillo-
"When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
D3jsp is proudly powered by phpBB © 2.0 Theme and Forum by tramway
|