Jump to content
Sign in to follow this  
Riz

_NowDate help

Recommended Posts

Riz

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
Xenobiologist

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
Riz

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
randallc

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.