Sign in to follow this  
Followers 0
Riz

_NowDate help

5 posts in this topic

I have got one button and input box, when the button pressed input box should get the today date and time, that date should remain when the script stops, until next pressed.

Any suggestion and advice is appreciated

this is my simple code

#include <GuiConstants.au3>
#Include <date.au3>

GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("Input1", 70, 100, 140, 30)
$Button_2 = GuiCtrlCreateButton("Button2", 230, 100, 70, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $Button_2
        GUICtrlSetData($Input_1, GUICtrlRead(_NowDate()))
    Case Else
    ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

change the line to GUICtrlSetData($Input_1, _NowDate())

or to this to get the time, too GUICtrlSetData($Input_1, _NowDate())

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

change the line to GUICtrlSetData($Input_1, _NowDate())

or to this to get the time, too GUICtrlSetData($Input_1, _NowDate())

So long,

Mega

Thanks for your help. but is that bossible the time remain when the GUI close?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

Save it when you click?

;DateSave.au3
#include <GuiConstants.au3>
#Include <date.au3>
GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Input_1 = GuiCtrlCreateInput("Input1", 70, 100, 140, 30)
$Button_2 = GuiCtrlCreateButton("Button2", 230, 100, 70, 30)
if FileExists(@ScriptDir&"\DateSaver.txt") then GUICtrlSetData($Input_1, FileReadLine(@ScriptDir&"\DateSaver.txt",1))
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $Button_2
        FileDelete(@ScriptDir&"\DateSaver.txt")
        FileWrite(@ScriptDir&"\DateSaver.txt",_Now())
        GUICtrlSetData($Input_1, _Now())
    Case Else
    ;;;
    EndSelect
WEnd
Exit
Randallc

[EDIT: added "FileDelete(@ScriptDir&"\DateSaver.txt")"]

Edited by randallc

Share this post


Link to post
Share on other sites

Thanks mate. That is great :D:wacko:

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