[System.Idle] event is not working under certain conditions

Found a bug in EventGhost? Report it here.
Snowbird
Experienced User
Posts: 115
Joined: Fri Jul 03, 2009 10:04 am

[System.Idle] event is not working under certain conditions

Post by Snowbird » Thu Jul 24, 2014 12:01 pm

Hello everyone,

I have a bug that bugs me for a while and I never had the time to report it here, and now is the time :).

Ok, here's a quick information of my setup, Win7 x64 with latest version of EG 0.4.1 r1669.

I use a lot the [System.Idle] event to do many things, for example to lock my windows session after a certain time, turn off my display, and so on. What I do, is to wait for example 2 minutes of inactivity of my computer to let the [System.Idle] event Fired up by itself, and then I run the macro with all my required actions, and if in the meantime I move my mouse or type anything it resets the 2 minutes timer, and this works perfectly except under certain conditions. Some applications, for example when I'm using the "Windows Task Scheduler", even though I'm moving the mouse or typing anything within this application, the [System.Idle] event is still fired ! and it shouldn't because there is activity. There are some other applications where this behavior occurs, like Acrobat Reader for example, and some others... but in most cases all my other applications work as expected with this [System.Idle] event (ie. if there is activity, the event is not fired).

Does anyone else have this issue except me ? This bug has been around for months, maybe more.

Thank you for any help or advice you could provide.

orlum
Posts: 1
Joined: Sun Oct 05, 2014 11:42 am

Re: [System.Idle] event is not working under certain conditi

Post by orlum » Sun Oct 05, 2014 11:57 am

I found a workaround for this bug. Just generate an insignificant keyboard or mouse windows message before calling Set Idle Time.

Code: Select all

# workaround for bug "Idle/UnIdle events doesn't fire after call [Set Idle Time]" 
eg.win32api.keybd_event(0, 0, 0, 0)

Snowbird
Experienced User
Posts: 115
Joined: Fri Jul 03, 2009 10:04 am

Re: [System.Idle] event is not working under certain conditi

Post by Snowbird » Sun Aug 23, 2015 10:04 am

Hello,

Thanks for your suggestion but it didn't work !

