How to get key board entries on windows explorer ?
-
Hello, I have a requirement of triggering my application on Ctrl+d only when user is in Windows Explorer. For that I have an ahk script which works perfectly..
#IfWinActive ahk_class CabinetWClass
^d::
Run "C:\myapp.exe"
return
#IfWinActive ; turn off context sensitivityBut I want implement the same in C#, While searching I came to know that this can be done using Autohotkey.dll from this site But no where I got any working dll. How to achieve in my requirement in c# ? I got a project which gets the keyboard entries when it is in foreground but how to catch the keyboard entries of other window (In my case Windows Explorer) while my app is running in background? Please help.
-
Hello, I have a requirement of triggering my application on Ctrl+d only when user is in Windows Explorer. For that I have an ahk script which works perfectly..
#IfWinActive ahk_class CabinetWClass
^d::
Run "C:\myapp.exe"
return
#IfWinActive ; turn off context sensitivityBut I want implement the same in C#, While searching I came to know that this can be done using Autohotkey.dll from this site But no where I got any working dll. How to achieve in my requirement in c# ? I got a project which gets the keyboard entries when it is in foreground but how to catch the keyboard entries of other window (In my case Windows Explorer) while my app is running in background? Please help.
You can see an answer on how to use RegisterHotKey here[^]. Inside the handler you would have to get the currently active window handle using GetForegroundWindow function (Windows)[^]. You then pass that handle to the GetWindowThreadProcessId function (Windows)[^] to get the Process ID (PID) of the window. Compare that to the list of Process ID's you can get from the Process class and make sure the process name is "Explorer.exe". If there's a match, do whatever you need to do.
A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak