Sign in to follow this  
Followers 0
jslegers

Creating an application killer. Need some help please

6 posts in this topic

Hi,

I have the following code :

#include <Array.au3>

#include <GUIConstants.au3>

;Defining variables

Dim $runArray[1]

Dim $prcArray[1]

Dim $pid

$varappn = IniReadSectionNames( "Apps.ini" )

;Filling Array

For $i = 1 to $varappn[0]

_ArrayAdd ( $runArray, IniRead ( "Apps.ini", $varappn[$i], "Exe", "" ))

Next

_ArrayDelete ( $runArray, 0 )

_ArrayDisplay ( $runArray, "Test" )

$list = ProcessList ()

For $i1 = 1 to $list[0][0]

_ArrayAdd ( $prcArray, $list[$i1][0] )

Next

_ArrayDelete ( $prcArray, 0 )

_ArrayDelete ( $prcArray, 0 )

_ArrayDelete ( $prcArray, 0 )

_ArrayDisplay ( $prcArray, "Test" )

;While 1

;$pid = _ArraySearch ( $runArray, "notepad.exe" )

; MsgBox ( 4096, "Test", $pid )

; Exit

;ProcessClose ( $pid )

;WEnd

As you can see there are two Array's being created the runArray and the prcArray. The ini file looks like this.

[Notepad]

Exe=notpad.exe

[Calc]

Exe=calc.exe

What I'm trying to make, is an script that closes programs with the name of the executable. First it looks in the ini file. Second it creates an array with running processes. If one or more of the exe's that are in the ini file are running the have to be killed. This has to be run in a loop so that he checks every time.

My problem is how can I use the results of runArray to kill processes that where found in the prcArray ?

John

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Alright. First off, setup your ini file so all the applications you want to kill are under ONE section, not each their own:

[Applications]Exe=notepad.exe

Exe=calc.exe

Then, you dont need to ArraySearch or cross-compare arrays of currently running processes. Instead, I think it is better to simply loop through the ones in your ini and run a "ProcessExists()" on them.

HotKeySet("{Esc}", "_Quit")

$runArray = IniReadSection("Apps.ini", "Applications") ; Read entire Applications section to an array
If Not IsArray($runArray) Then ; If nothing is returned to the array, quit program
    MsgBox(0, "Error", "There are no applications listed in the ini!")
    Exit
EndIf

While 1
    For $i = 1 To UBound($runArray) - 1 ; Loop through each app in the array, close if it exists
        If ProcessExists($runArray[$i][1]) Then ProcessClose($runArray[$i][1])
    Next
    Sleep(250)
WEnd

Func _Quit()
    Exit
EndFunc

-Simucal

EDIT: Also, you should use [ Autoit] [ /Autoit] tags to post code (without spaces).

Edited by Simucal

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Wow,

Thanks for the script and help.

Grtz.

John

Share this post


Link to post
Share on other sites

Np, hope it helps. You were just making it a little too hard on yourself.


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Error: "There are no applications listed in the ini!"

What is an ini, and can I change it?

I am looking for a script that will automatically kill any non-windows processes (open programs and everything in the system tray) that are currently running to free up cpu &/or memory for heavy applications or watching videos.


Anyone who does not wonder is either omniscient or foolish.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

An INI is a configuration file...

The script above only kills processes that are in the .ini file.

And try not to bump :/

Edited by pugboy

Share this post


Link to post
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
Sign in to follow this  
Followers 0