Sign in to follow this  
Followers 0
HaNdLoRdz

inputbox n timer

14 posts in this topic

hmm.,.,sorry im newbie here..want to askin something..

can i read data from GUICtrlRead($input1) to be minutes in timer???

example:

when i put 5 in my inputbox ,so program will read the data is "5" then they will convert it to Minutes (in case its 5 min / 300 sec)

anyone can help me out????

thx for helpin me out..

Share this post


Link to post
Share on other sites



hmm.,.,sorry im newbie here..want to askin something..

can i read data from GUICtrlRead($input1) to be minutes in timer???

example:

when i put 5 in my inputbox ,so program will read the data is "5" then they will convert it to Minutes (in case its 5 min / 300 sec)

anyone can help me out????

thx for helpin me out..

Yes you can. show us what you have and what is going wrong because what you described sound pretty close and only needs to be coded.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt("TrayOnEventMode", 1)
;Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("V.1.1", 237, 335, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

$Label1 = GUICtrlCreateLabel("Time : ", 8, 56, 36, 17)
$Label2 = GUICtrlCreateLabel("Post : ", 8, 98, 34, 17)

$input1 = GUICtrlCreateInput("", 48, 52, 41, 21)
guictrlsetstate($input1,$GUI_DISABLE)
$input2 = GUICtrlCreateInput("", 48, 95, 41, 21)
guictrlsetstate($input2,$GUI_DISABLE)

$Label3 = GUICtrlCreateLabel("Minute", 93, 56, 36, 17)
$Label4 = GUICtrlCreateLabel("Post", 93, 100, 36, 17)
$Label9 = GUICtrlCreateLabel("The Number is =  ", 10, 320, 200, 27)

$Settings = GUICtrlCreateGroup("Settings : ", 0, 32, 137, 89, -1, $WS_EX_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$OR = GUICtrlCreateLabel("OR", 58, 76, 22, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;;; radio
$Radio1 = GUICtrlCreateRadio("By Time", 0, 8, 57, 17)
$Radio2 = GUICtrlCreateRadio("By Post", 80, 8, 57, 17)

;;TOMBOL start
$Button1 = GUICtrlCreateButton("START", 4, 128, 129, 17)

;;tombol stop
$Button2 = GUICtrlCreateButton("STOP", 4, 152, 129, 17)

;tombol hide
$Button3 = GUICtrlCreateButton("Hide To Tray", 4, 176, 129, 17)


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    if $nmsg = -3 then Exit
    if $nmsg = $Radio1 then time()
    if $nmsg = $Radio2 then post()
    if $nmsg = $Button1 then Start()
        
WEnd

func Start()
    If GUICtrlRead($input1) <> "" Then bytime()
    sleep(20)
    If GUICtrlRead($input2) <> "" Then bypost()
EndFunc

func bytime()
msgbox(0,"","show message bytime : ")
endfunc

func bypost()
msgbox(0,"","show message bypost: ")
endfunc

func post()
    GUICtrlSetState($input2,$GUI_ENABLE)
    guictrlsetstate($input1,$GUI_DISABLE)
EndFunc

func time()
    GUICtrlSetState($input1,$GUI_ENABLE)
    guictrlsetstate($input2,$GUI_DISABLE)
EndFunc

func _quit()
    Exit
EndFunc

there's the code...

in my mind i just want to read Inputbox1 n then looping it with delay whose get from what i write in Inputbox1..

ex: when i write "5", the script will do the job until 5 minute later and then Stop...

thx for ur help

Edited by HaNdLoRdz

Share this post


Link to post
Share on other sites

there's the code...

in my mind i just want to read Inputbox1 n then looping it with delay whose get from what i write in Inputbox1..

ex: when i write "5", the script will do the job until 5 minute later and then Stop...

thx for ur help

So, you got most of it figured out and all you need to do is translate it into some code.

Look at TimerInit() and and Loop until TimerDiff() is greater or equal to GUICtrlRead($input1)*1000.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hello HaNdLoRdz,

There are a few different ways to achieve what you ask, Try this simple approach:

While 1
    $nMsg = GUIGetMsg()
    if $nmsg = -3 then Exit
    if $nmsg = $Radio1 then time()
    if $nmsg = $Radio2 then post()
    if $nmsg = $Button1 then Start()
    if $nmsg = $input1 Then
        $mins_to_pause = GUICtrlRead($input1) ;reads the value inputed
        $time_to_pause = ($mins_to_pause*60000) ;converts mins into milleseconds
        Sleep($time_to_pause)
    EndIf
WEnd

Realm


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

Hello HaNdLoRdz,

There are a few different ways to achieve what you ask, Try this simple approach:

While 1
    $nMsg = GUIGetMsg()
    if $nmsg = -3 then Exit
    if $nmsg = $Radio1 then time()
    if $nmsg = $Radio2 then post()
    if $nmsg = $Button1 then Start()
    if $nmsg = $input1 Then
        $mins_to_pause = GUICtrlRead($input1) ;reads the value inputed
        $time_to_pause = ($mins_to_pause*60000) ;converts mins into milleseconds
        Sleep($time_to_pause)
    EndIf
WEnd

Realm

hmm thx for help bro,

but i mean,not for sleep in "some" time, but to running the looping in a time...i.e: running the code in "X" minutes <--where "X" is i got from read from Inputbox.

sorry for my bad english..n thx 4 d help

Share this post


Link to post
Share on other sites

hmm thx for help bro,

but i mean,not for sleep in "some" time, but to running the looping in a time...i.e: running the code in "X" minutes <--where "X" is i got from read from Inputbox.

sorry for my bad english..n thx 4 d help

You should look at Jos' suggestion... TimerInit and TimerDiff can help you with that. If you want something to loop for 10 seconds, you could try something like:

$TimerInitStamp = TimerInit()

$counter = 0

While 1
    $counter += 1
    ConsoleWrite("Still looping! Nr: "&$counter&@CRLF)
    Sleep(100)

    ; Now the magic: use TimerDiff to see how much time (milliseconds!) has passed since the TimerInit on top of the script
    If TimerDiff($TimerInitStamp) > 10000  Then ExitLoop
    ; if timer difference was greater than 10000 milliseconds (10 seconds) then the While loop is exited and script continues below WEnd
WEnd

MsgBox(64,"test","All done looping!")

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

You should look at Jos' suggestion... TimerInit and TimerDiff can help you with that. If you want something to loop for 10 seconds, you could try something like:

$TimerInitStamp = TimerInit()

$counter = 0

While 1
    $counter += 1
    ConsoleWrite("Still looping! Nr: "&$counter&@CRLF)
    Sleep(100)

    ; Now the magic: use TimerDiff to see how much time (milliseconds!) has passed since the TimerInit on top of the script
    If TimerDiff($TimerInitStamp) > 10000  Then ExitLoop
    ; if timer difference was greater than 10000 milliseconds (10 seconds) then the While loop is exited and script continues below WEnd
WEnd

MsgBox(64,"test","All done looping!")

thx sadbunny for u n Jos suggested...

but the problem is...im too newbie here...lol n i cant mix in my code T_T too complicated for newbie like me.,.,

coz im still learning too run it clearly...

Share this post


Link to post
Share on other sites

thx sadbunny for u n Jos suggested...

but the problem is...im too newbie here...lol n i cant mix in my code T_T too complicated for newbie like me.,.,

coz im still learning too run it clearly...

If you wrote that code you posted yourself, you should be able to put this in here... Try doing $stamp = TimerInit() as soon as you start the job, and exit the job again when TimerDiff($stamp) ( = the difference in milliseconds between "Now" and the timestamp stored in $stamp) is greater than the number of milliseconds you want the job to last. That amount you can calculate using the content of that control, which you can read with GuiCtrlRead().


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

example code like i want in my mind (reading inputbox n convert to Second) :

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $Read1 = GUICtrlRead($Input1)
            $iTimer = TimerInit()
            $iSec = -1
            $iSecLast = -1
            Do
                $iSec = Int(TimerDiff($iTimer)/1000)
                If $iSec <> $iSecLast Then
                    $iSecLast = $iSec
                    GUICtrlSetData($Input2,$iSec)
                EndIf
            Until $iSec = $Read1 Or GUIGetMsg() = $Button2
    EndSwitch
WEnd

how i change or convert it to my code????

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>


Global $PAUSE 
HotKeySet("{PAUSE}", "Pause") 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("V.1.1", 137, 335, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

$Label1 = GUICtrlCreateLabel("Time : ", 8, 56, 36, 17)
$Label2 = GUICtrlCreateLabel("Post : ", 8, 98, 34, 17)

$input1 = GUICtrlCreateInput("", 48, 52, 41, 21)
guictrlsetstate($input1,$GUI_DISABLE)
$input2 = GUICtrlCreateInput("", 48, 95, 41, 21)
guictrlsetstate($input2,$GUI_DISABLE)

$Label3 = GUICtrlCreateLabel("Minute", 93, 56, 36, 17)
$Label4 = GUICtrlCreateLabel("Post", 93, 100, 36, 17)
$Label9 = GUICtrlCreateLabel("Waiting . . .  ", 10, 320, 200, 27)

$Settings = GUICtrlCreateGroup("Settings : ", 0, 32, 137, 89, -1, $WS_EX_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$OR = GUICtrlCreateLabel("OR", 58, 76, 22, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;;; radio
$Radio1 = GUICtrlCreateRadio("By Time", 0, 8, 57, 17)
$Radio2 = GUICtrlCreateRadio("By Post", 80, 8, 57, 17)

;;TOMBOL start
$Button1 = GUICtrlCreateButton("START", 4, 128, 129, 17)
GUICtrlSetOnEvent($Button1, "Start")
;;tombol stop
$Label5 = GUICtrlCreateLabel("---------", 4, 152, 129, 17)
GUICtrlSetOnEvent($Label5, "Pause")
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
;tombol hide
$Button3 = GUICtrlCreateButton("Pause IT", 4, 176, 129, 17)


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    switch $nmsg
    case $GUI_EVENT_CLOSE
        Exit
    ;if $nmsg = -3 then Exit
    case $radio1
        time()
    case $radio2
        post()
    case $Button1
        Start()
    ;Case $Input1
    
    EndSwitch
WEnd

Func Start()
    sleep(20)
    If GUICtrlRead($input1) <> "" Then bytime()
    sleep(20)
    If GUICtrlRead($input2) <> "" Then bypost()
EndFunc

func bytime()

Do
    ;;code looping job here
;sleep(2000);;;;<----sleep
Until $iSec = $Read1 Or GUIGetMsg() = Button3   ;;;;; i think the code is here to do in "X" sec????????????????
EndFunc
Edited by HaNdLoRdz

Share this post


Link to post
Share on other sites

func bytime()

Do
    ;;code looping job here
;sleep(2000);;;;<----sleep
Until $iSec = $Read1 Or GUIGetMsg() = Button3   ;;;;; i think the code is here to do in "X" sec????????????????
EndFunc

Try a loop like this:

Func bytime()
    $stamp = TimerInit()
    $minutesToWait = GUICtrlRead($input1)
    $msecToWait = $minutesToWait * 60 * 1000 ; minutes * 60 -> seconds, * 1000 -> msec
    Do
        ;;code looping job here
    Until $iSec = $Read1 Or GUIGetMsg() = Button3 Or TimerDiff($stamp) >= $msecToWait
EndFunc   ;==>bytime

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Try a loop like this:

Func bytime()
    $stamp = TimerInit()
    $minutesToWait = GUICtrlRead($input1)
    $msecToWait = $minutesToWait * 60 * 1000 ; minutes * 60 -> seconds, * 1000 -> msec
    Do
        ;;code looping job here
    Until $iSec = TimerDiff($stamp) >= $msecToWait ; Or GUIGetMsg() = Button3 Or TimerDiff($stamp) >= $msecToWait
EndFunc   ;==>bytime

thx for the help Sadbunny

hmm...i try it..but...the looping still running even the time that i was giving was end...

how to stop the looping???

Share this post


Link to post
Share on other sites

thx for the help Sadbunny

hmm...i try it..but...the looping still running even the time that i was giving was end...

how to stop the looping???

Works perfectly fine for me, once I correct the Until line to Until TimerDiff($stamp) >= $msecToWait :

bytime()

Exit

Func bytime()
    $stamp = TimerInit()
    $minutesToWait = 1
    $msecToWait = $minutesToWait * 60 * 1000 ; minutes * 60 -> seconds, * 1000 -> msec
    Do
        Sleep(50)
    Until TimerDiff($stamp) >= $msecToWait
EndFunc   ;==>bytime

I hardcoded the $minutesToWait to 1 for testing purposes. If this hardcoding test works for you too, then the problem is probably in the data you read from that control.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

oh ok SadBunny...thx for help.,.,its done now..hehehe..thx alot :graduated:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0