Code : Tout sélectionner
; Code du soldat inconnu bidouillé pour être activé/désactivé avec un double-clic sur F11
;
Global m_hMidiOut,m_MIDIOpen.b
Procedure SendMIDIMessage(nStatus.l,nCanal.l,nData1.l,nData2.l)
dwFlags.l = nStatus | nCanal | (nData1 << 8 ) | (nData2 << 16)
temp.l = midiOutShortMsg_ (m_hMidiOut,dwFlags) ;
If temp<>0
MessageRequester ( "Problème" , "Erreur dans l'envoi du message MIDI" ,0)
EndIf
EndProcedure
Procedure MIDIOpen()
If m_MIDIOpen = 0
If midiOutOpen_ (@m_hMidiOut,MIDIMAPPER,0,0,0) <> 0
MessageRequester ( "Problème" , "Impossible d'ouvrir le périphérique MIDI" ,0)
Else
SendMIDIMessage($C0,0,0,0)
m_MIDIOpen = 1
EndIf
EndIf
EndProcedure
Procedure PlayNoteMIDI(Canal.b,Note.b,VelociteDown.b,VelociteUp.b)
If m_MIDIOpen
SendMIDIMessage($80 | Canal,0,Note,VelociteDown)
SendMIDIMessage($90 | Canal,0,Note,VelociteUp)
EndIf
EndProcedure
Procedure ChargeInstrument(Canal.b,Instrument.b)
If m_MIDIOpen
SendMIDIMessage($C0 | Canal,0,Instrument,0)
EndIf
EndProcedure
#Taille = 200
NewList hWndList.l()
; taille de la zone de l'écran utilisable (sans la barre des taches)
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @Taille_Ecran.RECT, 0)
Largeur_Ecran = Taille_Ecran\Right - Taille_Ecran\Left
Hauteur_Ecran = Taille_Ecran\Bottom - Taille_Ecran\Top
MIDIOpen()
ChargeInstrument(0, 127)
ChargeInstrument(1, 1)
Repeat
For nq = 1 To 1
PlayNoteMidi(1, 50, 0, 127)
Delay(100)
Next
Repeat
Delay(5)
xxx = GetKeyState_(#VK_F11)
Until xxx = -128
For nq = 1 To 3
PlayNoteMidi(0, 50, 0, 127)
Delay(100)
Next
If OpenWindow(0, Taille_Ecran\Left, Taille_Ecran\Top, Largeur_Ecran, Hauteur_Ecran, "Affiche bureau", #PB_Window_Invisible | #PB_Window_BorderLess)
DC = GetDC_(0)
CreateImage(0, Largeur_Ecran, Hauteur_Ecran)
Dessin = StartDrawing(ImageOutput(0))
BitBlt_(Dessin, 0, 0, Largeur_Ecran, Hauteur_Ecran, DC, 0, 0, #SRCCOPY)
StopDrawing()
ReleaseDC_(0, DC)
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) ; choix de la barre d'outil réduite
ShowWindow_(WindowID(0), #SW_SHOW) ; montre la fenêtre
SetWindowPos_(WindowID(0), -1, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
If CreateGadgetList(WindowID(0))
ImageGadget(0, 0, 0, Largeur_Ecran, Hauteur_Ecran, ImageID(0))
EndIf
UpdateWindow_(WindowID(0))
; On pousse les fenêtres
hWnd.l = FindWindow_(0, 0)
While hWnd <> 0
If GetWindowLong_(Hwnd, #GWL_STYLE) & #WS_VISIBLE = #WS_VISIBLE
If GetWindowLong_(Hwnd, #GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW
GetWindowRect_(Hwnd, @Fen.RECT)
MoveWindow_(Hwnd, Fen\Left + Largeur_Ecran + 50, Fen\Top, Fen\Right - Fen\Left, Fen\Bottom - Fen\Top, #True)
AddElement(hWndList())
hWndList() = Hwnd
EndIf
EndIf
hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
Wend
Timer = SetTimer_(WindowID(0), 0, 15, 0)
#HotKeyID = 45
RegisterHotKey_(WindowID(0), #HotKeyID, 0, #PB_Shortcut_Escape)
Bureau = 0
Repeat
Event = WaitWindowEvent()
Win = GetForegroundWindow_()
If 1
If Event = #WM_TIMER
; position de la souris
GetCursorPos_(CursorPos.POINT)
Region1 = CreateRectRgn_(Taille_Ecran\Left, Taille_Ecran\Top, Taille_Ecran\Right, Taille_Ecran\Bottom)
Region2 = CreateEllipticRgn_(CursorPos\x - #Taille, CursorPos\y - #Taille, CursorPos\x + #Taille, CursorPos\y + #Taille)
CombineRgn_(Region1, Region1, Region2, #RGN_DIFF)
SetWindowRgn_(WindowID(0), Region1, #True)
UpdateWindow_(WindowID(0))
DeleteObject_(Region1)
DeleteObject_(Region2)
EndIf
EndIf
If GetKeyState_(#VK_F11) = -128
Win = -2
EndIf
If Event = #WM_HOTKEY ; si on appui sur Echap
If EventwParam() = #HotKeyID
Win = -1
EndIf
EndIf
If Bureau = 0 And Win <> WindowID(0)
GetCursorPos_(CursorPos.POINT)
If CursorPos\x >= Taille_Ecran\Left And CursorPos\x <= Taille_Ecran\Right And CursorPos\y >= Taille_Ecran\Top And CursorPos\y <= Taille_Ecran\Bottom
Bureau = Win
EndIf
EndIf
Until (Win <> WindowID(0) And Win <> Bureau) Or Win = -1 Or Win = -2
UnregisterHotKey_(WindowID(0), #HotKeyID)
KillTimer_(WindowID(0), Timer)
; On remet les fenêtres
ResetList(hWndList())
While NextElement(hWndList())
GetWindowRect_(hWndList(), @Fen.RECT)
MoveWindow_(hWndList(), Fen\Left - Largeur_Ecran - 50, Fen\Top, Fen\Right - Fen\Left, Fen\Bottom - Fen\Top, #True)
Wend
EndIf
CloseWindow(0)
Until Win <> -2