jaberwacky Posted May 26, 2018 Share Posted May 26, 2018 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 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted May 26, 2018 Author Share Posted May 26, 2018 (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 May 26, 2018 by jaberwacky Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted May 26, 2018 Author Share Posted May 26, 2018 (edited) Actually, no, I did not. Now it won't copy selected text. Edited May 26, 2018 by jaberwacky Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Bilgus Posted May 26, 2018 Share Posted May 26, 2018 (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 May 26, 2018 by Bilgus Link to comment Share on other sites More sharing options...
Bilgus Posted May 26, 2018 Share Posted May 26, 2018 See SendKeyLL here: you can use that to send your key up events Link to comment Share on other sites More sharing options...
jaberwacky Posted May 26, 2018 Author Share Posted May 26, 2018 Sorry. I meant that I don't want the numbers to be sent to the window which has the highlighted text. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
seandisanti Posted May 27, 2018 Share Posted May 27, 2018 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now