ฟอรั่ม 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ทีคับ

    sticked
    sticked
    PSsix Member
    PSsix Member


    ช่วยโคดกับ GUIทีคับ Empty ช่วยโคดกับ GUIทีคับ Empty
    จำนวนข้อความ : 24
    ความนิยม : 1
    เข้าร่วมเมื่อ : 30/01/2012
    อายุ : 34

    ช่วยโคดกับ GUIทีคับ Empty ช่วยโคดกับ GUIทีคับ

    ตั้งหัวข้อ by sticked 20/02/12, 10:05 pm

    $Combo1 = GUICtrlCreateCombo("กรุณาเลือก", 40, 96, 145, 25)
    GUICtrlSetData(-1,"Blue|Red|Yellow|Pink","กรุณาเลือก")
    $Button1 = GUICtrlCreateButton("start", 224, 32, 75, 25)

    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    Case $Button1
    If $combobox ..........
    (ตรงส่วนนี้แหละครับจะทำไงดี)จะให้ทำ ถ้าเลือกแถบ Blue ที่คอมโบบ๊อกให้เป็น
    $color1 = "รหัสสีฟ้า"
    ถ้าเลือกแถบ Red ที่คอมโบบ๊อกให้เป็น
    $color1 = "รหัสสีแดง"
    ถ้าเลือกแถบ Yellow ที่คอมโบบ๊อกให้เป็น
    $color1 = "รหัสสีเหลือง"
    ถ้าเลือกแถบ Pink ที่คอมโบบ๊อกให้เป็น
    $color1 = "รหัสสีชมพู"

    EndSwitch
    WEnd

    มึนตึ๊บ เลยครับ
    POS
    POS
    PSsix
    PSsix


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

    ช่วยโคดกับ GUIทีคับ Empty Re: ช่วยโคดกับ GUIทีคับ

    ตั้งหัวข้อ by POS 21/02/12, 12:00 pm

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

    $Form1 = GUICreate("PSsix", 299, 107, 350, 252)
    $Combo1 = GUICtrlCreateCombo("กรุณาเลือก", 24, 16, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "Blue|Red|Yellow|Pink")
    $Button1 = GUICtrlCreateButton("Button1", 200, 16, 75, 25)
    $Label1 = GUICtrlCreateLabel("Label1", 24, 56, 147, 17)
    GUISetState(@SW_SHOW)


    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button1
             GUICtrlSetData($Label1, "รหัสสี " & comboselect())
       EndSwitch
    WEnd

    Func comboselect()
       $seleccb = GUICtrlRead($Combo1)
       Select
          Case StringInStr($seleccb, "Blue")
             Return "น้ำเงิน"
          Case StringInStr($seleccb, "Red")
             Return "แดง"
          Case StringInStr($seleccb, "Yellow")
             Return "เหลือง"
          Case StringInStr($seleccb, "Pink")
             Return "ชมพู"
       EndSelect
    EndFunc
    sticked
    sticked
    PSsix Member
    PSsix Member


    ช่วยโคดกับ GUIทีคับ Empty ช่วยโคดกับ GUIทีคับ Empty
    จำนวนข้อความ : 24
    ความนิยม : 1
    เข้าร่วมเมื่อ : 30/01/2012
    อายุ : 34

    ช่วยโคดกับ GUIทีคับ Empty Re: ช่วยโคดกับ GUIทีคับ

    ตั้งหัวข้อ by sticked 21/02/12, 06:48 pm

    ต้องขอโทษด้วยครับที่โพสผิดหมวด พอดีทำเรื่องเกม ก็เลยไปโพสที่เกมครับ em219

    ขอบคุณ คุณ POS มากเลยนะครับ เปิดหนังสือไม่มี combo เลย --. ไปคลำในเว็บกับดูคลิป ก้ไม่กระจ่าง em230

    พอดีไม่ค่อยเข้าใจเรื่องรีเทิร์นค่าผมเลยเอาใส่ if elseifแทน เผื่อใครมึนตึ๊บอย่างผม em228
    Code:

             $seleccb = GUICtrlRead($Combo1)
                If StringInStr($seleccb, "Blue") Then
                      $color1 = 0x523C29
                   ElseIf StringInStr($seleccb, "Red") Then
                      $color1 = 0x9C8A6B
                   ElseIf StringInStr($seleccb, "Yellow") Then
                      $color1 = 0x896834
                   ElseIf StringInStr($seleccb, "Pink") Then
                      $color1 = 0xA52018
                   ElseIf StringInStr($seleccb, "Black") Then
                      $color1 = 0xA7211E
                   Else
                EndIf
          ;-----------------------choose item blood
             If $b1 = 0x080608 Then
                If PixelGetColor(490, 746) = $color1 Then
                   Send("{F1}")
                ElseIf PixelGetColor(520, 746) = $color1 Then
                   Send("{F2}")
                ElseIf PixelGetColor(550, 746) = $color1 Then
                   Send("{F3}")
                ElseIf PixelGetColor(544, 745) = 0xA59A84 Then
                   Send("z")
                Else
             EndIf
          EndI
    POS
    POS
    PSsix
    PSsix


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

    ช่วยโคดกับ GUIทีคับ Empty Re: ช่วยโคดกับ GUIทีคับ

    ตั้งหัวข้อ by POS 23/02/12, 03:24 pm

    ใช้งานคำสั่งแล้วแต่ถนัดครับ ผมทำตัวอย่างเปรียบเทียบให้ตามโค้ดด้านล่างนี้ ตอนแรกเข้าใจว่า Select น่าจะทำงานเร็วกว่า ElseIf แต่พอลองทดสอบดูก็ได้ความเร็วใกล้เคียงกัน (ยังไม่ได้วัดการใช้งาน cpu ว่าคำสั่งไหนใช้มากกว่ากัน)

    Code:

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    $Form1 = GUICreate("PSsix", 299, 107, 350, 252)
    $Combo1 = GUICtrlCreateCombo("กรุณาเลือก", 24, 16, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "Blue|Red|Yellow|Pink")
    $Button1 = GUICtrlCreateButton("test speed", 200, 16, 75, 25)
    $Label1 = GUICtrlCreateLabel("Label1", 24, 56, 147, 17)
    GUISetState(@SW_SHOW)


    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button1
    ;~          GUICtrlSetData($Label1, "รหัสสี " & comboselect())
             comboselect2()
             comboselect()


       EndSwitch
    WEnd

    Func comboselect2()
       $TM2 = TimerInit() ;เริ่มตันการวัดเวลา ใช้ตัวแปร $TM เป็นตัวอ้างอิง

       For $i = 1 To 10000
          $seleccb = GUICtrlRead($Combo1)
          If StringInStr($seleccb, "Blue") Then
             $color1 = 0x523C29
          ElseIf StringInStr($seleccb, "Red") Then
             $color1 = 0x9C8A6B
          ElseIf StringInStr($seleccb, "Yellow") Then
             $color1 = 0x896834
          ElseIf StringInStr($seleccb, "Pink") Then
             $color1 = 0xA52018
          ElseIf StringInStr($seleccb, "Black") Then
             $color1 = 0xA7211E

          EndIf
       Next
       ConsoleWrite("เวลา ElseIf  คือ = " & Round(TimerDiff($TM2) / 1000, 2) & "วินาที" & @LF)
       ; ใส่คำสั่งถัดไป

    EndFunc 


    Func comboselect()
       $TM = TimerInit() ;เริ่มตันการวัดเวลา ใช้ตัวแปร $TM เป็นตัวอ้างอิง
       For $i = 1 To 10000
          $seleccb = GUICtrlRead($Combo1)
          Select
             Case StringInStr($seleccb, "Blue")
                $color1 = 0x523C29
             Case StringInStr($seleccb, "Red")
                $color1 = 0x9C8A6B
             Case StringInStr($seleccb, "Yellow")
                $color1 = 0x896834
             Case StringInStr($seleccb, "Pink")
                $color1 = 0xA7211E
          EndSelect
       Next
       ConsoleWrite("เวลา Select  คือ = " & Round(TimerDiff($TM) / 1000, 2) & "วินาที" & @LF)
       ; ใส่คำสั่งถัดไป

    EndFunc 
    sticked
    sticked
    PSsix Member
    PSsix Member


    ช่วยโคดกับ GUIทีคับ Empty ช่วยโคดกับ GUIทีคับ Empty
    จำนวนข้อความ : 24
    ความนิยม : 1
    เข้าร่วมเมื่อ : 30/01/2012
    อายุ : 34

    ช่วยโคดกับ GUIทีคับ Empty Re: ช่วยโคดกับ GUIทีคับ

    ตั้งหัวข้อ by sticked 06/03/12, 02:58 am

    switch ดีกว่าครับ
    เทสใน vmware จัดแรมให้น้อยๆ
    อย่างละ 3
    ชั่วโมงโดยไม่ sleep

    switch จะลื่นกว่านะครับ แต่ลืมไปดู process ว่ากินไปเท่าไร

      เวลาขณะนี้ 19/04/24, 05:35 pm