marffin

hi everybody

I'm trying to write an application to redirect hotkeys of specific program. For example, in notepad, if the user press "ctrl+s", that means save. But I really want to assign the save action another hotkey and of cause, without modifying the notepad program itself. Unfortunatley I was stucked at the first step: How can I recognize the process of the certain program I'm targeting at I'm using C#

Sorry for this question may sound a little bit stupid but I do not write .net program often and I'm not quite familiar with .net API and architecture. I even have a little doubt if it's possible to write such a "hotkey redirection" program. Anyway, I really need it and thank you very much if you can give me some advice




Re: Common Language Runtime How to recognize process?

Roman S.

The following code demonstrates, how to get Process object for "notepad.exe" (Notepad must be launched):

foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses(Environment.MachineName))

{

if (p.ProcessName.ToLower() = "notepad.exe")

{

//Apply some actions

}

}

But you cannot redirect hot keys from managed code. You must use window hooks (see WinAPI).






Re: Common Language Runtime How to recognize process?

marffin

Thank you very much Roman, that helps a lot

I've already figure out how to hook and intercept keyboard messages. I think the next step is to send a new keyboard message to the target process. It seems RegisterHotkey() function is not the only way to process hotkeys in a program. But are they essentially the same all based on keyboard message