Sign in to follow this  
Followers 0
klikyuk

Auto input the date into a table

5 posts in this topic

Hi Guys, Quite new to autoit scripts and I have a little problem. I had a script coded through Vcoder that creates a simple database using a table. (The girl who did this script hasn't answered my emails to her) The code for a new window is detailed below.

Is there any way that the current can be inserted into the window (input box) so it can be saved to the database

Many thanks

Tim

Func NewWin()

$NewForm = GUICreate("Add a new Prospect Record", 550, 350, -1, -1,Default, Default, WinGetHandle(AutoItWinGetTitle()))

$NLabel1 = GUICtrlCreateLabel("Title", 20, 10, 40)

$NLabel2 = GUICtrlCreateLabel("First Name", 20, 40, 60)

$NLabel3 = GUICtrlCreateLabel("Last Name", 20, 70, 60)

$NLabel4 = GUICtrlCreateLabel("Email address", 20, 100, 80)

$NLabel5 = GUICtrlCreateLabel("Notes", 20, 130, 40)

$NLabel6 = GUICtrlCreateLabel("Group", 20, 160, 30)

$NLabel7 = GUICtrlCreateLabel("Data Source", 20, 190, 60)

$NLabel8 = GUICtrlCreateLabel("Entry Date", 20, 220, 60)

$NLabel9 = GUICtrlCreateLabel("N-A", 20, 250, 30)

$NLabe20 = GUICtrlCreateLabel("N-A", 20, 280, 30)

; #include <Date.au3> This reference has been put at the top of the script

GUISetFont(11)

$NInput1 = GUICtrlCreateInput("", 130, 10, 70, 22)

$NInput2 = GUICtrlCreateInput("", 130, 40, 160, 22)

$NInput3 = GUICtrlCreateInput("", 130, 70, 160, 22)

$NInput4 = GUICtrlCreateInput("", 130, 100, 350, 22)

$NInput5 = GUICtrlCreateInput("", 130, 130, 350, 22)

$NInput6 = GUICtrlCreateInput("", 130, 160, 250, 22)

$NInput7 = GUICtrlCreateInput("", 130, 190, 160, 22)

$NInput8 = GUICtrlCreateInput("&@hour&@min&@sec&", 130, 220, 160, 22)

; it's here where I want to insert the current date?

$NInput9 = GUICtrlCreateInput("", 130, 250, 160, 22)

$NInput10 = GUICtrlCreateInput("", 130, 280, 160, 22)

$NButton4 = GUICtrlCreateButton("Save", 400, 260, 100)

GUISetState(@SW_SHOW)

While 1

$_msg = GUIGetMsg(1)

Select

;Check if user clicked on a close button of any of the 2 windows

Case $_msg[0] = $GUI_EVENT_CLOSE

;Check if user clicked on the close button of the child window

If $_msg[1] = $ViewForm Then

GUICtrlSetState($View, $GUI_ENABLE)

GUICtrlSetState($New, $GUI_ENABLE)

;Switch to the child window

GUISwitch($hGUI)

;Destroy the child GUI including the controls

GUIDelete($ViewForm)

;Check if user clicked on the close button of the parent window

ElseIf $_msg[1] = $hGUI Then

;Switch to the parent window

GUISwitch($hGUI)

;Destroy the parent GUI including the controls

GUIDelete()

;Exit the script

Exit

ElseIf $_msg[1] = $NewForm Then

GUICtrlSetState($View, $GUI_ENABLE)

GUICtrlSetState($New, $GUI_ENABLE)

;Switch to the child window

GUISwitch($hGUI)

;Destroy the child GUI including the controls

GUIDelete($NewForm)

;Check if user clicked on the close button of the parent window

Endif

Case $_msg[0] = $View

GUICtrlSetState($View, $GUI_DISABLE)

GUICtrlSetState($New, $GUI_DISABLE)

EditWin()

Case $_msg[0] = $New

GUICtrlSetState($View, $GUI_DISABLE)

GUICtrlSetState($New, $GUI_DISABLE)

NewWin()

Case $_msg[0] = $Del

DeleteItem()

Case $_msg[0] = $NButton4

_GUICtrlListView_AddItem($hListView, GUICtrlRead($NInput1), 0)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput2), 1)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput3), 2)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput4), 3)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput5), 4)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput6), 5)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput7), 6)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput8), 7)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput9), 8)

_GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput10), 9)

; _GUICtrlListView_AddSubItem($hListView, $c, GUICtrlRead($NInput11), 10)

$c = $c + 1

$file = FileOpen("C:\Program Files\TBC-DB\DBaseList.txt", 1)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Error Saving The File!")

Exit

EndIf

$_NewRec = GUICtrlRead($NInput1) & "," & GUICtrlRead($NInput2) & "," & GUICtrlRead($NInput3) & "," & GUICtrlRead($NInput4) & "," & GUICtrlRead($NInput5) & "," & _

GUICtrlRead($NInput6) & "," & GUICtrlRead($NInput7) & "," & GUICtrlRead($NInput8) & "," & GUICtrlRead($NInput9)

FileWriteLine($file, $_NewRec)

FileClose($file)

$Recordnumber = $Recordnumber + 1

; MsgBox(0,"Notice", "Sucessfuly Saved one Record")

GUICtrlSetState($View, $GUI_ENABLE)

GUICtrlSetState($New, $GUI_ENABLE)

GUIDelete($NewForm)

EndSelect

Wend

EndFunc

Share this post


Link to post
Share on other sites



klikyuk,

Welcome to the AutoIt forum. :unsure:

When you post code in future, please use Code tags. Put [autoit] before and [/autoit] after your posted code.

If you want to put the current date into an input you can use the date macros:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hInput = GUICtrlCreateInput(@MDAY & "/" & @MON & "/" & @YEAR, 10, 10, 200, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

All clear? Please ask if not. :>

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

Hi Melba, Thanks for that code, I will have a go at including it in the script as I am not to sure where it should go. The include statement goes at the top with the others I guess.

I will remember to use Autoit above and below my code if I get stuck again..

many thanks

Tim

Share this post


Link to post
Share on other sites

Brilliant Melba, Thanks for your help..

Share this post


Link to post
Share on other sites

klikyuk,

You had this in your code:

$NInput8 = GUICtrlCreateInput("&@hour&@min&@sec&", 130, 220, 160, 22)
; it's here where I want to insert the current date?

Just replace "&@hour&@min&@sec&" (which is garbage) with "@MDAY & "/" & @MON & "/" & @YEAR". :unsure:

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  
Followers 0