Hello,
i would like to trigger an action depending on the mostfront window.
Here the scenario i want to implement:
Find frontmost window
If Window1 then jump to A
If Window2 then jump to B
How can i do this? I guess with python script but what would be?
Thanks in advance,
Fabien
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.
How to get the front window name to trigger a proper action?
Re: How to get the front window name to trigger a proper act
Maybe something similar to what I used:
Find Window: ehshell.exe
Python Script:If successful jump to "AlphaNumpad1"
Find Window: ehshell.exe
Python Script:
Code: Select all
from eg.WinApi.Dynamic import (GetForegroundWindow)
if eg.lastFoundWindows and eg.lastFoundWindows[0] == GetForegroundWindow():
eg.result = False
else:
eg.result = True
Re: How to get the front window name to trigger a proper act
You could just trigger a new event with the window name + a prefix. Then just assign this this to another macro.
You may want to add the first event's name with eg.event.string, and also using the event payload instead of one long event string may be helpful..
You may want to add the first event's name with eg.event.string, and also using the event payload instead of one long event string may be helpful..
Code: Select all
from eg.WinApi import (GetWindowText)
from eg.WinApi.Dynamic import (GetForegroundWindow)
eg.TriggerEvent('Foreground.' + GetWindowText(GetForegroundWindow()))Re: How to get the front window name to trigger a proper act
Great! It works very nice
Thanks a lot!
Thanks a lot!
-
themaster1
- Experienced User
- Posts: 133
- Joined: Wed Feb 03, 2010 9:02 pm
Re: How to get the front window name to trigger a proper act
Someone give me hints i wanna do the following thing:
- Find frontmost window
- left mouse click on the window
- Find frontmost window
- left mouse click on the window
Re: How to get the front window name to trigger a proper act
Add Macro...->Window\"Find a window"themaster1 wrote:Someone give me hints i wanna do the following thing:
- Find frontmost window
Add Action...->Mouse\"Left mouse button"- left mouse click on the window
jonib
-
themaster1
- Experienced User
- Posts: 133
- Joined: Wed Feb 03, 2010 9:02 pm
Re: How to get the front window name to trigger a proper act
with a python script i mean otherwise i know how
-
eatmeimadanish
- Experienced User
- Posts: 118
- Joined: Thu Oct 01, 2009 5:11 pm
Re: How to get the front window name to trigger a proper act
Just copying actions will get you the XML and command line, just add eg.plugins before most of them and it works.
Code: Select all
eg.plugins.Window.FindWindow(u'program.exe', None, None, None, None, None, False, 0.0, 0)
eg.plugins.Mouse.LeftButton()-
themaster1
- Experienced User
- Posts: 133
- Joined: Wed Feb 03, 2010 9:02 pm
Re: How to get the front window name to trigger a proper act
Thanks for the hint, now what if i want to add "if-else" conditions.Let's say i want to get the name of the window
if window name=blabla
eg.plugins.EventGhost.ExclusiveEnablefolder blabla
if window name=blabla
eg.plugins.EventGhost.ExclusiveEnablefolder blabla
