Jump to content

problem with listing processes to file


Recommended Posts

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

Link to comment
Share on other sites

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
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...