I have made a deeper investigation and finally find out what was causing this bug (Pako, if you're around you should read :) ).

When you run a program in "elevated" mode (run as admin), while you are using this program EG doesn't see any events that may occur in the meantime, that is why the "idle/unidle" events were not seen ! :)

You can reproduce this bug anytime with any program, here's how to do it :
- in EG set an idle timer to 3 seconds for example,
- then run "Notepad" in elevated mode (run as admin),
- then start typing a text, and, stop typing for 3 seconds or more,
>> an idle event should be generated in EG, but it won't until you switch to another program.

Is there a way to fix this bug ? we should be able to trigger an event while using a program in elevated mode.

Thanks.

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: [System.Idle] event is not working under certain conditi

Post by skribb » Thu Apr 28, 2016 8:15 am

Snowbird wrote:Hello,

When you run a program in "elevated" mode (run as admin), while you are using this program EG doesn't see any events that may occur in the meantime, that is why the "idle/unidle" events were not seen ! :)

Thanks.

System.Unidle isn't registrering. This doesn't happen all the time. But a few days out of the week I notice that EG doesn't log system.unidle, or sometimes the event shows up in the log a minute later.

I'm pretty sure I'm not running anything in elevated mode from EG - or could it be that this bug appears when any program is run elevated, even if said program wasn't launched from within EG?
Automation is life.

Win7 64bit
EG: r1722

Snowbird
Experienced User
Posts: 115
Joined: Fri Jul 03, 2009 10:04 am

Re: [System.Idle] event is not working under certain conditi

Post by Snowbird » Mon Jun 26, 2017 10:48 am

yes, this happens even when you run a program on its own, i.e. that hasn't been launched by EG, and this behavior is there for any program as long as you run it in elevated mode.

This problem is still there even with EG 0.5 RC2, here's an easy way to reproduce this odd behavior, just open notepad in elevated mode, type some text inside just to simulate activity for a minute (if you have set the idle time to 1min), and you will see that while your still typing an idle event occurs, this is not normal...

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: [System.Idle] event is not working under certain conditi

Post by skribb » Mon Jun 26, 2017 11:27 am

Snowbird wrote:yes, this happens even when you run a program on its own, i.e. that hasn't been launched by EG, and this behavior is there for any program as long as you run it in elevated mode.

This problem is still there even with EG 0.5 RC2, here's an easy way to reproduce this odd behavior, just open notepad in elevated mode, type some text inside just to simulate activity for a minute (if you have set the idle time to 1min), and you will see that while your still typing an idle event occurs, this is not normal...
i actually haven't experienced this bug lately, as far as I can tell. I know I have a few apps running in elevated mode and as of right now I have one idle timer in EG which closes an app after 2 hours idle, and thus far it has always closed that app.

orlum wrote:I found a workaround for this bug. Just generate an insignificant keyboard or mouse windows message before calling Set Idle Time.

Code: Select all

# workaround for bug "Idle/UnIdle events doesn't fire after call [Set Idle Time]" 
eg.win32api.keybd_event(0, 0, 0, 0)
Color me dumb I guess but what is "Set idle time"?
Automation is life.

Win7 64bit
EG: r1722

Snowbird
Experienced User
Posts: 115
Joined: Fri Jul 03, 2009 10:04 am

Re: [System.Idle] event is not working under certain conditi

Post by Snowbird » Mon Jun 26, 2017 1:30 pm

i actually haven't experienced this bug lately, as far as I can tell. I know I have a few apps running in elevated mode and as of right now I have one idle timer in EG which closes an app after 2 hours idle, and thus far it has always closed that app.
There has been some improvements, just to recap a bit :
  • - before there was no System.Idle event fired when a program launched in elevated mode was in focus and when there was no activity (mouse moving or keyboard presses), this has been fixed, I don't remember when exactly though.

    - Now the problem is a bit different but still related in a way, when a program is launched in elevated mode and is in focus and when you type something or move the mouse within the program, the System.Idle event is still fired ! and it shouldn't since we're doing some activities...
Color me dumb I guess but what is "Set idle time"?
no one is dumb here, we're just learning that's all :wink: I am myself struggling with some "easy" things :P
--> Set Idle Time is an action ( location : Add Action > System > Set Idle Time) that you can use to change the default Idle Time which is 60 seconds if I'm not mistaken, you can set it to whatever value you want it will fire the System.Idle event accordingly, that's it.

Regarding the workaround suggested by Orlum, I don't think it works.

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: [System.Idle] event is not working under certain conditi

Post by skribb » Mon Jun 26, 2017 2:56 pm

Snowbird wrote:
i actually haven't experienced this bug lately, as far as I can tell. I know I have a few apps running in elevated mode and as of right now I have one idle timer in EG which closes an app after 2 hours idle, and thus far it has always closed that app.
There has been some improvements, just to recap a bit :
  • - before there was no System.Idle event fired when a program launched in elevated mode was in focus and when there was no activity (mouse moving or keyboard presses), this has been fixed, I don't remember when exactly though.

    - Now the problem is a bit different but still related in a way, when a program is launched in elevated mode and is in focus and when you type something or move the mouse within the program, the System.Idle event is still fired ! and it shouldn't since we're doing some activities...
Color me dumb I guess but what is "Set idle time"?
no one is dumb here, we're just learning that's all :wink: I am myself struggling with some "easy" things :P
--> Set Idle Time is an action ( location : Add Action > System > Set Idle Time) that you can use to change the default Idle Time which is 60 seconds if I'm not mistaken, you can set it to whatever value you want it will fire the System.Idle event accordingly, that's it.

Regarding the workaround suggested by Orlum, I don't think it works.

Thanks for the info
Automation is life.

Win7 64bit
EG: r1722

User avatar
kgschlosser
Site Admin
Posts: 2889
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: [System.Idle] event is not working under certain conditi

Post by kgschlosser » Mon Jun 26, 2017 3:32 pm

OK guys going to give you a little bit of information on how the window notification system and the UAC work in respect to these. Now I could be wrong in this because I am really going to try and pull this one out of my ^#@. But here goes.

There is no "bug" per say with the system idle events. it is how windows is designed. EventGhost only posts events for notifications it receives from Windows. and the reason this behavior changes is because technically speaking when you move the mouse over a window that is controlled by another user the technical logged in user goes dormant and can become "Idle" System is not meant for System as in Computer System. System is more intended to identify the plugin causing the event. It is simply telling you that the current logged in session has become Idle. in which is has become idle because whatever you are doing is being done in a different session technically. The event really should have been System.Session.Idle. as to not cause confusion in what the definition of Idle actually means.
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 115
Joined: Fri Jul 03, 2009 10:04 am

Re: [System.Idle] event is not working under certain conditi

Post by Snowbird » Mon Jun 26, 2017 4:46 pm

you're absolutely right, that's what I had noticed back then when running EG as admin, every program launched as admin would behave properly, but i didn't know the right explanation, now I understand better. So the only possible solution would be to run EG with 2 different contexts :) one as admin and one as the current logged in user, this way it will catch everything in theory. But it's impossible to do what I'm saying, so I guess we're stuck with this behavior !

User avatar
kgschlosser
Site Admin
Posts: 2889
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: [System.Idle] event is not working under certain conditi

Post by kgschlosser » Mon Jun 26, 2017 5:10 pm

start eg with -m or -multiload

from a command line of course :-D

if you want to start it as a specific user then you would do the following

Code: Select all

runas /user:COMPUTER_NAME\USER_NAME "c:\program files (x86)\eventghost\eventghost.exe -multiload"
where COMPUTER_NAME is the name of your computer
and USER_NAME is the user account name.

when prompted for a password you will need to enter it.
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 115
Joined: Fri Jul 03, 2009 10:04 am

Re: [System.Idle] event is not working under certain conditi

Post by Snowbird » Mon Jun 26, 2017 5:13 pm

LOOOOL nice patching :p

I will stay like this, it's ok :)

User avatar
kgschlosser
Site Admin
Posts: 2889
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: [System.Idle] event is not working under certain conditi

Post by kgschlosser » Mon Jun 26, 2017 5:15 pm

now you can get really slick with this and have a specific tree load depending on the user. is you specify a generic tree name so each tree you save has the same filename and you save it into My Documents depending on the user you run eventghost with it will load the tree from that user account automatically. so this way if you want to have a specific user accound monitor for different things you will not have to worry about which save file to open. I think this should work. it all depends on how the save location is stored. I would have to double check on that.

but in the event it is not saved to the config file in a manner that would allow for the above example. then we could specify the save file to load

Code: Select all

runas /user:COMPUTER_NAME\USER_NAME "c:\program files (x86)\eventghost\eventghost.exe %PROFILEPATH%\documents\SAVE_FILE.egtree -multiload"
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 2889
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: [System.Idle] event is not working under certain conditi

Post by kgschlosser » Mon Jun 26, 2017 5:16 pm

you said impossible. I am showing you that it's not. :-D with some flare added.
If you like the work I have been doing then feel free to Image

skribb
Experienced User
Posts: 157
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: [System.Idle] event is not working under certain conditi

Post by skribb » Tue Jul 04, 2017 8:42 am

I just saw in my log that System.UnIdle was fired while I was asleep (I live alone and don't have any pets so...). Could this be related to what's been discussed in this thread?
Automation is life.

Win7 64bit
EG: r1722

Post Reply