ShavedJesus
New member
- Joined
- Mar 17, 2021
- Messages
- 4
- Programming Experience
- 3-5
Hello all,
I'm developing a background application which detects keys pressed by the user and perform some operations accordingly.
I already developed the low-level part which detects keys pression. What I need is any tip to understand, anywhere at OS level (so also outside of my application), which window is focused (I think something like this should do the job:
)
but, mostly, to understand if the user is focusing a control where text can be inserted.
Given example:
my application is in the background. The user opens Google Chrome and starts typing a URL in the address bar. At this point, I do need to understand that the focus is on Goggle Chrome application and the user is typing text in a textbox.
Is it possible to make this? If yes, I'm not asking a full solution (even if would be good to have), but just a starting point because I tried to search but unsuccessful.
Thanks a lot in advance.
I'm developing a background application which detects keys pressed by the user and perform some operations accordingly.
I already developed the low-level part which detects keys pression. What I need is any tip to understand, anywhere at OS level (so also outside of my application), which window is focused (I think something like this should do the job:
C#:
IntPtr foregroundWindow = GetForegroundWindow();
uint foregroundProcess = GetWindowThreadProcessId(foregroundWindow, IntPtr.Zero);
but, mostly, to understand if the user is focusing a control where text can be inserted.
Given example:
my application is in the background. The user opens Google Chrome and starts typing a URL in the address bar. At this point, I do need to understand that the focus is on Goggle Chrome application and the user is typing text in a textbox.
Is it possible to make this? If yes, I'm not asking a full solution (even if would be good to have), but just a starting point because I tried to search but unsuccessful.
Thanks a lot in advance.