Jump to content
Sign in to follow this  
Alexxander

msgbox when clock time = specified time

Recommended Posts

Alexxander

hi all

what i'm trying to accomplish is a small script that give a msgbox when the clock time equals the time the user provide in the GUI

but it won't work until the user press the button

here is what i tried 

#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <date.au3>


    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate("", 10, 10, 185, 20)
    $button = GUICtrlCreateButton("", 50, 50, 100, 50)

    ; to select a specific default format
    $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
    $style = "M/d/yyyy hh:mm:ss tt"
    GUICtrlSendMsg($date, $DTM_SETFORMAT_, 0, $style)

    GUISetState()

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    if $nMsg = $button then but()
WEnd

func but()
    do
    Sleep (1000)
    Until _Now() = GUICtrlRead($date)
    MsgBox(0, "", "matched")
EndFunc

any ideas why this wont work for me ?


Share this post


Link to post
Share on other sites
Melba23

alexander95,

 

any ideas why this wont work for me ?

Yes. Try adding these 2 lines and see if you can see it as well: ;)

func but()

    ConsoleWrite(GUICtrlRead($date) & @CRLF)
    ConsoleWrite(_Now() & @CRLF)

    do
    Sleep (1000)
    Until _Now() = GUICtrlRead($date)
    MsgBox(0, "", "matched")
EndFunc
Did the light bulb illuminate? :)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Alexxander

alexander95,

 

Yes. Try adding these 2 lines and see if you can see it as well: ;)

func but()

    ConsoleWrite(GUICtrlRead($date) & @CRLF)
    ConsoleWrite(_Now() & @CRLF)

    do
    Sleep (1000)
    Until _Now() = GUICtrlRead($date)
    MsgBox(0, "", "matched")
EndFunc
Did the light bulb illuminate? :)

M23

 

 

thank you bro

i'm so idiot 

i hope i'm not reducing this forum level


Share this post


Link to post
Share on other sites
Melba23

alexander95,

Rather than feeling sorry for yourself, learn from the above and try some basic errorchecking yourself before posting next time. For example, if you have a comparison that is not working, make sure that you are comparing things which are alike - if a file operation does not work, check the path that you are passing to it. etc, etc. :)

It is experience that suggests where to look to find problems - so build up your own experience level, simple really. ;)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
michaelslamet

This is work as expected for your project:

#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <date.au3>


    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate("", 10, 10, 185, 20)
    $button = GUICtrlCreateButton("", 50, 50, 100, 50)

    ; to select a specific default format
    $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
    $style = "yyyy/MM/d HH:mm:ss"
    GUICtrlSendMsg($date, $DTM_SETFORMAT_, 0, $style)

    GUISetState()

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    if $nMsg = $button then but()
WEnd

func but()
    do
        Sleep (1000)
    Until _DateDiff("s", _NowCalc(), GUICtrlRead($date)) <= 0
    MsgBox(0, "", "matched")
EndFunc

 

See Melba's explanation :)

Share this post


Link to post
Share on other sites
NewPlaza

I would change these two lines of code.

$style = "M/d/yyyy hh:mm:ss tt"

to

$style = "M/d/yyyy h:mm:ss tt"

and

Until _Now() = GUICtrlRead($date)

to

Until _Now() > GUICtrlRead($date)
#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <date.au3>


    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate("", 10, 10, 185, 20)
    $button = GUICtrlCreateButton("START", 50, 50, 100, 50)

    ; to select a specific default format
    $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
    $style = "M/d/yyyy h:mm:ss tt"
    GUICtrlSendMsg($date, $DTM_SETFORMAT_, 0, $style)

    GUISetState()

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    if $nMsg = $button then but()
WEnd

func but()
    GUICtrlSetState($button, $GUI_DISABLE)
    do
    Sleep (1000)
    Until _Now() > GUICtrlRead($date)
    MsgBox(0, "", "matched")
EndFunc

EDIT: Added code

Edited by NewPlaza

Share this post


Link to post
Share on other sites
Alexxander

I would change these two lines of code.

$style = "M/d/yyyy hh:mm:ss tt"

to

$style = "M/d/yyyy h:mm:ss tt"

and

Until _Now() = GUICtrlRead($date)

to

Until _Now() > GUICtrlRead($date)
#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <date.au3>


    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate("", 10, 10, 185, 20)
    $button = GUICtrlCreateButton("START", 50, 50, 100, 50)

    ; to select a specific default format
    $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
    $style = "M/d/yyyy h:mm:ss tt"
    GUICtrlSendMsg($date, $DTM_SETFORMAT_, 0, $style)

    GUISetState()

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    if $nMsg = $button then but()
WEnd

func but()
    GUICtrlSetState($button, $GUI_DISABLE)
    do
    Sleep (1000)
    Until _Now() > GUICtrlRead($date)
    MsgBox(0, "", "matched")
EndFunc

EDIT: Added code

 

what is the difference in = and < in this case ?


Share this post


Link to post
Share on other sites
Melba23

alexander95,

When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - we know what we wrote immediately above your post and it just pads the thread unneccessarily. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×