Jump to content

System Clock Thai


newsak2005
 Share

Recommended Posts

Include file name: SystemDateThai.au3

#include-once
#cs====start discription=====
Create date: 7/24/2011
File type: Library include
File name: SystemDateThai.au3
Syntax: _SystemDateThaiEx()
Design by: sak2005
#ce====end discription=======
Global $Tweek, $wday
Func _DaysOfWeekTha()
    $Tweek = @WDAY
    Switch $Tweek
        Case 1
            $wday = 'อาทิตย์'
        Case 2
            $wday = 'จันทร์'
        Case 3
            $wday = 'อังคาร'
        Case 4
            $wday = 'พุธ'
        Case 5
            $wday = 'พฤหัส'
        Case 6
            $wday = 'ศุกร์'
        Case 7
            $wday = 'เสาร์'
    EndSwitch
        If (@error) Then Return SetError(1, 0, 0)
        Return $wday
EndFunc
;----------------------------------------------------
Global $Tday, $mday
Func _DaysOfMonthTha()
    $Tday = @MDAY
    Switch $Tday
        Case 01
            $mday = 1
        Case 02
            $mday = 2
        Case 03
            $mday = 3
        Case 04
            $mday = 4
        Case 05
            $mday = 5
        Case 06
            $mday = 6
        Case 07
            $mday = 7
        Case 08
            $mday = 8
        Case 09
            $mday = 9
        Case Else
            $mday = $Tday
    EndSwitch
        If (@error) Then Return SetError(1, 0, 0)
        Return $mday
EndFunc
;----------------------------------------------------
Global $Tmonth, $month
Func _MonthsOfYearTha()
    $Tmonth = @MON
    Switch $Tmonth
        Case 01
            $month = 'มกราคม'
        Case 02
            $month = 'กุมภาพันธ์'
        Case 03
            $month = 'มีนาคม'
        Case 04
            $month = 'เมษายน'
        Case 05
            $month = 'พฤษภาคม'
        Case 06
            $month = 'มิถุนายน'
        Case 07
            $month = 'กรกฎาคม'
        Case 08
            $month = 'สิงหาคม'
        Case 09
            $month = 'กันยายน'
        Case 10
            $month = 'ตุลาคม'
        Case 11
            $month = 'พฤษจิกายน'
        Case 12
            $month = 'ธันวาคม'
    EndSwitch
        If (@error) Then Return SetError(1, 0, 0)
        Return $month
EndFunc
;----------------------------------------------------
Global $Tyear, $year
Func _YearOfTenYearsTha()
    $Tyear = @YEAR
    Switch $Tyear
        Case 2011
            $year = 2554
        Case 2012
            $year = 2555
        Case 2013
            $year = 2556
        Case 2014
            $year = 2557
        Case 2015
            $year = 2558
        Case 2016
            $year = 2559
        Case 2017
            $year = 2560
        Case 2018
            $year = 2561
        Case 2019
            $year = 2562
        Case 2020
            $year = 2563
    EndSwitch
        If (@error) Then Return SetError(1, 0, 0)
        Return $year
EndFunc
;-------------------------------------------------------------------------------------
Global $Tdate
Func _SystemDateThaiEx()
    $Tdate = (_DaysOfWeekTha()&_DaysOfMonthTha()&_MonthsOfYearTha()&_YearOfTenYearsTha())
    If (@error) Or (Not $Tdate) Then Return SetError(1, 0, 0)
    Return $Tdate
EndFunc

======================================================================================

Include file name: SystemTimeThai.au3

#include-once
#cs========start discription===========
Create date: 7/24/2011
File type: Library include
File name: SystemTimeThai.au3
Syntax: _SystemTimeThaiEx()
'-----' _SystemHalfTimeEx()
Design by: sak2005
#ce=========end discription============
Global $Ttime, $hour, $min, $sec
Func _SystemTimeThaiEx()
    $hour = @HOUR
    $min  = @MIN
    $sec  = @SEC
    $Ttime = ($hour&':'&$min&':'&$sec)
    If (@error) Or (Not $Ttime) Then Return SetError(1, 0, 0)
    Return $Ttime
EndFunc
;------------------------------------------------------------
Global $Thours, $halftime
Func _SystemHalfTimeEx()
    $Thours = @HOUR
    If $Thours < 12 Then
        $halftime = ':AM'
    Else
        $halftime = ':PM'
    EndIf
    If (@error) Then Return SetError(1, 0, 0)
    Return $halftime
