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.

Useful code to detect Window Title context?

If you have a question or need help, this is the place to be.
Post Reply
slewis
Posts: 6
Joined: Sun Nov 29, 2009 5:50 pm

Useful code to detect Window Title context?

Post by slewis »

I'm sharing the following short sequence of python commands that I've found extremely useful for detecting my application context, such as a browser whose context is best detected from the Window Title (because it's inadequately exposed by the events in the Task plugin):

Code: Select all

eg.result=eg.WinApi.GetWindowText(eg.WinApi.Dynamic.GetForegroundWindow())
eg.result.split(' - ')[0]=="YouTube XL"
If successful jump to SetYouTubeXLContext
I am posting them here for the benefit of others (as it took me quite some effort to work this out as a non-python coder), and to ask if anyone knows a simpler (non-python) way to do this?

And if not, perhaps some kind plugin developer out there might consider developing a new plugin (or enhancing the Windows plugin?) to support this functionality in a more user friendly manner, e.g.

Code: Select all

If ForegroundWindowTitle matches "YouTube XL - *" jump to SetYouTubeXLContext
Steve
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Useful code to detect Window Title context?

Post by jinxdone »

Good idea. I'll put it on my to-do list incase nobody beats me to it.

I'm thinking a general purpose regexp (or just plain string compare) action would be useful too, so you could compare the eg.result and other variables and do some conditional jumps etc. based on that. It'd be easier to use for simple comparisons than having to use a python script each time.
Post Reply