Jump to content

Recommended Posts

Posted

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

 

Posted (edited)

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
Posted (edited)

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
Posted

you could just set hotkeys for while the window in question is active, rather than manually casing out keyboard hooks. Look at hotkeyset and GUISetAccelerators as alternatives

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
  • Recently Browsing   0 members

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