EndFunc

==============================================================

Run System Clock Thai Sample (Use:ToolTip)

#include "SystemDateThai.au3"
#include "SystemTimeThai.au3"

HotKeySet("{ESC}", "_hkExit")

Do
    Sleep(10)
    ToolTip(_SystemDateThaiEx()&@CRLF&'      '& _
            _SystemTimeThaiEx()&' '& _
            _SystemHalfTimeEx())
Until False

Func _hkExit()
    Exit
EndFunc

=============================================================

Gui Library: Digital Clock. Add animation effect. Exit program with Fadein, Fadeout and Drag move GUI.

#NoTrayIcon
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <SendMessage.au3>
    #Include <Date.au3>

    Opt("MustDeclareVars", 1)
    HotKeySet("{ESC}", "_hkExit")

    Global Const $SC_DRAGMOVE = 0xF012
    Global $gtitle = 'DigitalClock'
    Global $hWnd, $Lbl_exit, $Lbl_time, $Lbl_trigA, $Lbl_date, $Lbl_trigB, $Lbl_ht
    Global $nMsg, $halftime, $i, $wday, $x

    $hWnd = GUICreate($gtitle, 205, 85, -100, -100, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP, _
    $WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), _
    BitOR($WS_EX_APPWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    GUISetBkColor(0x575C64)
    GUISetIcon("shell32.dll", 47)
    GUICtrlCreateGraphic(8, 32, 148, 44, BitOR($SS_NOTIFY,$SS_SUNKEN,$WS_BORDER))
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $Lbl_exit = GUICtrlCreateLabel("x", 193, 0, 10, 18, $SS_CENTER)
    GUICtrlSetFont(-1, 8, 800, 0, "Arial")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetCursor(-1, 0)
    $Lbl_time = GUICtrlCreateLabel(@HOUR&":"&@MIN&":"&@SEC, 16, 40, 130, 28, BitOR($SS_CENTER,$SS_CENTERIMAGE))
    GUICtrlSetFont(-1, 20, 800, 0, "Arial")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x000000)
    $Lbl_trigA = GUICtrlCreateLabel(".", 161, 30, 9, 18, BitOR($SS_CENTER,$SS_CENTERIMAGE))
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetColor(-1, 0xFF0000)
    $Lbl_date = GUICtrlCreateLabel(_SystemDate(), 38, 8, 130, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Lbl_trigB = GUICtrlCreateLabel(".", 161, 47, 9, 18, BitOR($SS_CENTER,$SS_CENTERIMAGE))
    GUICtrlSetFont(-1, 14, 800, 0, "Arial")
    GUICtrlSetColor(-1, 0xFF0000)
    $Lbl_ht = GUICtrlCreateLabel(_Halftime(), 173, 45, 28, 23)
    GUICtrlSetFont(-1, 12, 800, 0, "Arial")
    GUICtrlSetColor(-1, 0xFFFF00)
    GUISetState(@SW_SHOW)
    _Fadein()

    Do
        $nMsg = GUIGetMsg()
        If $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Lbl_exit Then _Fadeout()
        If $nMsg = $GUI_EVENT_PRIMARYDOWN Then
            _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
        EndIf
        If $nMsg = 0 Then _trig()
    Until False

Func _trig()
    GUICtrlSetState($Lbl_trigA, $GUI_HIDE)
    GUICtrlSetState($Lbl_trigB, $GUI_HIDE)
    Sleep(333.33)
    GUICtrlSetState($Lbl_trigA, $GUI_SHOW)
    GUICtrlSetState($Lbl_trigB, $GUI_SHOW)
    Sleep(333.33)
    GUICtrlSetData($Lbl_time, @HOUR&":"&@MIN&":"&@SEC)
    GUICtrlSetData($Lbl_ht, _Halftime())
    Sleep(333.33)
EndFunc

Func _Halftime()
    Local $hour = @HOUR
    If $hour > 12 Then
        $halftime = 'PM'
    Else
        $halftime = 'AM'
    EndIf
        Return $halftime
EndFunc

Func _Fadein()
    For $i = 0 To 255 Step 3
        WinSetTrans($gtitle, "", $i)
        WinMove($gtitle, "", 400, 300, 205, 85)
        Sleep(1)
    Next
EndFunc

Func _SystemDate()
    Local $opwday = @WDAY
    Switch $opwday
        Case 1
            $wday = 'SUN'
        Case 2
            $wday = 'MON'
        Case 3
            $wday = 'TUE'
        Case 4
            $wday = 'WED'
        Case 5
            $wday = 'THU'
        Case 6
            $wday = 'FRI'
        Case 7
            $wday = 'SAT'
    EndSwitch
    Local $Ret = $wday&'/'&_NowDate()
    If(@error)Or(Not $Ret)Then Return SetError(1, 0, 0)
    Return $Ret
EndFunc

Func _Fadeout()
    For $x = 255 To 0 Step -3
        WinSetTrans($gtitle, "", $x)
        Sleep(1)
    Next
        Exit
EndFunc

Func _hkExit()
    Exit
EndFunc

================================================================

For Library include Test.

Include name: PopupMessage.au3

#include-once
#cs===================discription============================
createdate: 7/27/2011
filetype: Library include
filename: PopupMessage.au3
syntax: _MessageBoxEx($flag, $title, $text, $timeout, $hWnd)
'----'  _InputBoxEx($title, $prompt, $defult, $passwordchar, $width, $height, $left, $top, $timeout, $hwnd)
design by: sak2005
#ce======================end=================================
Global $flag, $title, $text, $timeout, $hwnd
Func _MessageBoxEx($flag, $title, $text, $timeout, $hwnd)
    $Ret = (MsgBox($flag, $title, $text, $timeout, $hwnd))
    If(@error)Or(Not $Ret)Then Return SetError(1, 0, 0)
    Return $Ret
EndFunc ;<<=end MessageBoxEx=<<
;------------------------------------------------------------
Global $title, $prompt, $defult, $passwordchar, $width, $height, $left, $top, $timeout, $hwnd
Func _InputBoxEx($title, $prompt, $defult, $passwordchar, $width, $height, $left, $top, $timeout, $hwnd)
    $Ret = InputBox($title, $prompt, $defult, $passwordchar, $width, $height, $left, $top, $timeout, $hwnd)
    If(@error)Then 
        Exit 1
    ElseIf(Not $Ret)Then
        Return 0
    Else
        Return $Ret
    EndIf
EndFunc ;<<=end InputBoxEx=<<

-----------------------------------------------------------------------------------

Run Library Popup Sample

#include "PopupMessage.au3"
#cs=========discription==========
createdate: 7/27/2011
filetype: run popupmessage sample
filename: --(Modify)
design by: sak2005
#ce==============================
sample1()
sample2()
Func sample1()
    While 1
        Local $btn = _MessageBoxEx(35, "Sample", "Do you wanted test button?", 0, 0)
        If(@error)Or(Not $btn)Then Return SetError(1, 0, 1)
        Switch $btn
            Case 6
                _MessageBoxEx(64, "Sample", "You press button..Yes", 0, 0)
            Case 7
                _MessageBoxEx(64, "Sample", "You press button..No", 0, 0)
            Case Else
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Func sample2()
    While 1
        Local $var = _InputBoxEx("Sample", "Enter:Your name", "", "", 200, 100, 400, 300, 0, 0)
        Select
            Case @error = 1
                Exit
            Case $var = ""
               _MessageBoxEx(0, "Info", "Enter your name in the box.", 0, 0)
            Case Else
                _MessageBoxEx(64, "Info", "Your name is "&$var, 0, 0)
                ExitLoop
        EndSelect
    WEnd
EndFunc
Edited by newsak2005
Link to comment
Share on other sites

Sample Code:DateTime Desktop.au3 'Last my library. Full Script.' :)

