Raccourcis clavier avancée.... Windows

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Avatar de l’utilisateur
celtic88
Messages : 309
Inscription : sam. 12/sept./2015 14:31
Localisation : Alger

Raccourcis clavier avancée.... Windows

Message par celtic88 »

salut les pures :)

l'idée est de créer des raccourcis clavier avec des mots dans toutes les langues et sur n 'importe fenêtre a l 'utilisation de "keyboard hook" ,,,,, ;)


le code

Code : Tout sélectionner

;////////////////////////////////////
;          Author Celtic88(c) 2016
;          Purebasic advanced System hotKey
;          !i!For educational purposes only.!i!
;///////////////////////////////////

EnableExplicit

Enumeration
  #KeylogWindow=0
EndEnumeration

Global HotKey1.s="$purebasicisthebest$" ;<=== votre mot de raccourci
Global HotKey2.s="[L_CONTROL_On][L_SHIFT_On]M" ;<=== deuxième mot de raccourci

Global KeylogWindowId
Global KeylogerWindowsHook
Global Keyloger.s

Define mm, Keytext.s ="........BS.TAB...CLEAR.ENTER...SHIFT.CTRL.ALT.PAUSE.CAPS_LK.IME_KANA..IME_JUNJA.IME_FINAL.IME_HANJA..ESC.IME_CONVERT.IME_NONCONVERT.IME_ACCEPT.IME_MODE.SPACE.PAGE_UP.PAGE_DOWN.END.HOME.LEFT.UP.RIGHT.DOWN.SELECT.PRINT.EXECUTE.PRINT_SCREEN.INS.DEL.HELP............................................L_WINDOWS.R_WINDOWS.MENU..SLEEP.................F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.........NUM_LK.SCROLL_LK...............L_SHIFT.R_SHIFT.L_CONTROL.R_CONTROL.L_MENU.R_MENU.BROWSER_BACK.BROWSER_FORWARD.BROWSER_REFRESH.BROWSER_STOP.BROWSER_SEARCH.BROWSER_FAVORITES.BROWSER_START_HOME.VOLUME_MUTE.VOLUME_DOWN.VOLUME_UP.NEXT_TRACK.PREVIOUS_TRACK.STOP_MEDIA.PLAY/PAUSE_MEDIA.START_MAIL.SELECT_MEDIA.START_APPLICATION_1.START_APPLICATION_2...........................................OEM_102...IME_PROCESS.................ATTN.CRSEL.EXSEL.ERASE_EOF.PLAY.ZOOM.RESERVED.PA1_KEY.OEM_CLEAR_KEY."
Global Dim Systext.s(256)
For mm=1 To 256
  Systext(mm)=StringField(Keytext,mm,".")
Next

Structure KeyState
  lpKeyState.a[256]
EndStructure

Procedure KeyboardHook(nCode, wParam, lParam)
  If nCode = 0 
    Protected *KEYHOOKSTRUCT.KBDLLHOOKSTRUCT=lParam
    Protected vkCode = *KEYHOOKSTRUCT\vkCode, GetKeyState
    Protected unikey.s
    
    Protected Verkey.b=Bool((vkCode > 159 And  vkCode < 166 )  Or (vkCode > 15   And  vkCode < 19 ))
    Protected aCtivWin=GetForegroundWindow_()
    Select wParam
      Case #WM_KEYUP,  #WM_SYSKEYUP
        If Systext(vkCode+1) <> ""
          If Verkey
            unikey = "[" + Systext(vkCode+1)  + "_Off" + "]"
          EndIf
        EndIf
      Case #WM_KEYDOWN,  #WM_SYSKEYDOWN
        If Systext(vkCode+1) <> ""
          unikey = "[" + Systext(vkCode+1)
          If Verkey
            unikey + "_On"
          ElseIf vkCode = 20 Or  vkCode = 144   Or  vkCode = 145  
            GetKeyState=GetKeyState_(vkCode)
            If GetKeyState
              unikey +  "_Off"
            Else
              unikey + "_On"
            EndIf
          EndIf
          unikey + "]"
        Else
          Protected lpKeyState.KeyState
          GetKeyboardState_(@lpKeyState)
          unikey=Space(1)
          ToUnicodeEx_(vkCode,MapVirtualKey_(vkCode,0),lpKeyState,@unikey,1,0,GetKeyboardLayout_(GetWindowThreadProcessId_(aCtivWin,0)))
          If Asc(unikey)>0 And Asc(unikey)<32
            unikey=Chr(vkCode)
          EndIf
        EndIf
        
    EndSelect
    
    If aCtivWin <> KeylogWindowId And unikey
      Keyloger + unikey
      SendMessage_(GadgetID(0), $C2, #True, @unikey)
    EndIf
    
  EndIf
  ProcedureReturn CallNextHookEx_(KeylogerWindowsHook,nCode, wParam, lParam)
EndProcedure

OpenWindow(#KeylogWindow, 0, 0, 600, 400, "test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(0, 20, 20, 570, 370)
SetGadgetAttribute(0,#PB_Editor_ReadOnly,1)
StickyWindow(#KeylogWindow,1)
KeylogWindowId=WindowID(#KeylogWindow)

KeylogerWindowsHook=SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0)

While WaitWindowEvent() <> #PB_Event_CloseWindow  
  If CountString(Keyloger, HotKey1)
    MessageRequester("","premier raccourci")
    Break
  ElseIf CountString(Keyloger, HotKey2)
    MessageRequester("","deuxième raccourci")
    Break
  EndIf
Wend

UnhookWindowsHookEx_(KeylogerWindowsHook)
End
by
Dernière modification par celtic88 le lun. 25/avr./2016 12:43, modifié 2 fois.
.....i Love Pb :)
Avatar de l’utilisateur
celtic88
Messages : 309
Inscription : sam. 12/sept./2015 14:31
Localisation : Alger

Re: Raccourcis clavier avancée.... Windows

Message par celtic88 »

l'erreur est corrigée :p
.....i Love Pb :)
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: Raccourcis clavier avancée.... Windows

Message par Kwai chang caine »

Salut CELTIC content de te revoir, ça faisait un petit moment :wink:
Tu nous as fait un joli petit keylogger, ça va plaire aux antivirus :mrgreen:

Dis donc ça manque de doc ton truc :lol:
Comment tu effaces ?
Comment ça marche exactement ?

Quoi qu'il en soit merci pour le partage 8)
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Répondre