topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 6:13 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA Prevent/allow specified keypresses to be received by a program?  (Read 8432 times)

appyface

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 18
  • Isn't she beautiful? :-)
    • View Profile
    • Donate to Member
(I searched the web and this forum, to see if a program like this already exists, but did not find one.  If I missed, please point me to site, threads, etc. thank you!)

Is it possible, to prevent (or allow) any 'key release' event to be seen/not seen by a specified process?  While not interfering with other programs and processes that are watching the keyboard?

I have a program running in background process (WinXP Pro SP2), that monitors the keyboard.  It isn't a keylogger but it does watch for every 'key release' event (such as when alt, shift, letter keys, function keys, combinations of keys, arrows etc. are released), the program may take some action in response.  Unfortunately the program is not configurable as to what 'key releases' it watches or what actions it takes.  (I have written the author of the program to request configuration possibility, but have not yet gotten a reply.)

So in the meantime... is it possible to intercept and prevent or allow this program from seeing specific key release events?

I don't care if I need to specify a "prevent these" or "allow these" list, for my situation it's a tedious list to configure either way.  Helpful would be a wizard that presented a model of a keyboard and one could click on the keys to be considered and added to the prevent (or allow) list:
keyboard.jpg

Thank you for any help or ideas!

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #1 on: February 24, 2008, 12:12 PM »
Could you please give some examples?

Also, i think that depens on what level does that other program you mentioned scan the keyboard, but i think this might be doable.

jazper

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 92
    • View Profile
    • Jazper's Software
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #2 on: February 24, 2008, 12:17 PM »
This could be done by injecting a DLL into the process that monitors key strokes and then hook the appropriate API's that are called when key up(WM_KEYUP) happens. 




lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #3 on: February 24, 2008, 08:15 PM »
if you are familiar with Autohotkey then it can be done but only app-specific. as that way, the script will be easier on the CPU usage. e.g. in the example below, the letter 'a' won't work. is this what you're looking for?

SetTitleMatchMode, 2
#IfWinActive, - notepad
a::Return

appyface

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 18
  • Isn't she beautiful? :-)
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #4 on: February 26, 2008, 02:46 AM »
App-specific is exactly what I want, I want only to affect the one program while still allowing everything else running, to see all keyboard entries.  That script looks like it will do what I want.  I'm not familiar with Autohotkeys, would you please point me to where I can learn about it and how to use it?

Thanks and regards,
--appyface

P.S. Sorry I'm late getting back in here, I was not getting the email subscription notifications that I had replies.  Thanks again.


EDIT: I found the site for AutoHotKey, and will read up.  I am unclear, though, how this script would work?  Do I just loop it forever until I manually terminate it, so it will continually monitor and catch the keystrokes I don't want?
« Last Edit: February 26, 2008, 03:55 AM by appyface »

appyface

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 18
  • Isn't she beautiful? :-)
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #5 on: February 26, 2008, 02:54 AM »
Could you please give some examples?

Also, i think that depens on what level does that other program you mentioned scan the keyboard, but i think this might be doable.
The program reacts to all key releases, sometimes in a way that is not desirable to me.  Unforunately I cannot configure the program.  There are some keys which are action keys in my specific context (enter, function keys, combos of shift-fkey or ctrl-shift-fkey, alt-fkey, alt-shift-fkey) that I want the program to see.  But I do not want the program to see and react to letters and numbers (with or without the shift key) arrows, backspace, tab, insert, home, page up/down, punctuation.  These are "non-action" keys in my context and I don't want the program to see these and therefore it will not react to these.

Hope that makes sense?

Thanks for your response and regards,
--appyface

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #6 on: February 26, 2008, 05:18 AM »
That means i probably got it wrong.

ProgA <- program that scans the keyboard
ProgB <- program where you're now working

You want to be working in progB, and want progA to only react when you press enter,function keys, alt-fkey, etc, but not letters and numbers and such. Is this right?

If so, it sounds damn hard to do, can't you use an alternative for progA? What exactly does it do?

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #7 on: February 26, 2008, 06:16 AM »
EDIT: I found the site for AutoHotKey, and will read up.  I am unclear, though, how this script would work?  Do I just loop it forever until I manually terminate it, so it will continually monitor and catch the keystrokes I don't want?

i'm copy-pasting these from the AHK help-file..

#IfWinActive keyword creates context-sensitive hotkeys and hotstrings. Such hotkeys perform a different action (or none at all) depending on the type of window that is active or exists.

Also, multiple scripts can be running simultaneously, each with its own tray icon but AHK scripts are run-on-demand type unless there are timers, loops or the keyword #Persistent.

#Persistent keeps a script permanently running (that is, until the user closes it or ExitApp is encountered).

HTH. btw, myself or jgpaiva don't mind creating a skeleton script for you so that it is easier for you to learn and add your commands but as jgpaiva mentioned, we need for more info. ;)


appyface

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 18
  • Isn't she beautiful? :-)
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #8 on: February 26, 2008, 10:44 AM »
Thanks for help.  I tried to use the AHK but the program I want to intercept the keyboard for, does not have a window, it is a background process.  I didn't see in the command list for AHK on their website, how to target a process?  So I'm thinking AHK can't work.

I'm not sure what else you need to know about the program I'm trying to intercept?  What more information do you need?  Other programs are not involved except to the extent that I do not want to shield keypress (key *release* event, actually) from anything but this one program, so it is not a complete system block but app-specific.

As I mentioned, the program is not intended as a keylogger or spy but it behaves similarly to those.  It is listening for key *release* events and documenting what is typed by taking actions such as launching another program.  I really like this program but it is old and the author has not responded to any emails so he/she may no longer be available.  I don't need many of these actions to be performed on simple typing (my "non-action" key release events).  It isn't huge to just live with it but it would be nice if I could front-end the program with something that let only my desired "action" key release events get through to the program.

Looks like this is taking way more of your time than I ever intended.  I thought this might be something quick and also useful for other purposes.  My apologies. 

  --appyface

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #9 on: February 26, 2008, 11:22 AM »
Sorry, i didn't ask out of curiosity, my intention wasn't to seem nosey.
I asked because the good people of DC might actually know a better replacement to your program, solving your trouble with it, see what i mean?

Yes, from your description, it does sound like something that can't be done with ahk.

appyface

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 18
  • Isn't she beautiful? :-)
    • View Profile
    • Donate to Member
Re: IDEA Prevent/allow specified keypresses to be received by a program?
« Reply #10 on: February 26, 2008, 11:38 AM »
I didn't take as nosey :-)  thanks.  It is a very specialized program that would take a lot to explain and then still maybe not make sense, and what it does wasn't relevant to my request so I was trying to keep it simple...  I have looked for replacement programs but so far have not been able to find any, I believe it is a one-of-a-kind (and for good reason LOL).  I just have no need any longer for some of the functions it performs and have no way to control them.

Thank you again, best regards,
--appyface