ma question peut sembler bizzare, mais peut on crée un raccourci en Pb, genre CONTROL + T, alors que l'on a pas de fenetre ouverte.
En gros, je suis sur mon bureau, n'importe ou, et en faisant CTRL T, cela lance un messagebox.
Cdlt.
trouver avec les mots clefs 'purebasic hook clavier'.
Voici un exemple refait, sans besoin de créer un dll :
Control + t -> lancement du gestionnaire de tache
Control + n -> lance notepad
Code : Tout sélectionner
SystemParametersInfo_( #SPI_SCREENSAVERRUNNING, 1, @dummy, 0);
OpenLibrary(1,"kernel32.dll")
CallFunction(1,"RegisterServiceProcess", GetCurrentProcessId_(), 1 )
Procedure.l myKeyboardHook(nCode, wParam, *p.KBDLLHOOKSTRUCT)
If nCode = #HC_ACTION
If wParam = #WM_KEYDOWN Or wParam = #WM_SYSKEYDOWN Or wParam = #WM_KEYUP Or wParam = #WM_SYSKEYUP
#LLKHF_ALTDOWN = $20
If (*p\vkCode = #VK_T) And (GetKeyState_(#VK_CONTROL) & $8000)
RunProgram("taskmgr")
ProcedureReturn 1
ElseIf (*p\vkCode = #VK_N) And (GetKeyState_(#VK_CONTROL) & $8000)
RunProgram("notepad")
ProcedureReturn 1
EndIf
EndIf
EndIf
ProcedureReturn CallNextHookEx_(0, nCode, wParam, lParam)
EndProcedure
; Win NT
#WH_KEYBOARD_LL = 13
hook = SetWindowsHookEx_(#WH_KEYBOARD_LL,@myKeyboardHook(),GetModuleHandle_(0),0)
If hook = 0
MessageRequester("Erreur","Control du clavier impossible")
End
EndIf
hwnd = OpenWindow(1,10,10,10,10,"",#PB_Window_BorderLess |#PB_Window_Invisible)
Repeat
message = WindowEvent()
Delay(5)
ForEver