Hook doesn't work with 5.6
Posted: Fri Sep 01, 2017 6:48 am
Hello
This code is good with PB 5 but not with PB5.6...maybe a bug ...????
Thank you to have a look
Program:
DLL(seam OK):
This code is good with PB 5 but not with PB5.6...maybe a bug ...????

Thank you to have a look

Program:
Code: Select all
OpenWindow(0,0,0,300,200,"Test_Hook");,#PB_Window_Invisible)
hDLL = OpenLibrary(0, "hook_detection_pc.dll")
Debug hDLL
hmyHookHookKeyboard = SetWindowsHookEx_(#WH_KEYBOARD , GetProcAddress_(hDLL, "HookKeyboard"), hDLL, 0)
hmyHookHookMouse = SetWindowsHookEx_(#WH_MOUSE , GetProcAddress_(hDLL, "HookMouse"), hDLL, 0)
InitNetwork()
Repeat
event=WaitWindowEvent()
If event<>0
Debug "event="+event
EndIf
Select event
Case #WM_USER+6 ;{Hook Mouse
Debug "Mouse"
;}
Case #WM_USER+5 ;{ HOOK CLAVIER
Debug "Clavier"
EndSelect
Until event=#PB_Event_CloseWindow
Code: Select all
ProcedureDLL.S WindowsEnum()
Static Flag,hWnd
Repeat
If Flag=0
hWnd = FindWindow_( 0, 0 )
Flag=1
Else
hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
EndIf
If hWnd <> 0
If GetWindowLong_(hWnd, #GWL_STYLE) & #WS_VISIBLE = #WS_VISIBLE ; pour lister que les fenĂȘtres visibles
If GetWindowLong_(hWnd, #GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW ; pour lister que les fenĂȘtres qui ne sont pas des ToolWindow ou barre d'outils
retour.S = Space(256)
GetWindowText_(hWnd, retour, 256)
If retour<>"" : Break : EndIf
EndIf
EndIf
Else
Flag=0
EndIf
Until hWnd=0
ProcedureReturn retour
EndProcedure
Procedure.S GetNomFenetreAvecDebut(Nom.S)
;debug "Procedure.s GetNomFenetreAvecDebut(Nom.s)"
;debug "Nom"
retour$=""
Repeat
Temp.S=WindowsEnum()
;debug "Procedure.s GetNomFenetreAvecDebut : "+ Temp
If LCase(Left(Temp,Len(Nom)))=LCase(Nom)
;debug "Bingo : "+Temp
retour$=Temp
EndIf
Until Temp=""
ProcedureReturn retour$
EndProcedure
ProcedureDLL HookKeyboard(code.l, wParam.l, lParam.l)
hMyWin = FindWindow_(0,"Test_Hook")
If lParam<0 : type=0 : Else : type=1 : EndIf
;If GetNomFenetreAvecDebut("Confirmation")=""
PostMessage_(hMyWin,#WM_USER+5,wParam,type)
ProcedureReturn CallNextHookEx_(@HookKeyboard(), code, wParam, lParam)
EndProcedure
ProcedureDLL HookMouse(code.l, wParam.l, lParam.l)
hMyWin = FindWindow_(0,"Test_Hook")
*mymsg.MOUSEHOOKSTRUCT = lParam
*position.POINT=*mymsg\pt; MSG structure holds info
;SetClipboardText(action$)
;PokeS(adresse_message,action$)
PostMessage_(hMyWin,#WM_USER+6,wParam,lParam)
ProcedureReturn CallNextHookEx_(@HookMouse(), code, wParam, lParam)
EndProcedure