ฟอรั่ม 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

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    avatar
    darkbeeza10
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 11
    ความนิยม : 4
    เข้าร่วมเมื่อ : 26/07/2013

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by darkbeeza10 05/09/13, 03:28 pm

    ช่วยบอกคำสั่งที่จะออกจากวนลูปทีครับ โดยไม่ปิดหน้าต่าง GUI อ่าครับem229 

    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func Start()
     While 1
     Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
     WEnd
     EndFunc
    POS
    POS
    PSsix
    PSsix


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by POS 06/09/13, 04:20 am

    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func Start()
     While 1
             Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                Exit
                EndSwitch
    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
     Sleep(10)
     WEnd
     EndFunc
    avatar
    darkbeeza10
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 11
    ความนิยม : 4
    เข้าร่วมเมื่อ : 26/07/2013

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by darkbeeza10 06/09/13, 10:34 am

    POS พิมพ์ว่า:
    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func Start()
     While 1
           Switch GUIGetMsg()
     Case $GUI_EVENT_CLOSE
     Exit
     EndSwitch
    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
     Sleep(10)
     WEnd
     EndFunc
    ถ้า + คำอธิบายด้วยจะเป็นพระคุณมากเลยครับ เพราะให้โค๊ดมา มันก็จะไม่รู้ว่า โค๊คที่ให้มาทำงานทำยังไง แล้วต้องเขียนอะไรเข้าไปมั้งอ่าครับ เพราะจะได้เอาไปใช้แบบอื่นได้อ่าครับ
    avatar
    darkbeeza10
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 11
    ความนิยม : 4
    เข้าร่วมเมื่อ : 26/07/2013

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by darkbeeza10 06/09/13, 10:58 am

    POS พิมพ์ว่า:
    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func Start()
     While 1
           Switch GUIGetMsg()
     Case $GUI_EVENT_CLOSE
     Exit
     EndSwitch
    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
     Sleep(10)
     WEnd
     EndFunc
    หลังจากที่ทดสอบแล้ว มันก็ยังไม่ออกจากวนลูปเหมือนเดิมครับ มันก็ยังทำการวนลูปไปเรื่อยๆเหมือนเดิมครับ หลังจากที่กด button1 เพื่อออกจากวนลูปem229 
    POS
    POS
    PSsix
    PSsix


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by POS 06/09/13, 09:23 pm

    พอดีผมไม่ได้ทดสอบการใส่ค่าตัวเลข แก้ไขใหม่ตามสคริปต์ด้านล่างนี้ (บรรทัดที่เพิ่มเข้ามา เอาไปใช้ในสคริปต์อื่นๆ ได้)

    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>


    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func Start()
       AdlibRegister("checkexit",50)
     While 1

    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
     Sleep(10)
     WEnd
     EndFunc


    Func checkexit()
       if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit
       EndFunc
    avatar
    darkbeeza10
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 11
    ความนิยม : 4
    เข้าร่วมเมื่อ : 26/07/2013

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by darkbeeza10 07/09/13, 02:22 pm

    POS พิมพ์ว่า:พอดีผมไม่ได้ทดสอบการใส่ค่าตัวเลข  แก้ไขใหม่ตามสคริปต์ด้านล่างนี้ (บรรทัดที่เพิ่มเข้ามา เอาไปใช้ในสคริปต์อื่นๆ ได้)

    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>


    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Func Start()
       AdlibRegister("checkexit",50)
     While 1

    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
     Sleep(10)
     WEnd
     EndFunc


    Func checkexit()
       if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit
       EndFunc
    จากที่ท่านได้แก้มาให้ผมนั้น คือ 1 กด button1 ไม่หลุดจากวนลูป 2 เพิ่มเข้ามาจากอันแรกที่ให้คือ X ปิดหน้าต่าง GUI
    ซึงที่ท่านให้มาก็ยังไม่สามารถออกจากวนลูปได้โดยที่ไม่ปิดหน้าต่าง GUI ครับ จากเครื่องที่ผมทดสอบน่ะครับ ไม่รู้ว่าของท่านนั้นจะเป็นเหมือนผมหรือเปล่า แต่ถ้าไม่ได้ก็ไม่เป็นไรครับ ผมจะได้ใส่ func pause func stop จะได้ใส่ 2 ตัวนี้เข้าไปแทน แต่ข้อเสียคือ ถ้าจะใช้คือต้องรันไฟล์ใหม่
    POS
    POS
    PSsix
    PSsix


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by POS 08/09/13, 01:14 am

    ผมอ่านไม่ชัดเจนเองแหละครับ นึกว่าจะให้ปิดหน้าต่างโปรแกรมเลย

    สรุปคุณต้องการ ให้กดปุ่ม button1 ทำงาน แล้วกดปุ่ม button2 ออกจากลูป ใช่ไหมครับ ถ้าต้องการตามนั้นก็ใช้โค้ดด้านล่างนี้

    หมายเหตุ
    การออกแบบ GUI ผิดตั้งแต่เริ่มต้นแล้วครับ เราตัวโปรแกรมต้องรอรับคำสั่งเมื่อหลุดจากคำสั่ง sleep เท่านั้น แต่จะไม่รอรับคำสั่งตลอดเวลา ลองเปรียบเทียบกับโปรแกรม [You must be registered and logged in to see this link.] ที่ผมทำแจกจะเห็นว่ากดหยุดชั่วคราวก็จะหยุดทันทีโดยไม่ต้องรอค่าดีเลย์ของ sleep ซึ่งหากจะทำอย่างนี้ต้องศึกษาเพิ่มเติมตามลิงก์ [You must be registered and logged in to see this link.] (ผมไม่มีเวลามาเขียนบทความสอน เนื่องจากไม่ค่อยว่างในช่วงนี้)

    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

    $itr = 1

    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
     Case $GUI_EVENT_CLOSE
     Exit
     Case $Button1
        $itr =1
     Start()
     EndSwitch
    WEnd

    Func Start()
       AdlibRegister("checkexit",50)
     While $itr
    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
      Sleep(10)
     WEnd
     EndFunc


    Func checkexit()
     $nMsg = GUIGetMsg()
     Switch $nMsg
     Case $GUI_EVENT_CLOSE
     Exit
     Case $Button2
     $itr = 0
     EndSwitch

       EndFunc
    avatar
    darkbeeza10
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty
    จำนวนข้อความ : 11
    ความนิยม : 4
    เข้าร่วมเมื่อ : 26/07/2013

    ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ Empty Re: ช่วยทำตัวออกจากวนลูปโดยไม่ปิด GUI ทีครับ

    ตั้งหัวข้อ by darkbeeza10 08/09/13, 02:15 pm

    POS พิมพ์ว่า:ผมอ่านไม่ชัดเจนเองแหละครับ นึกว่าจะให้ปิดหน้าต่างโปรแกรมเลย  

    สรุปคุณต้องการ ให้กดปุ่ม button1 ทำงาน    แล้วกดปุ่ม button2 ออกจากลูป ใช่ไหมครับ  ถ้าต้องการตามนั้นก็ใช้โค้ดด้านล่างนี้

    หมายเหตุ
    การออกแบบ GUI ผิดตั้งแต่เริ่มต้นแล้วครับ เราตัวโปรแกรมต้องรอรับคำสั่งเมื่อหลุดจากคำสั่ง sleep เท่านั้น แต่จะไม่รอรับคำสั่งตลอดเวลา ลองเปรียบเทียบกับโปรแกรม [You must be registered and logged in to see this link.] ที่ผมทำแจกจะเห็นว่ากดหยุดชั่วคราวก็จะหยุดทันทีโดยไม่ต้องรอค่าดีเลย์ของ sleep  ซึ่งหากจะทำอย่างนี้ต้องศึกษาเพิ่มเติมตามลิงก์ [You must be registered and logged in to see this link.]  (ผมไม่มีเวลามาเขียนบทความสอน เนื่องจากไม่ค่อยว่างในช่วงนี้)

    Code:

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>

    $itr = 1

    _Singleton(@ScriptName, 0)

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 451, 80, 367, 297)
    $Input1 = GUICtrlCreateInput("", 24, 24, 65, 21)
    $Label1 = GUICtrlCreateLabel("Delay", 104, 32, 31, 17)
    $Input2 = GUICtrlCreateInput("", 136, 24, 73, 21)
    $Button1 = GUICtrlCreateButton("Button1", 232, 24, 75, 25)
    $Button2 = GUICtrlCreateButton("Button2", 312, 24, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
     Case $GUI_EVENT_CLOSE
     Exit
     Case $Button1
        $itr =1
     Start()
     EndSwitch
    WEnd

    Func Start()
       AdlibRegister("checkexit",50)
     While $itr
    Send(GUICtrlRead($Input1))
     Sleep(GUICtrlRead($Input2) & "000")
      Sleep(10)
     WEnd
     EndFunc


    Func checkexit()
     $nMsg = GUIGetMsg()
     Switch $nMsg
     Case $GUI_EVENT_CLOSE
     Exit
     Case $Button2
     $itr = 0
     EndSwitch

       EndFunc
    ขอบคุณท่าน POS มากๆเลยน่ะครับ พอดีผมมือใหม่อ่าครับ พึ่งเริ่มเขียน AutoIt ก็เลยไม่ค่อยรู้เรื่องเท่าไหร่ครับ

    ขอบคุณสำหรับโค๊คที่ให้มาด้วยน่ะครับ แล้วก็โทดทีด้วยน่ะครับ ที่ทำให้ท่านต้องเสียเวลา ^^em218

      เวลาขณะนี้ 19/04/24, 11:11 am