Displaying mouse and keyboard state in screencasting...

Just starting out? Need help? Post your questions and find answers here.
DoMi
User
User
Posts: 67
Joined: Sat Jan 10, 2004 5:41 pm
Location: France

Displaying mouse and keyboard state in screencasting...

Post by DoMi »

Hello
Unsuccessfuly searching for a hook displaying mouse and keyboard state in screencasting application (CamStudio) , I decided to make my own.
But I can't succeed in catching mouse and keyboard events elsewhere than in my application!?
There is my test code in "Main.pb":

Code: Select all


IncludeFile "GUI.pb"

Open_Window_0()
StickyWindow(#Window_0,1)

Procedure WinCallback(hwnd, uMsg, wParam, lParam) 
  
  Select uMsg 
    Case #WM_KEYDOWN
      Select wParam 
        Case #VK_CONTROL
          Debug "#VK_CONTROL"
          SetGadgetState(#CheckBox_Control,1)
        Case #VK_SHIFT
          Debug "#VK_SHIFT"
          SetGadgetState(#CheckBox_Shift,1)
        Case #VK_ESCAPE 
          End
        Case #VK_A To #VK_Z
          Debug Chr(wParam)
          SetGadgetText(#Text_Key,Chr(wParam))
      EndSelect
      
    Case #WM_SYSKEYDOWN
      SetGadgetState(#CheckBox_Alt,1)
      
    Case #WM_LBUTTONDOWN
      SetGadgetState(#CheckBox_Souris_Gauche,1)
    Case #WM_RBUTTONDOWN
      SetGadgetState(#CheckBox_Souris_Droite,1)
    Case #WM_MBUTTONDOWN
      SetGadgetState(#CheckBox_Souris_Milieu,1)
      
    Case #WM_KEYUP
      Select wParam 
        Case #VK_CONTROL
          Debug "#VK_CONTROL up" 
          SetGadgetState(#CheckBox_Control,0)
        Case #VK_SHIFT
          Debug "#VK_SHIFT up" 
          SetGadgetState(#CheckBox_Shift,0)
        Case #VK_ESCAPE 
          Debug "#VK_ESCAPE up" 
        Case #VK_A To #VK_Z
          SetGadgetText(#Text_Key,"")
      EndSelect
      
    Case #WM_SYSKEYUP
      SetGadgetState(#CheckBox_Alt,0)
      
    Case #WM_LBUTTONUP
      SetGadgetState(#CheckBox_Souris_Gauche,0)
    Case #WM_RBUTTONUP
      SetGadgetState(#CheckBox_Souris_Droite,0)
    Case #WM_MBUTTONUP
      SetGadgetState(#CheckBox_Souris_Milieu,0)
      
      
  EndSelect 
  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure

SetWindowCallback(@WinCallback())
Repeat ; Start of the event loop
  
  Event = WaitWindowEvent()
  WindowID = EventWindow()
  GadgetID = EventGadget()
  EventType = EventType()
  
  Select Event 
    Case #PB_Event_Gadget
      Select GadgetID
        Case #CheckBox_Souris_Gauche
        Case #CheckBox_Souris_Droite
        Case #CheckBox_Souris_Milieu
        Case #CheckBox_Shift
        Case #CheckBox_Control
        Case #CheckBox_Alt
          ; Case #Button_quit
          ; End 
      EndSelect
  EndSelect
  
Until Event = #PB_Event_CloseWindow ; End of the event loop

End
;
and in "GUI.pb" :

Code: Select all

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #CheckBox_Souris_Gauche
  #CheckBox_Souris_Droite
  #CheckBox_Souris_Milieu
  #CheckBox_Shift
  #CheckBox_Control
  #CheckBox_Alt
  #Frame3D_souris
  #Frame3D_clavier
  #Text_Key
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 295, 66, 180, 90, "Etat souris/clavier",  #PB_Window_SystemMenu);#PB_Window_BorderLess,
    If CreateGadgetList(WindowID(#Window_0))
      CheckBoxGadget(#CheckBox_Souris_Droite, 15, 20, 50, 20, "Droite")
      CheckBoxGadget(#CheckBox_Souris_Milieu, 15, 40, 50, 20, "Milieu")
      CheckBoxGadget(#CheckBox_Souris_Gauche, 15, 60, 65, 20, "Gauche")
      CheckBoxGadget(#CheckBox_Shift, 90, 20, 55, 20, "Shift")
      CheckBoxGadget(#CheckBox_Control, 90, 40, 55, 20, "Control")
      CheckBoxGadget(#CheckBox_Alt, 90, 60, 55, 20, "Alt")
      Frame3DGadget(#Frame3D_souris, 5, 5, 75, 75, " Souris ")
      Frame3DGadget(#Frame3D_clavier, 85, 5, 65, 75, " Clavier ")
      TextGadget(#Text_Key, 152, 15, 25, 15, "")
    EndIf
  EndIf
EndProcedure
Thanks for your help
DoMi
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Maybe some type of global hook? There are examples in the forums.
DoMi
User
User
Posts: 67
Joined: Sat Jan 10, 2004 5:41 pm
Location: France

Post by DoMi »

It looks like to be the right topic
Thanks
DoMi
Post Reply