Page 1 of 1

[req] Detect App in Focus + If/Then State functionality

Posted: Sun Mar 08, 2009 4:35 pm
by Livin
A module tha0t would detect the running apps, and which was currently in focus.
Then would change states (enable/disable macros/folders) based on an If/Then function.
If this is already available, my apologies, I did not know how to do it. I suggest the If/Then function since the existing 'state' functionality is a bit confusing and seems more complicated and difficult to follow, in comparison.

Example...

State App1_In_Focus
IF <app1> infocus THEN
disable <app4 keyboard emulation>
enable <app 1 keyboard emulation>
End If
End State

State App1_No_Focus
IF <app4> nofocus THEN
enable <app1 keyboard emulation>>
close <app4>
End If
End State

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 7:28 am
by jinxdone
Load up the "Task Create/switch events" plugin. Switch between some applications.

You will see it logs events Task.Activated.* and Task.Deactivated.*, you can use these to enable parts of the config when you switch between applications.

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 8:30 am
by Pako
You can find an example of how to detect whether the application has focus in this topic:
http://www.eventghost.org/forum/viewtop ... f=2&t=1218
Pako

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 3:39 pm
by Livin
jinxdone wrote:Load up the "Task Create/switch events" plugin. Switch between some applications.

You will see it logs events Task.Activated.* and Task.Deactivated.*, you can use these to enable parts of the config when you switch between applications.
Is there any how-to/docs on how to use this? I can add a Task but it does not have a config, and it is not intuitive as how to use it?

We really need If/Then statements... they are intuitive and most everyone knows how to use them if they have ever used any coding/scripting language.

I have suggested it before but I think that making a clear separation of EG's "logic" from "commands" makes sense. Today it is just too jumbled... or maybe there is just no good docs on the correct way to setup EG?

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 7:08 pm
by jsonnabend
I understand your thoughts. It takes a bit to break the "get an event and then see what's focused" approach.

In EG, you receive events whenever a new application gains focus. In response to that event, you enable the event handlers for that application and disable event handlers for other applications. It's actually easier than it sounds using "enable exclusive".

From a slightly different perspective, you run your "if/then" when you receive notice that a new application has focus, not when you receive an input event.

- Jeff

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 7:44 pm
by Livin
I need to detect specific things and run macros based on them...

App closes
App not in focus
App in focus
App opens

I see EG detect Activated or Deactivated... but I don't see how to determine if it is open or closed?

thx

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 7:53 pm
by jsonnabend
App closes=Task.Destoyed.*
App not in focus=Task.Deactivated.*
App in focus=Task.Activated.*
App opens=Task.Created.*

To see if an application is running, you can use the "Find a Window" action and then jump on whether that action was successful or not. There's a thread around here somewhere on that.

Hope that helps.

- Jeff

Re: [req] Detect App in Focus + If/Then State functionality

Posted: Mon Mar 09, 2009 8:58 pm
by Livin
jsonnabend wrote:App closes=Task.Destoyed.*
App not in focus=Task.Deactivated.*
App in focus=Task.Activated.*
App opens=Task.Created.*

To see if an application is running, you can use the "Find a Window" action and then jump on whether that action was successful or not. There's a thread around here somewhere on that.

Hope that helps.

- Jeff
good info, thanks!

I still hope for If/Then... it would be so much easier :wink: