It is currently Fri Apr 10, 2020 2:21 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [LIBRARY] WIH - Mouse & Keyboard Library [Windows x64]
PostPosted: Sun Mar 15, 2020 11:34 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 638
WIH (Window Input Handler)
wih.lib is a small library to handle mouse and keyboard input.

Example:
Code:
;WIH - WINDOW INPUT HANDLER
;A SMALL LIBRARY TO HANDLE MOUSE AND KEYBOARD INPUT
;AUTHOR: MIJIKAI
;VERSION: 1.0

EnableExplicit

Import "wih.lib"
  wihCreate.i(hwnd.i)
EndImport

Interface WIH
  Focus.i()                       ;is the window focused / is the input attached to the window thread!
  Key.i(Code.i)                   ;is the key pushed? / use #VK key-codes
  KeySgl.i(Code.i)                ;was the key pushed? / use #VK key-codes
  KeyChr.i()                      ;get the chr key code of the pushed key
  MouseCheck.i()                  ;is the mouse inside the client area of the window
  MouseLeft.i()                   ;is the left mouse button pushed?
  MouseRight.i()                  ;is the right mouse button pushed?
  MouseMiddle.i()                 ;is the middle mouse button pushed?
  MouseLeftSgl.i()                ;was the left mouse button pushed?
  MouseRightSgl.i()               ;was the right mouse button pushed?
  MouseMiddleSgl.i()              ;was the middle mouse button pushed?
  MouseLeftDbl.i()                ;was the left mouse button pushed twice in a short time? / doubleclick!
  MouseRightDbl.i()               ;was the right mouse button pushed twice in a short time? / doubleclick!
  MouseMiddleDbl.i()              ;was the middle mouse button pushed twice in a short time? / doubleclick!
  MouseWheel.i(Code.i = #Null)    ;was the mousewheel moved? / optional check if a special key is pressed!
  MouseX.i()                      ;get the mouse horizontal (x) postion / offset from the top left corner of the client area!
  MouseY.i()                      ;get the mouse verical (y) postion / offset from the top left corner of the client area!
  Flush.i()                       ;flush the input buffers / needed for all 'Sgl' and 'Dbl' functions to work properly!
  Release.i()                     ;release the input handler and all associated resources
EndInterface

Procedure.i Demo(Title.s = #Null$,Width.i = 600,Height.i = 400)
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *input.WIH
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    *input = wihCreate(WindowID(wnd))
    If *input
      Repeat
        Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
            wnd_exit = #True
        EndSelect
        ;-------------------------------
        ;check mouse and keyboard input!
        If *input\MouseLeftDbl()
          Debug "DoubleClick!"
        EndIf
        ;-------------------------------
        *input\Flush();<- when done flush the input buffers!
      Until wnd_exit
      *input\Release();<- release all resources
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

Demo("WIH")

End


Download:
https://www.dropbox.com/s/9bzqhhsb5iehnoz/wih_v1.0.zip?dl=0


Top
 Profile  
Reply with quote  
 Post subject: Re: [LIBRARY] WIH - Mouse & Keyboard Library [Windows x64]
PostPosted: Sun Mar 15, 2020 2:35 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6106
Location: Wales, UK
...but where is the library?

Ah! Linked to DropBox :mrgreen:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye