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


3 posters

    โปรแกรมเรียกคิว Autoit โดยใช้เสียง

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


     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty  โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty
    จำนวนข้อความ : 2
    ความนิยม : 0
    เข้าร่วมเมื่อ : 16/04/2013

     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty โปรแกรมเรียกคิว Autoit โดยใช้เสียง

    ตั้งหัวข้อ by chiltunder 16/04/13, 08:27 am

    คือผมใส่เสียงได้แล้ว แต่ว่าเสียงที่อัดต้องเป็น

    "หมายเลข 1 เชิญที่ช่องบริการ 1"

    ต่อ 1 ไฟล์เสียง ถ้ามี 100 คิว ก็ต้องอัด 100 เสียง

    ซึ่งที่ผมเห็นเขาทำกัน เขาจะทำเป็นแบบแยกเก็บอะครับ

    คือ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, ช่องบริการ, เชิฐหมายเลข โดยแยกกันเก็บเป็นคนละไฟล์เลย

    เวลาเรียกใช้เสียง ก็เหมือนเอาเสียงพวกนี้มาต่อกันอะครับ

    แต่ผมทำไม่เป็น ไม่รู้ต้องเขียน code อย่างไร ช่วยชี้แนะทีครับ

    อันนี้คือ code ที่ผมเขียนไว้ครับ
    Code:

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <FontConstants.au3>
    #Include <File.au3>
    #include <WINAPI.au3>

    HotKeySet("{Space}", "_OpenCard")
    HotKeySet("{Delete}", "_DeleteCard")
    HotKeySet("{ESC}", "_Exit")

    Global $hFile = @ScriptDir & "\ServiceCard.txt"

    Global $Form1 = GUICreate("", 1152, 864, -1, -1, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    GUISetBkColor(0x0000FF)
    $Form1context = GUICtrlCreateContextMenu()
    $MenuItem1 = GUICtrlCreateMenu("เมนูโปรแกรม", $Form1context)
    $MenuItem2 = GUICtrlCreateMenu("เมนูบัตรคิว", $MenuItem1)
    $MenuItem3 = GUICtrlCreateMenuItem("เมนูวันเวลา", $MenuItem2)
    $MenuItem9 = GUICtrlCreateMenuItem("", $MenuItem2)
    $MenuItem7 = GUICtrlCreateMenuItem("เปิดวันเวลา", $MenuItem2)
    $MenuItem8 = GUICtrlCreateMenuItem("ปิดวันเวลา", $MenuItem2)
    $MenuItem6 = GUICtrlCreateMenuItem("", $MenuItem1)
    $MenuItem10 = GUICtrlCreateMenuItem("เรียกบัตร", $MenuItem1)
    $MenuItem11 = GUICtrlCreateMenuItem("เคลียร์บัตร", $MenuItem1)
    $MenuItem4 = GUICtrlCreateMenuItem("", $Form1context)
    $MenuItem5 = GUICtrlCreateMenuItem("ปิดโปรแกรม", $Form1context)
    Global $Label1 = GUICtrlCreateLabel("", 0, 400, 1152, 78, $SS_CENTER)
    GUICtrlSetFont(-1, 48, 800, 0, "KodchiangUPC")
    GUICtrlSetColor(-1, 0xFFFFFF)
    Global $Label2 = GUICtrlCreateLabel("", 10, 50, 1152, 78, $SS_CENTER)
    GUICtrlSetColor(-1, 0x0000FF)
    _WinAnimate($Form1, 0x00080000, 1000)
    GUISetState()
    AdlibRegister("_timer", 1000)
    If Not FileExists($hFile)Then FileWrite($hFile, "")
    If _FileCountLines($hFile)=0 Then
        GUICtrlSetData($Label1, "ยังไม่มีคิว กดปุ่ม Space เรียกบัตรคิว")
    Else
       Dim $x, $FLcount
       For $x = 1 To 1000
       $FLcout = _FileCountLines($hFile)
       If $FLcount = "" Then ExitLoop
       Next
       GUICtrlSetData($Label1, "หมายเลข: 0" & $FLcout & " เชิญที่ช่องบริการ: " & $FLcout)
    EndIf

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             _WinAnimate($Form1,  0x00050010, 1000)
             ExitLoop
          Case $MenuItem10
             _GetCard()
          Case $MenuItem5
             _WinAnimate($Form1,  0x00050010, 1000)
             ExitLoop
          Case $MenuItem11
              _DeleteCard()
           Case $MenuItem7
             GUICtrlSetFont(-1, 36, 400, 0, "KodchiangUPC")
                GUICtrlSetColor(-1, 0xFFFFFFF)
          Case $MenuItem8
              GUICtrlSetColor(-1, 0x0000FF)
        EndSwitch
    WEnd

    Func _timer()
       GUICtrlSetData($Label2, @MDAY & "/" & @MON & "/" & @YEAR & " " &  @HOUR & ":" & @MIN &":"& @SEC)
    EndFunc

    Func _WinAnimate($v_gui, $i_mode, $i_duration = 1000)
       DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($v_gui), "int", $i_duration, "long", $i_mode)
       Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError')
       If $ai_gle[0] <> 0 Then
          SetError(1)
          Return 0
       EndIf
          Return 1
    EndFunc

    Func _GetCard()
       Local $i
       For $i = 1 To 1000
            If FileReadLine($hFile, $i) = ""  Then
               _FileWriteToLine($hFile, $i, ": " & $i, 1)
              GUICtrlSetData($Label1, "หมายเลข: 0" & $i & " เชิญที่ช่องบริการ" & FileReadLine($hFile, $i))
             If _FileCountLines($hFile)=1 Then
                 SoundPlay(@ScriptDir & "\sch1.wav")
              ElseIf _FileCountLines($hFile)=2 Then
                 SoundPlay(@ScriptDir & "\sch2.wav")
             Else
                SoundPlay(@ScriptDir & "\sch3.wav")
             EndIf
             Return
          EndIf
        Next
    EndFunc

    Func _DeleteCard()
       If  _FileCountLines($hFile)<>0 Then
           FileDelete($hFile)
           FileWrite($hFile, "")
            GUICtrlSetData($Label1, "เคลียร์บัตรคิวทั้งหมด")
           Sleep(2000)
           GUICtrlSetData($Label1, "ยังไม่มีคิว กดปุ่ม Space เรียกบัตรคิว")
        EndIf
    EndFunc

    Func _OpenCard()
        _GetCard()
     EndFunc

     Func _Exit()
       _WinAnimate($Form1,  0x00050010, 1000)
       GUIDelete()
       Exit
    EndFunc


    ชินจัง2
    POS
    POS
    PSsix
    PSsix


     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty  โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty  โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty Re: โปรแกรมเรียกคิว Autoit โดยใช้เสียง

    ตั้งหัวข้อ by POS 17/04/13, 11:45 am

    แบบที่ธนาคารเรียกคิวใช่ไหมครับมี ช่อง 1 ถึง 4 แต่การอัดเสียงทีละไฟล์ ถ้าเรียกคิวเป็นพัน แบบนี้ก็ต้องอัดเสียงเป็นพันเสียง ทั้งเปลืองเวลาและไม่ได้ประโยชน์อะไร จะแก้ไขก็เสียเวลามากขึ้นไปอีก

    ปัญหาที่คุณแก้ไขไม่ได้ เพราะคุณคิดแบบคนไม่เคยหัดเขียนโปรแกรมตามมาตรฐานทั่วไปเขาเรียนกัน (ไม่ใช่ตัดแปะสคริปต์แล้วบอกว่าเขียนเป็น) คือ คิดแบบร้อยเสียง ก็ร้อยไฟล์ ซึ่งผิดหลักการเขียนโปรแกรม

    หลักการเขียนโปรแกรมเบื้องต้น ต้องเข้าใจคำสั่งพื้นฐานเช่น if, Select ,Switch ,อาร์เรย์ ให้แม่นว่าจะหยิบคำสั่งมาใช้ทำอะไรในเหตุการณ์ไหน ถ้าไม่มีพื้นฐานด้านนี้หาหนังสือพวกสอนเขียนโปรแกรมเช่น VB หรือ C เบื้องต้น อะไรก็ได้ เพราะคำสั่งพื้นฐานจะเหมือนกันหมด หลักการเขียนก็นำมาประยุกต์ใช้ได้กับทุกภาษาคอมพิวเตอร์ อย่าใจร้อนคิดเอาง่ายเข้าว่า เอาโค้ดมาแก้นิดหน่อย (แต่ไม่เคยคิดเรียนคำสั่งพื้นฐานจริงจัง) สุดท้ายจะไม่ได้อะไรเลย เสียเวลาด้วย

    ดูตัวอย่างจากสคริปต์ด้านล่างนี้ก็แล้วกันครับ

    Code:
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <Date.au3>
    #include <Sound.au3>
    Global $Channel, $queue , $pssixSound, $ps = StringSplit("0,1,2,3.1,4.2,5,5.9,6.6,7.5,8.5,9.5,10.5,11.5,12.5,13.2,14.2,15.1", ",")

    $Form1 = GUICreate("PSsix", 590, 271, 658, 204)
    $ListView1 = GUICtrlCreateListView(" ลำดับที่เรียกไปแล้ว |  ช่องบริการ | บันทึกเวลาที่เรียก  | หมายเหตุ ", 16, 16, 481, 201)
    $Button1 = GUICtrlCreateButton("ช่อง 1", 16, 224, 75, 25)
    $Button2 = GUICtrlCreateButton("ช่อง 2", 152, 224, 75, 25)
    $Button3 = GUICtrlCreateButton("ช่อง 3", 288, 224, 75, 25)
    $Button4 = GUICtrlCreateButton("ช่อง 4", 424, 224, 75, 25)
    $Button5 = GUICtrlCreateButton("เริ่มนับใหม่", 504, 16, 75, 25)
    GUISetState(@SW_SHOW)

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button1
             $Channel = 1
             Speak()
          Case $Button2
             $Channel = 2
             Speak()
          Case $Button3
             $Channel = 3
             Speak()
          Case $Button4
             $Channel = 4
             Speak()
          Case $Button5
             $queue = 0
       EndSwitch
    WEnd

    Func Speak()
       $queue += 1
       GUICtrlCreateListViewItem($queue & "|" & $Channel & "|" & _DateTimeFormat(_NowCalc(), 5), $ListView1)
       $pssixSound = _SoundOpen("PSsix.mp3")
       $st = 900
       $cnumb = 1
       _SoundSeek($pssixSound, 0, 0, $ps[16])
       _SoundPlay($pssixSound, 0)
       Sleep(1200)

       Select
          Case StringMid($queue, 3, 1)
             _SoundSeek($pssixSound, 0, 0, $ps[StringMid($queue, $cnumb, 1)])
             _SoundPlay($pssixSound, 0)
             If $queue = 6 Then $st = 800
             Sleep($st)
             _SoundSeek($pssixSound, 0, 0, $ps[12])
             _SoundPlay($pssixSound, 0)
             If $queue = 6 Then $st = 800
             Sleep($st)
             $cnumb += 1
             ContinueCase

          Case StringMid($queue, 2, 1)
             If StringMid($queue, $cnumb, 1) <> 0 Then
                _SoundSeek($pssixSound, 0, 0, $ps[StringMid($queue, $cnumb, 1)])
                If StringMid($queue, $cnumb, 1) = 1 Then _SoundSeek($pssixSound, 0, 0, $ps[11])
                If StringMid($queue, $cnumb, 1) = 1 Then $st = 1000
                If StringMid($queue, $cnumb, 1) = 2 Then _SoundSeek($pssixSound, 0, 0, $ps[15])
                _SoundPlay($pssixSound, 0)
                If $queue = 6 Then $st = 800
                Sleep($st)
                If StringMid($queue, $cnumb, 1) <> 1 Then
                   _SoundSeek($pssixSound, 0, 0, $ps[11])
                   _SoundPlay($pssixSound, 0)
                   Sleep($st)
                EndIf
             EndIf
             $cnumb += 1
             ContinueCase

          Case StringMid($queue, 1, 1)
             If StringMid($queue, $cnumb, 1) <> 0 Then
                If StringLen($queue) > 1 Then
                   _SoundSeek($pssixSound, 0, 0, $ps[StringMid($queue, $cnumb, 1)])
                   If StringMid($queue, $cnumb, 1) = 1 Then _SoundSeek($pssixSound, 0, 0, $ps[14])
                   _SoundPlay($pssixSound, 0)
                   If $queue = 6 Then $st = 800
                   Sleep($st)
                Else
                   _SoundSeek($pssixSound, 0, 0, $ps[StringMid($queue, 1, 1)])
                   _SoundPlay($pssixSound, 0)
                   If $queue = 6 Then $st = 800
                   Sleep($st)
                EndIf
             EndIf

       EndSelect
       _SoundSeek($pssixSound, 0, 0, $ps[17])
       _SoundPlay($pssixSound, 0)
       Sleep(2400)
       _SoundSeek($pssixSound, 0, 0, $ps[$Channel])
       _SoundPlay($pssixSound, 0)
       Sleep($st)
       _SoundClose($pssixSound)
    EndFunc

    ไฟล์เสียงเอาไปใส่ในโฟลเดอร์เดียวกับสคริปต์
    Attachments
     โปรแกรมเรียกคิว Autoit โดยใช้เสียง AttachmentPSsix.zip
    ไฟล์เสียงคลายซิป แล้วไปวางในโฟลเดอร์เดียวกับสคริปต์
    You don't have permission to download attachments.
    (64 Kb) Downloaded 82 times
    avatar
    chiltunder
    มือใหม่เพิ่งสมัคร
    มือใหม่เพิ่งสมัคร


     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty  โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty
    จำนวนข้อความ : 2
    ความนิยม : 0
    เข้าร่วมเมื่อ : 16/04/2013

     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty Re: โปรแกรมเรียกคิว Autoit โดยใช้เสียง

    ตั้งหัวข้อ by chiltunder 20/04/13, 11:11 pm

    ขอบคุณครับ..

    จะนำไปศึกษาครับ
    avatar
    kisda.th
    มือใหม่เพิ่งสมัคร
    มือใหม่เพิ่งสมัคร


     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty  โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty
    จำนวนข้อความ : 1
    ความนิยม : 0
    เข้าร่วมเมื่อ : 20/09/2013

     โปรแกรมเรียกคิว Autoit โดยใช้เสียง Empty Re: โปรแกรมเรียกคิว Autoit โดยใช้เสียง

    ตั้งหัวข้อ by kisda.th 20/09/13, 07:18 am

    ขอบคุณครับ

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