Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
determening the top most windows
determening the top most windows
Hello,
I want to send an event to an application only if the application is currently the active application (top most window). How can I do that ?
Thanks,
Oren
I want to send an event to an application only if the application is currently the active application (top most window). How can I do that ?
Thanks,
Oren
Re: determening the top most windows
use the find window action.
you don't send events to application but use events to trigger actions.
you don't send events to application but use events to trigger actions.
Re: determening the top most windows
I'm using the find window action. But I also want to know if that window belongs to the top most application, otherwise if want to stop.
How can I do that ?
Thanks,
Oren
How can I do that ?
Thanks,
Oren
Re: determening the top most windows
If you check the only foremost window action you will only get the foremost window.
Do you want to combine the search for a specific program and that the fact that is the foremost window?
Do you want to combine the search for a specific program and that the fact that is the foremost window?
Re: determening the top most windows
exactly, this is what i want.
Oren
Oren
Re: determening the top most windows
anyone ?
Re: determening the top most windows
This involves some scripting. Although probably only a few lines I have to take a look at the code first.
Re: determening the top most windows
i will appreciate it.
Oren
Oren
Re: determening the top most windows
anyone ?
Re: determening the top most windows
After switching to Win7 here is the script.
This sends an "A" to notepad if it is the foreground window.
This sends an "A" to notepad if it is the foreground window.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0">
<Folder Name="ForegroundWindow" Expanded="True">
<Macro Name="Emulate Keystrokes: A" Expanded="True">
<Event Name="GameVoice.Command" />
<Action>
EventGhost.PythonScript(u'from eg.WinApi.Dynamic import GetForegroundWindow\nfrom eg.WinApi.Utils import GetWindowProcessName\nhwnd = GetForegroundWindow()\nif hwnd:\n processName = GetWindowProcessName(hwnd)\n if processName == "notepad.exe":\n eg.result = hwnd\n else:\n eg.result = None\nelse:\n eg.result = None\n ')
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(1384), 1, False)
</Action>
<Action>
Window.SendKeys(u'A', False)
</Action>
</Macro>
<Macro Name="Comment" id="1384" Expanded="True">
<Action>
EventGhost.Comment()
</Action>
</Macro>
</Folder>
</EventGhost>Re: determening the top most windows
The OP didn't bother to reply and thank you Bartman. So although I'm resurrecting a dead thread, I'm doing it for him! This is one of quite a few threads I've looked through when trying to solve the same problem and your solution is the easiest to understand and use and it works great for me.
So THANK YOU!
So THANK YOU!