Jump to content

How to Trigger a Function, Without Resetting the PC's Idle Time?


Zohar
 Share

Recommended Posts

Hello

I need to be able to Execute a Function, but I cannot do it via a Keyboard press or Mouse Click,

since both of them Reset the PC's Idle Time.

Anyone has an Idea for me?

Please note, a Timer will not be good, since I do not know beforehand when I want to call the function.

I need to be able to call it instantly

Please write me any creative/wild idea you have..

Thank you

Link to comment
Share on other sites

Hello

I need to be able to Execute a Function, but I cannot do it via a Keyboard press or Mouse Click,

since both of them Reset the PC's Idle Time.

Anyone has an Idea for me?

Please note, a Timer will not be good, since I do not know beforehand when I want to call the function.

I need to be able to call it instantly

Please write me any creative/wild idea you have..

Thank you

Why can't you call it when the conditions arrise for it to be called? Do the conditions occur outside of the PC? In which case have something outside which tells the program on the PC, using bluetooth, tcpip, udp, usb or serial port for example.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi Martin

Why can't you call it when the conditions arrise for it to be called? Do the conditions occur outside of the PC?

Does it happen to you sometime, that your HardDrive starts to work, despite the fact that you did nothing at the moment?

Not only that you did nothing, but the PC has been idle, and some application, or windows itself, decided to do some background work when you're away,

so it will not interfere your work.

This is good, however neither Windows, nor any application, invested in the thought that the user might ask himself

"What the hell is my PC doing??? Why is the HardDisk working so much? and on what??".

A good developer, would've shown some TrayTip, to indicate what operation is being done, that dig so deeply in your harddrive, for example:

"Windows is Deleting Temporary Files"

"Windows Malicious Removal Tool is Scanning your PC for Malware"

"Messenger is Downloading New Advertizements"

etc.

But no..

They did not put a TrayTip.

So you have to Guess what application is doing what.

And Hope it's not a Virus/Troyan, scanning your harddisk and sending the file list to someone else :)

Anyhow,

If you try to press Ctrl-Shift-ESC(to launch Task Manager) while your harddrive is being grinded,

You'll most likely get Task Manager, but the background process will stop doing it's work, since it noticed your not away anymore :)

So what I did is created a very small script that Launches Task Manager, and Sorts the Processes by CPU Consumption.

Here it is:

Run("C:\WINDOWS\System32\Taskmgr.exe")
WinWaitActive("Windows Task Manager")

Opt("MouseCoordMode",2)
    ;Switching to the Processes Tab
    MouseClick("left",105,13,1,0)       ;Tab:   Processes
    
    ;Sorting the ListView by CPU, Descending
    MouseClick("left",185,50,1,0)       ;ColumnHeader:  CPU
    Sleep(500)
    MouseClick("left",185,50,1,0)       ;ColumnHeader:  CPU
    
    ;Moving Away the Mouse
    MouseMove(685,10,0)
Opt("MouseCoordMode",1)

Now I only need a way to Launch this code, without resetting the Idle counter.

That way, I get Task Manager to load, AND not interfere the background process.

And now to some ideas I thought about, for activating/triggering without affecting the Idle Counter:

One nice way, can be the CD/DVD Drive's button.

If I could detect when the DVD Drive is open, then I could trigger the above mentioned script.

I checked to verify that opening the CD/DVD Tray does not affect the idle timer, and it does not.

The only problem is that after searching the forums here, I found out that it's not really possible to check the CD/DVD's state(Open/Closed).

:P

So I will have to use other ideas.

have something outside which tells the program on the PC, using bluetooth, tcpip, udp, usb or serial port for example.

yeah.

1 way is to buy a USB Button.

If anyone has more ideas, prefereably ones that do not require you to use another computer for the trigerring(like you need with TCP/IP, etc),

It would be really helpful.

Thank you

Edited by Zohar
Link to comment
Share on other sites

Personally I find it annoying when I get an excess of tray tips. "Anti-Virus database has been updated!" That's fantastic, but that's normal. Why not tell me if there's a problem. Ideally things should be logged to Event log.

If you want to track CPU / disk usage, try performance monitor: start->run->perfmon.

You can get it to track individual process CPU time or Disk IO, and get it to save the log for later examination.

I don't know what event you're trying to capture, but if Windows XP hasn't done it in the past 3 days, after 30 minutes of idle activity it will do a boot layout defrag.

controlled in: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction] and [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout] or via TweakUI.

Windows Vista will just continuously thrash the hard drive as part of the SuperPrefetch service.

Alternatively you may want it to trigger based on something like Idle time greater than 5 minutes, and CPU usage > 40%?

I'll have to check, but maybe you could do something simple like inserting a USB flash drive, and have your script monitor and wait for the drive to appear? That might not reset the idle counter.

If the computer is on a network, you could try disconnecting the ethernet cable, or switch a hardware Wifi switch, and have the script monitor for IP addresses to dissapear.

Edited by TurionAltec
Link to comment
Share on other sites

Obviously substituting the appropriate path and volume label for a flash drive, this works without resetting the counter:

#Include <Timers.au3>

AdlibEnable("Idletime",1000)

Do
    sleep(1000)
Until DriveGetLabel ("h:") = "Flashdrive"

run("taskmgr.exe")
ConsoleWrite("Found flash drive"&@CRLF)
While 1
    sleep(1000)
WEnd


Func Idletime()
    ConsoleWrite(_Timer_GetIdleTime()&@CR)
EndFunc
Link to comment
Share on other sites

Hi TurionAltec and Inverted

First, Regarding Performance Monitor, it's really nice, I didn't know it can save logs, and periodically even..

nice!

You could also do it in AutoIt with a resident script that takes process snapshots every second or so.

won't that take alot of CPU?

(you would do it with WMI?)

I'll have to check, but maybe you could do something simple like inserting a USB flash drive, and have your script monitor and wait for the drive to appear? That might not reset the idle counter.

that's a terrific idea!

it's like the USB Button idea, but without the button!!!

very nice(:

I will use it.

BTW

I had an idea to use the Screen's Power Button, but apparently it's not possible to detect screen power on/off.

too bad, it could've been nice :)

Edited by Zohar
Link to comment
Share on other sites

What OS do you use? In Vista there is so called reliability and performance monitor with several simple categories like CPU,disk,network,memory and it shows nicely which process does the most disk writes/reads or uses the most CPU power and so. And it is not just the actual status but it keeps average numbers for a while so you can see it even after you stop the idle status. That's something I realy like in Vista. In 7 it is probably the same I guess.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...