Sign in to follow this  
Followers 0
snowman533

problem with listing processes to file

2 posts in this topic

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



#2 ·  Posted (edited)

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  
Followers 0