Jump to content

Recommended Posts

Posted

I'm having trouble setting the value in a Time Box in my GUI, and I'm pretty sure the problem is the format I'm using for the value. To facilitate debugging, here's a stripped down copy of my code.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$Test = GUICreate("Test", 140, 70, 1337, 226, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$StartDate = GUICtrlCreateDate("2006/01/01", 5, 5, 100, 25, $WS_TABSTOP)
GuiCtrlSendMsg(-1, 0x1005, 0, "MM/dd/yyyy")
$StartTime = GUICtrlCreateDate("14:00:00", 5, 35, 100, 25, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP))
GuiCtrlSendMsg(-1, 0x1005, 0, "HH:mm:ss")

$GoButton = GUICtrlCreateButton("Go", 110, 5, 25, 60, 0)
GUICtrlSetOnEvent(-1, "GetTime")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd
        
Func GetTime()
    $GUIStartDate = "2006/10/18"
    $GUIStartTime = "23:59:59"
    ConsoleWrite("Control Date : " & GuiCtrlRead($StartDate) &@CR)
    ConsoleWrite("Control Time : " & GuiCtrlRead($StartTime) &@CR)
    GUICtrlSetData($StartDate, $GUIStartDate)
    GUICtrlSetData($StartDate, $GUIStartTime)
    ConsoleWrite("GUI Start Date : " & $GUIStartDate&@CR)
    ConsoleWrite("GUI Start Time : " & $GUIStartTime&@CR)
    ConsoleWrite("Control Date : " & GuiCtrlRead($StartDate) &@CR)
    ConsoleWrite("Control Time : " & GuiCtrlRead($StartTime) &@CR)
EndFunc

Func CLOSEClicked()
  Exit
EndFunc
Posted

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$Test = GUICreate("Test", 140, 70, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$DTM_SETFORMAT = 0x1005
$StartDate = GUICtrlCreateDate("2006/01/01 14:00:00", 5, 5, 100, 25, $WS_TABSTOP)
$style = "MM/dd/yyyy HH:mm:s"
GUICtrlSendMsg($StartDate, $DTM_SETFORMAT, 0, $style)

$GoButton = GUICtrlCreateButton("Go", 110, 5, 25, 60, 0)
GUICtrlSetOnEvent(-1, "GetTime")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func GetTime()
    $GUIStartDate = "2006/10/18"
    $GUIStartTime = "23:59:59"
    ConsoleWrite("Control Date : " & GUICtrlRead($StartDate) & @CR)
    GUICtrlSetData($StartDate, $GUIStartDate & " " & $GUIStartTime)
    ConsoleWrite("GUI Start Date : " & $GUIStartDate & @CR)
    ConsoleWrite("GUI Start Time : " & $GUIStartTime & @CR)
    $date_time = StringSplit(GUICtrlRead($StartDate), " ")
    ConsoleWrite("Control Date : " & $date_time[1] & @CR)
    ConsoleWrite("Control Time : " & $date_time[2] & @CR)
EndFunc   ;==>GetTime

Func CLOSEClicked()
    Exit
EndFunc   ;==>CLOSEClicked

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

Actually its rather important that the date and time are seperated, which was why it was set up that way. Is there a way to set the information in just the time portion of the GUI?

Posted

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$Test = GUICreate("Test", 140, 70, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$DTM_SETFORMAT = 0x1005
$StartDate = GUICtrlCreateDate("2006/01/01", 5, 5, 100, 25, $WS_TABSTOP)
$style = "MM/dd/yyyy"
GUICtrlSendMsg($StartDate, $DTM_SETFORMAT, 0, $style)

$StartTime = GUICtrlCreateDate("14:00:00", 5, 35, 100, 25, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT, $WS_TABSTOP))
$style = "H:mm:ss"
GUICtrlSendMsg($StartTime, $DTM_SETFORMAT, 0, $style)

$GoButton = GUICtrlCreateButton("Go", 110, 5, 25, 60)
GUICtrlSetOnEvent(-1, "GetTime")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func GetTime()
    $GUIStartDate = "2006/10/18"
    $GUIStartTime = "2006/10/18 23:59:59"
    ConsoleWrite("Control Date : " & GUICtrlRead($StartDate) & @CR)
    ConsoleWrite("Control Time : " & GUICtrlRead($StartTime) & @CR)
    GUICtrlSetData($StartDate, $GUIStartDate)
    GUICtrlSetData($StartTime, $GUIStartTime)
    ConsoleWrite("GUI Start Date : " & $GUIStartDate & @CR)
    ConsoleWrite("GUI Start Time : " & $GUIStartTime & @CR)
    ConsoleWrite("Control Date : " & GUICtrlRead($StartDate) & @CR)
    ConsoleWrite("Control Time : " & GUICtrlRead($StartTime) & @CR)
EndFunc   ;==>GetTime

Func CLOSEClicked()
    Exit
EndFunc   ;==>CLOSEClicked

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

  • 2 months later...
Posted

Thanks a lot gafrost,

your code was also very helpful for me.

Just one question left. How did you manage to display $StartTime in 24h format, even if windows regional options are set to 12h format. I was looking for that, your script does it, but I don't understand how it's done.

Could you please explain?

Posted

Thanks a lot gafrost,

your code was also very helpful for me.

Just one question left. How did you manage to display $StartTime in 24h format, even if windows regional options are set to 12h format. I was looking for that, your script does it, but I don't understand how it's done.

Could you please explain?

$style = "H:mm:ss"
GUICtrlSendMsg($StartTime, $DTM_SETFORMAT, 0, $style)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...