Jump to content

Close program when screensaver becomes active via Autoit


Recommended Posts

Posted (edited)

Usage:

- u need AutoIt to compile

- change the "firefox.exe" with your .exe

- copy the .exe to system32

- add the .exe to startup via regfile (change names of destination and .exe)

The code

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1
; Author: ddSHADOW
; Version: 1.0
;
; Script Function:[code]
; Close program when screensaver becomes active
;
; ----------------------------------------------------------------------------
Opt('TrayIconHide', 1)
Opt('TrayIconDebug', 1)
Opt('WinDetectHiddenText', 1)
Opt('WinTitleMatchMode', 4)
ProcessSetPriority ( @ScriptName, 0)


;--------SELECT PROCESES---------------
$PID="firefox.exe"
;--------------------------------------

;----------FUNCTION----------
;function closeprogram
Func closeprogram($program)
$Windowname=StringSplit($program, ".")
ProcessWait($program);wait till the process run, 1st protection of cpu overheat
While ProcessExists($program)
WinWaitNotActive($Windowname[1]);wait till the process is not active, 2st protection of cpu overheat
$list = ProcessList()
for $i = 1 to $list[0][0]
If StringInStr($list[$i][0],".scr") Then
ProcessClose($program)
;MsgBox(4096, "Terminated", $program)
EndIf
next
WEnd
EndFunc
;----------------------------------
;-----START PROGRAM---------------

While ProcessExists("winlogon.exe");windows is running
closeprogram($PID)
WEnd
exit

reg file

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"checkprogram.exe"="C:\\WINXPSP2\\system32\\checkprogram.exe"

In next version i will try to make compatible for more .exe's

checkprogram.zip

Edited by --=ddSHADOW=--

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
  • Recently Browsing   0 members

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