Jump to content

Keyboard hook still calls next hook; how to make it stop


Recommended Posts

I am making a copy/paste manager to hopefully be used by some people at my workplace.  I use a keyboard hook to both detect instances of ctrl+c which is successful.  I also use it to detect number key presses.  When a number is pressed the highlighted text is then replaced by that number.  I want to not pass on the number to the next hook.  How can I do this?  Sorry, it's been a looooong time since I did any kind of coding.  Here is a pseudocode example.

Func keyboard_hook( ... )
    Switch $ctrl_c
        Case True
            dothings()
    EndSwitch
    
    Switch $key1, $key2, $key3, etc
        Case True
            dostuff()
            
            return 1 <--- still calls the next hook anyway!
    EndSwitch
    
    Return CallnextHook(...)
EndFunc

 

Link to comment
Share on other sites

I figured it out.

 

Func keyboard_hook( ... )
    Switch $ctrl_c
        Case True
            dothings()
            
            Return CallnextHook(...)
    EndSwitch
    
    Switch $key1, $key2, $key3, etc
        Case True
            dostuff()
    EndSwitch
    
    return 1 
EndFunc

 

Edited by jaberwacky
Link to comment
Share on other sites

you have two keys there on ctrl you need to set a flag and pass through on 'C' you need to check for previous flag do your thing and (probably) send 'C' up & send ctrl UP

Edited by Bilgus
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...