見出し画像

🐤⑥MP3再生・スリープなどアプリの準備

Sub OSドライブ()

If Environ("COMPUTERNAME") = "PC1名" Then
    OsGo = "C:\umagen\ipatgo\"
    OsDC = "C:\競馬\"

ElseIf Environ("COMPUTERNAME") = "PC2名" Then
    OsGo = "C:\umagen\ipatgo\"
    OsDC = "C:\競馬\"

Else
    MsgBox ("ドライブ未設定")
    Stop
End If

End Sub


'---------------------------------------------------------------------keybd_eventの宣言

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const fKEYDOWN = KEYEVENTF_EXTENDEDKEY
Private Const fKEYUP = KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP
'---------------------------------------------------------------------Sleepの宣言

Private Declare Sub Sleep Lib "KERNEL32.dll" (ByVal dwMilliseconds As Long)
'---------------------------------------------------------------------フォアグラウンドxl用の宣言

#If Win64 Then
'【SetForegroundWindow関数】
    Declare PtrSafe Sub SetForegroundWindow Lib "user32" (ByVal hwnd As LongPtr)
    
'【FindWindow関数】
    Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
    
    Dim hwnd As LongPtr
    
#Else
'【SetForegroundWindow関数】
    Declare Sub SetForegroundWindow Lib "user32" (ByVal hwnd As Long)
    
'【FindWindow関数】
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Dim hwnd As Long
    
#End If
 
'------------------------------------------------------------------------'MP3サウンド用

#If Win64 Then
    Private Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
    (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
     ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
#Else
    Private Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" _
    (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
     ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
#End If

'-----------------------------------------------------------------------------------
Public SoundFile$ 'サウンド用Dim  SoundFile As String
 
Const ERROR_SUCCESS = &H0
'-----------------------------------------------------------------------------------

Dim myHwnd As Long 'ハンドル
Dim myFixClassName As String * 255 'クラス名full?
Dim myClassName As String 'クラス名
Dim MyDo
Dim StCopy$


Sub MP3再生()

OSドライブ
SoundFile = OsDC & SoundFile

Call mciSendString("play " & SoundFile, "", 0, 0)  '再生
'Call mciSendString("stop " &  SoundFile, "", 0, 0)     '停止
'Call mciSendString("pause " &  SoundFile, "", 0, 0)     '一時停止
'Call mciSendString("resume " &  SoundFile, "", 0, 0)     '一時停止から再開
 
End Sub

Sub MP3鳩時計() 'MP3サウンド
SoundFile = "鳩時計1.mp3" ' 再生したいMP3ファイルのパスに置き換えてください
MP3再生
End Sub

Sub MP3メッセージ表示音() 'MP3サウンド
SoundFile = "警告音2.mp3" ' 再生したいMP3ファイルのパスに置き換えてください
MP3再生
End Sub

Sub MP3金額表示() 'MP3サウンド
SoundFile = "金額表示.mp3" ' 再生したいMP3ファイルのパスに置き換えてください
MP3再生
 
End Sub

Sub レース時間()
MP3鳩時計
End Sub

Sub 問題発生()
MP3メッセージ表示音
End Sub

Sub 馬券購入()
MP3金額表示
End Sub


Sub まち3()
Dim Ti

Ti = Timer
Do
    DoEvents '一時的に制御を解放
    Sleep (100) 'Sleepはミリ秒です
Loop Until Timer > Val(Ti) + 3

End Sub

競馬でプログラムの作成
お疲れ様でした😎


いいなと思ったら応援しよう!

お風呂にバブ
応援あれば、とっても嬉しいです😁