;Hide tray icon.
#NoTrayIcon
#cs====Discription===========
CreateDate:7/28/2011
FileType:Library Form Design
FileName:DateTimeDesktop.au3
DesignBy:Sak2005
#ce==========================
;Library Include.
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
;Keyword Operator Variable.
Opt("MustDeclareVars", 1)
HotKeySet("{ESC}", "_hkExit")
Global $title = 'DateTimeDesktop'
;Form design. (Koda)
Local $hForm = GUICreate($title, @DesktopWidth, @DesktopHeight, -1, -1, -1, $WS_EX_LAYERED)
GUISetBkColor(0xABABAB)
GUISetIcon("shell32.dll", 47)
Local $hLabel_Date = GUICtrlCreateLabel(_SystemDate(), 20, 300, 950, 70, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 30, 0, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $hLabel_Disc = GUICtrlCreateLabel("Design by : sak2005", 20, 365, 950, 40, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 15, 0, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
Local $hLabel_Time = GUICtrlCreateLabel(_SystemTime(), 20, 400, 950, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 0, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
_WinAPI_SetLayeredWindowAttributes($hForm, 0xABABAB, 255, BitOR($LWA_COLORKEY, $LWA_ALPHA)) ;Glass form.
;Events GuiControl Loop.
Do
    ControlSetText($title, "", "Static1", _SystemDate())
    ControlSetText($title, "", "Static3", _SystemTime())
Until GUIGetMsg()=$GUI_EVENT_CLOSE
;Date Library function.
Func _SystemDate()
    Local $day, $wday = @WDAY
    Switch $wday
        Case 1
            $day = 'Su'
        Case 2
            $day = 'Mo'
        Case 3
            $day = 'Tu'
        Case 4
            $day = 'We'
        Case 5
            $day = 'Th'
        Case 6
            $day = 'Fr'
        Case 7
            $day = 'Sa'
    EndSwitch
    Local $tabledate, $mday = @MDAY, $mon = @MON, $year = @YEAR
    $tabledate = ($day&'/'&$mday&'/'&$mon&'/'&$year)
    If(@error)Or(Not $tabledate)Then Return SetError(1, 0, 0)
    Return $tabledate
EndFunc
;Time Library function.
Func _SystemTime()
    Local $tabletime, $hour = @HOUR, $min = @MIN, $sec = @SEC
    $tabletime = ($hour&':'&$min&':'&$sec)
    If(@error)Or(Not $tabletime)Then Return SetError(1, 0, 0)
    Return $tabletime
EndFunc
;Press key ESC to exit function.
Func _hkExit()
    Exit
EndFunc  ;<<=End Datetime Desktop=<<

==========================================================

Timer ScreenSaver ;)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Date.au3>
#cs=======================
createdate: 7/28/2011
filetype: screensaver
filename: countertimer.au3
design by:sak2005
#ce=======================
AutoItSetOption ( "MustDeclareVars", 1)
HotKeySet("{ESC}", "_hkExit")
Global $title = 'CounterTimer'

GUICreate($title, @DesktopWidth, @DesktopHeight,-1, -1)
GUISetBkColor(0x000000)
GUICtrlCreateLabel("00", 350, 300, 70, 50, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel(":", 420, 295, 18, 50, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("00", 440, 300, 70, 50, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel(":", 515, 295, 12, 50, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("00", 535, 300, 70, 50, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("STANDBY", 380, 225, 200, 50, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 30, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("[Press Key Esc to Exit]", 350, 380, 250, 30, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("(Create by : sak2005)", 750, 720, 250, 30, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel(_Now(), 750, 700, 250, 30, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 600, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreatePic(@ProgramFilesDir&"\AutoIt3\Examples\GUI\mslogo.jpg", 350, 150, 255, 40)
GUISetState(@SW_SHOW)

AdlibRegister("_timer", 1000)
For $j = 0 To 60
    ControlSetText($title, "", 3, $j)
    For $i = 0 To 59
        ControlSetText($title, "", 5, $i)
        For $x = 0 to 59
            ControlSetText($title, "", 7, $x)
            Sleep(333.33)
            ControlHide($title, "", 6)
            Sleep(333.33)
            ControlShow($title, "", 6)
            Sleep(333.33)
        Next
    Next
Next

Func _timer()
    Local $day, $halftime
    Switch @WDAY
        Case 1
            $day = 'Su'
        Case 2
            $day = 'Mo'
        Case 3
            $day = 'Tu'
        Case 4
            $day = 'We'
        Case 5
            $day = 'Th'
        Case 6
            $day = 'Fr'
        Case 7
            $day = 'Sa'
    EndSwitch
    If @HOUR >= 12 Then
        $halftime = 'PM'
    Else
        $halftime = 'AM'
    EndIf
    ControlSetText($title, "", 11, $day&'/'&_Now()&' :'&$halftime)
EndFunc

Func _hkExit()
    Exit
EndFunc
Edited by newsak2005
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...