Jump to content
Sign in to follow this  
snowman533

problem with listing processes to file

Recommended Posts

snowman533

hey guys im working off one of the exampels in the help file, i am trying to get it to list all processes to a txt file

here is the code:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
; List all processes
#Include <File.au3>
$rfile = "processes.txt"
$list = ProcessList()
for $i = 1 to $list[0][0]
  ;msgbox(0, $list[$i][0], $list[$i][1])
_FileWriteFromArray($rfile, $list[$i])
next

; List just notepad.exe processes
$list = ProcessList("notepad.exe")
for $i = 1 to $list[0][0]
  msgbox(0, $list[$i][0], $list[$i][1])
next

and attached is the error im getting, can anyone help with this?

error.txt


Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
EdwardTFN

Dear Snowman, try the following code:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
; List all processes
;#Include <File.au3>
$rfile = "processes.txt"
$list = ProcessList()
for $i = 1 to $list[0][0]
  ;msgbox(0, $list[$i][0], $i & " = " & $list[$i][1])
  FileWriteLine($rfile, $list[$i][0] & @TAB & $list[$i][1])
next

; List just notepad.exe processes
$list = ProcessList("notepad.exe")
for $i = 1 to $list[0][0]
  msgbox(0, $list[$i][0], $list[$i][1])
next

The problem was the way you were calling the array... Note that you don't need to invlude File.Au3 in this example, then you executable will be smaller...

Edited by EdwardTFN

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.