One way is to use the GetForegroundWindow() Windows API. In case the
user is in a dialog window, you might need to step back through the
ownership chain to get the real main window. Then check the window class
name for the application's main window, often that gives away the
application.
Best regards,
Jari Williamsson
Thank you very much, this seems to work:
Win32API.new("user32","GetForegroundWindow",[],"N").call
The only problem I have now is that the above example returns an
integer of a pointer / program id?
Now I have searched on google for an half an hour but I cannot find
out how to get the name of the process returned by the Win32API.
Thanks in advance