Jump to content

Time Picker


Ace08
 Share

Recommended Posts

Hi Guys,

Lately we've been extracting a bunch from our database so i thought why not make only one that can save queries instead of creating 1:1 apps and adding them on scheduled task, The problem is how do i make a time picker control(attached is a pic)? or rather, can this be done with autoit?

If it is possible kindly guide me with the functions to use.

Thank you in advance.

post-60325-0-20777700-1356484130_thumb.j

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

Ace08,

The following is in development but will give you something to build on. Start the script and select "Add New Event" from the tray menu.

#include <Date.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ListboxConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <EditConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>

Opt("MustDeclareVars", 1)
Opt("traymenumode", 1)

if not fileexists(@scriptdir & '\event.ini') then detail()

local $additem    =    TrayCreateItem('Add New Event')
local $list        =    TrayCreateItem('List Events')
local $exit        =    TrayCreateItem('Exit')
                    TrayCreateItem('')
local $help        =    TrayCreateItem('Help')
                    TraySetState()

while 1

    switch traygetmsg()
        case $exit
            Exit
        case $additem
            detail()
            trayitemsetstate($additem,4)
        case $list
            list()
        case $help
            help()
    endswitch

wend

func list()
EndFunc

func help()
endfunc

func detail()

    global  $Alarm        =     GUICreate("Event Add Dialog")
    global  $Asize        =    WinGetClientSize($Alarm)
                            guisetfont(9,800,default,'Courier New')
                            GUICtrlCreategroup("Date and Time",10,30,$Asize[0]-20,90)
                            guictrlsetfont(-1,12,800)
                            guictrlsetcolor(-1,0xaa0000)
                            guictrlcreatelabel('Start',40,60,50,20)
    global  $sdate         =     GUICtrlCreateDate(_now(), 90, 60, 100, 20, $WS_TABSTOP)
    global  $stime         =     GUICtrlCreateDate(@hour & ':' & @min & ':' & @sec, 245, 60, 110, 20, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP))
                            GUICtrlCreateLabel("End  ",40,80,50,20)
    global  $edate         =     GUICtrlCreateDate(_now(), 90, 80, 100, 20, $WS_TABSTOP)
    global  $etime         =     GUICtrlCreateDate(@hour & ':' & @min & ':' & @sec, 245, 80, 110, 20, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP))
                            GUICtrlCreategroup("Duration / Interval", 10, 120, $Asize[0]-20, 100)
                            guictrlsetfont(-1,12,800)
                            guictrlsetcolor(-1,0xaa0000)
                            guictrlcreatelabel('Hours',120,140,50,20)
                            guictrlcreatelabel('Minutes',180,140,50,20)
                            guictrlcreatelabel('Duration',40,160,70,15)
                            guictrlcreatelabel('Interval',40,185,70,15)
    global  $hdur         =     GUICtrlCreateInput("0", 120, 160, 40, 20)
    global  $udhdur      =     GUICtrlCreateUpdown($hdur)
                            guictrlsetlimit($udhdur,99,0)
    global  $mdur         =     GUICtrlCreateInput("0", 180, 160, 40, 20)
    global  $udmdur      =     GUICtrlCreateUpdown($mdur)
                            guictrlsetlimit($udmdur,99,0)
    global  $hint         =     GUICtrlCreateInput("0", 120, 185, 40, 20)
    global  $udhint      =     GUICtrlCreateUpdown($hint)
                            guictrlsetlimit($udhdur,99,0)
    global  $mint         =     GUICtrlCreateInput("0", 180, 185, 40, 20)
    global  $udmint      =     GUICtrlCreateUpdown($mint)
                            guictrlsetlimit($udmdur,99,0)
                            GUICtrlCreategroup("Do This...", 10, 220, $Asize[0]-20, 140)
                            guictrlsetfont(-1,12,800)
                            guictrlsetcolor(-1,0xaa0000)
    global  $chkAlarm     =    GUICtrlCreateCheckbox('Sound Alarm',40,250,100,20)
    global  $chkEmail    =    GUICtrlCreateCheckbox('Send Email',150,250,100,20)
    global  $chkdisp    =    GUICtrlCreateCheckbox('Display Message',250,250,130,20)
                            guictrlcreatelabel('Run ',40,270,150,20)
    global  $run        =    guictrlcreateinput('',40,290,320,20)
    global  $runsrch    =    guictrlcreatebutton('...',360,290,20,20)
                            guictrlsetfont(-1,9,800,default,'times new roman')
    global  $add        =    guictrlcreatebutton('Add Event',10,$Asize[1]-30,100,20)
    global  $list        =    guictrlcreatebutton('List Events',130,$Asize[1]-30,120,20)

                            GUISetState(@SW_SHOW)

    While 1

        switch guigetmsg()
            case $gui_event_close
                guidelete($Alarm)
                return
            case $runsrch
                detail_ini_run_filedialog()
            case $add
                detail_ini_add()
        Endswitch

    WEnd

endfunc

func detail_ini_run_filedialog()
    local $runFile = FileOpenDialog('Select file to execute',@scriptdir,'Files (*.*)',9)
    if @error then ConsoleWrite('filedialog error = ' & @error & @LF)
    guictrlsetdata($run,$runfile)
endfunc

func detail_ini_add()
    local $aSections     =     IniReadSectionNames(@ScriptDir & '\event.ini')
    if isarray($asections) then
        local $new_section    =    'Event' & stringformat('%02s',$aSections[0]+1)
    Else
        local $new_section  =   'Event01'
    EndIf

    local $adata[12][2]
    $adata[0][0]    =    'Start Date'
    $adata[0][1]    =    guictrlread($sdate)
    $adata[1][0]    =    'Start Time'
    $adata[1][1]    =    guictrlread($stime)
    $adata[2][0]    =    'End Date'
    $adata[2][1]    =    guictrlread($edate)
    $adata[3][0]    =    'End Time'
    $adata[3][1]    =    guictrlread($etime)
    $adata[4][0]    =    'Duration Hours'
    $adata[4][1]    =    guictrlread($hdur)
    $adata[5][0]    =    'Duration Minutes'
    $adata[5][1]    =    guictrlread($mdur)
    $adata[6][0]    =    'Interval Hours'
    $adata[6][1]    =    guictrlread($hint)
    $adata[7][0]    =    'Interval Minutes'
    $adata[7][1]    =    guictrlread($mint)
    $adata[8][0]    =    'Alarm Chk'
    $adata[8][1]    =   guictrlread($chkAlarm)
    $adata[9][0]    =    'Email Chk'
    $adata[9][1]    =    guictrlread($chkEmail)
    $adata[10][0]    =    'Display Chk'
    $adata[10][1]    =    guictrlread($chkdisp)
    $adata[11][0]    =    'Run Process'
    $adata[11][1]    =    guictrlread($run)
    ;_arraydisplay($adata)
    local $ret = IniwriteSection(@scriptdir & '\event.ini',$new_section,$adata,0)
    if $ret = 0 then ConsoleWrite('ini write error...@error = ' & @error & @LF)

endfunc


func alarm()


endfunc

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Thanks somdcomputerguy for the quick response have also do some research and found the needed function

#include <GuiDateTimePicker.au3>

_GUICtrlDTP_Create($hWnd, $iX, $iY [, $iWidth = 120 [, $iHeight = 21 [, $iStyle = 0x00000000 [, $iExStyle = 0x00000000]]]])

@kylomas

wow thanks for the sample script this will come in handy (almost look like the one im making >_<)

Work smarter not harder.My First Posted Script: DataBase

Link to comment
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
 Share

  • Recently Browsing   0 members

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