ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


2 posters

    ช่วยดูโค้ดหน่อยครับ

    avatar
    nurnger03
    มือใหม่เพิ่งสมัคร
    มือใหม่เพิ่งสมัคร


    ช่วยดูโค้ดหน่อยครับ Empty ช่วยดูโค้ดหน่อยครับ Empty
    จำนวนข้อความ : 9
    ความนิยม : 0
    เข้าร่วมเมื่อ : 22/02/2014

    ช่วยดูโค้ดหน่อยครับ Empty ช่วยดูโค้ดหน่อยครับ

    ตั้งหัวข้อ by nurnger03 30/03/14, 03:56 pm

    #include #include #include #include #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 240, 156, 192, 124)
    $Button1 = GUICtrlCreateButton("Set", 16, 56, 121, 81)
    $Input1 = GUICtrlCreateInput("1000", 16, 24, 121, 21)
    $Button2 = GUICtrlCreateButton("OpenMsg", 152, 85, 75, 50)
    $lable1 = GUICtrlCreateLabel("0", 152, 25, 50, 50)
    $s1 = GUICtrlSetData
    $s1 = GUICtrlSetData
    GUISetState(@SW_SHOW)

    While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
    Case $GUI_EVENT_CLOSE
           Exit
    Case $Button1
    Button1()
    case $Button2
    Button2()
     EndSwitch
    WEnd

    Func Button1()
    GUICtrlSetData($lable1, GUICtrlRead($Input1))
    GUICtrlSetData($s1, GUICtrlRead($Input1))
    EndFunc
    Func Button2()
    Sleep ($s1)
              MsgBox(0,"Hello!","Hi!")
    EndFunc

    คือกด Button1 SetData ไปแล้วให้มันไปเซต Sleep ตั้งเวลาหน่วยในการโชว์ Msg โดยกด Button2 ยังไงหรอครับ
    ขอบคุณครับ


    แก้ไขล่าสุดโดย nurnger03 เมื่อ 30/03/14, 04:07 pm, ทั้งหมด 3 ครั้ง
    avatar
    nurnger03
    มือใหม่เพิ่งสมัคร
    มือใหม่เพิ่งสมัคร


    ช่วยดูโค้ดหน่อยครับ Empty ช่วยดูโค้ดหน่อยครับ Empty
    จำนวนข้อความ : 9
    ความนิยม : 0
    เข้าร่วมเมื่อ : 22/02/2014

    ช่วยดูโค้ดหน่อยครับ Empty Re: ช่วยดูโค้ดหน่อยครับ

    ตั้งหัวข้อ by nurnger03 30/03/14, 04:00 pm

    ..


    แก้ไขล่าสุดโดย nurnger03 เมื่อ 30/03/14, 04:03 pm, ทั้งหมด 1 ครั้ง
    avatar
    nurnger03
    มือใหม่เพิ่งสมัคร
    มือใหม่เพิ่งสมัคร


    ช่วยดูโค้ดหน่อยครับ Empty ช่วยดูโค้ดหน่อยครับ Empty
    จำนวนข้อความ : 9
    ความนิยม : 0
    เข้าร่วมเมื่อ : 22/02/2014

    ช่วยดูโค้ดหน่อยครับ Empty Re: ช่วยดูโค้ดหน่อยครับ

    ตั้งหัวข้อ by nurnger03 30/03/14, 04:00 pm

    ..
    Arm
    Arm
    PSsix Member Super Class III
    PSsix Member Super Class III


    PSsix Master PSsix Program Coder
    จำนวนข้อความ : 268
    ความนิยม : 54
    เข้าร่วมเมื่อ : 31/03/2011
    อายุ : 26

    ช่วยดูโค้ดหน่อยครับ Empty Re: ช่วยดูโค้ดหน่อยครับ

    ตั้งหัวข้อ by Arm 01/04/14, 12:54 pm

    ประมาณนี้ครับ em219 
    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    Global $time = 0
    Global $Label3, $Label5, $Label6
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Open Message Box", 403, 258, -1, -1)
    $Label1 = GUICtrlCreateLabel("Timer :", 24, 32, 81, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "Tahoma")
    $Input1 = GUICtrlCreateInput("", 120, 35, 169, 27, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
    GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
    $Label2 = GUICtrlCreateLabel("Second", 304, 35, 72, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Tahoma")
    $Button1 = GUICtrlCreateButton("Set Time", 24, 104, 99, 41)
    GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
    $Button2 = GUICtrlCreateButton("Start", 152, 104, 107, 41)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label4 = GUICtrlCreateLabel("Reset", 312, 120, 41, 22)
    GUICtrlSetFont(-1, 11, 400, 4, "Tahoma")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetCursor(-1, 0)
    $Label3 = GUICtrlCreateLabel("Open MSG in", 24, 192, 142, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label5 = GUICtrlCreateLabel("second.", 296, 192, 85, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label6 = GUICtrlCreateLabel("", 168, 192, 129, 33, $SS_CENTER)
    GUICtrlSetFont(-1, 18, 800, 0, "Tahoma")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button1
             If GUICtrlRead($Input1) <> "" Then
                $time = GUICtrlRead($Input1)
                GUICtrlSetState($Button2, $GUI_ENABLE)
                SetText()
             EndIf
          Case $Button2
             Disable()
             For $i = $time To 0 Step -1
                GUICtrlSetData($Label6, $i)
                If $i = 0 Then ExitLoop
                Sleep(1000)
             Next
             Enable()
             GUICtrlSetData($Label6, $time)
             MsgBox(0,"Hello!","Hi!", -1, $Form1)
          Case $Label4
             $time = 0
             GUICtrlSetState($Button1, $GUI_ENABLE)
             GUICtrlSetState($Button2, $GUI_DISABLE)
             ClearText()
       EndSwitch
    WEnd

    Func SetText()
       GUICtrlSetState($Label3, $GUI_SHOW)
       GUICtrlSetState($Label5, $GUI_SHOW)
       GUICtrlSetState($Label6, $GUI_SHOW)
       GUICtrlSetData($Label6, $time)
    EndFunc

    Func ClearText()
       GUICtrlSetState($Label3, $GUI_HIDE)
       GUICtrlSetState($Label5, $GUI_HIDE)
       GUICtrlSetState($Label6, $GUI_HIDE)
       GUICtrlSetData($Input1, "")
    EndFunc

    Func Disable()
       GUICtrlSetState($Button1, $GUI_DISABLE)
       GUICtrlSetState($Button2, $GUI_DISABLE)
       GUICtrlSetState($Input1, $GUI_DISABLE)
       GUICtrlSetState($Label4, $GUI_DISABLE)
    EndFunc

    Func Enable()
       GUICtrlSetState($Button1, $GUI_ENABLE)
       GUICtrlSetState($Button2, $GUI_ENABLE)
       GUICtrlSetState($Input1, $GUI_ENABLE)
       GUICtrlSetState($Label4, $GUI_ENABLE)
    EndFunc

    EDIT: จริงๆแล้วมันมีวิธีในการนับเวลาที่ดีกว่านี้ครับ ใช้ TimerInit() กับ TimerDiff() แต่ตอนนี้ยังงงๆกับโค้ดอยู่เลยทำแบบ Sleep มาให้ดูก่อนครับ
    Arm
    Arm
    PSsix Member Super Class III
    PSsix Member Super Class III


    PSsix Master PSsix Program Coder
    จำนวนข้อความ : 268
    ความนิยม : 54
    เข้าร่วมเมื่อ : 31/03/2011
    อายุ : 26

    ช่วยดูโค้ดหน่อยครับ Empty Re: ช่วยดูโค้ดหน่อยครับ

    ตั้งหัวข้อ by Arm 02/04/14, 11:31 am

    อันนี้ใช้ TimerInit() กับ TimerDiff() นะครับ งงกับโค้ดตั้งนาน :P
    em228 em234 em246
    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    Global $time = 0
    Global $Label3, $Label5, $Label6
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Open Message Box", 403, 258, -1, -1)
    $Label1 = GUICtrlCreateLabel("Timer :", 24, 32, 81, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "Tahoma")
    $Input1 = GUICtrlCreateInput("", 120, 35, 169, 27, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
    GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
    $Label2 = GUICtrlCreateLabel("Second", 304, 35, 72, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Tahoma")
    $Button1 = GUICtrlCreateButton("Set Time", 24, 104, 99, 41)
    GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
    $Button2 = GUICtrlCreateButton("Start", 152, 104, 107, 41)
    GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label4 = GUICtrlCreateLabel("Reset", 312, 120, 41, 22)
    GUICtrlSetFont(-1, 11, 400, 4, "Tahoma")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetCursor(-1, 0)
    $Label3 = GUICtrlCreateLabel("Open MSG in", 24, 192, 142, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label5 = GUICtrlCreateLabel("second.", 296, 192, 85, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "Tahoma")
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label6 = GUICtrlCreateLabel("", 168, 192, 129, 33, $SS_CENTER)
    GUICtrlSetFont(-1, 18, 800, 0, "Tahoma")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If GUICtrlRead($Input1) <> "" Then
    $time = GUICtrlRead($Input1)
    GUICtrlSetState($Button2, $GUI_ENABLE)
    SetText()
    EndIf
    Case $Button2
    $sec = $time * 1000
    Disable()
    $start = TimerInit()
    $x = 0
    Local $t
    While ($sec - $x) > 0
    $x = TimerDiff($start)
    $t = Int(($sec - $x) / 1000) + 1
    If GUICtrlRead($Label6) <> $t Then
    GUICtrlSetData($Label6, $t)
    EndIf
    WEnd
    Enable()
    GUICtrlSetData($Label6, $time)
    MsgBox(0,"Hello!","Hi!", -1, $Form1)
    Case $Label4
    $time = 0
    GUICtrlSetState($Button1, $GUI_ENABLE)
    GUICtrlSetState($Button2, $GUI_DISABLE)
    ClearText()
    EndSwitch
    WEnd

    Func SetText()
    GUICtrlSetState($Label3, $GUI_SHOW)
    GUICtrlSetState($Label5, $GUI_SHOW)
    GUICtrlSetState($Label6, $GUI_SHOW)
    GUICtrlSetData($Label6, $time)
    EndFunc

    Func ClearText()
    GUICtrlSetState($Label3, $GUI_HIDE)
    GUICtrlSetState($Label5, $GUI_HIDE)
    GUICtrlSetState($Label6, $GUI_HIDE)
    GUICtrlSetData($Input1, "")
    EndFunc

    Func Disable()
    GUICtrlSetState($Button1, $GUI_DISABLE)
    GUICtrlSetState($Button2, $GUI_DISABLE)
    GUICtrlSetState($Input1, $GUI_DISABLE)
    GUICtrlSetState($Label4, $GUI_DISABLE)
    EndFunc

    Func Enable()
    GUICtrlSetState($Button1, $GUI_ENABLE)
    GUICtrlSetState($Button2, $GUI_ENABLE)
    GUICtrlSetState($Input1, $GUI_ENABLE)
    GUICtrlSetState($Label4, $GUI_ENABLE)
    EndFunc
     em239 em219 ชินจัง

      เวลาขณะนี้ 29/03/24, 06:38 am