Jump to content

Recommended Posts

  • Deye changed the title to why this restriction?
Posted

So, you're wanting to know why an empty array is returned when you pass an empty string to ProcessList()?

Only a dev can say for sure, but my guess is that ProcessList detects the existence of the parameter without checking for "", Default, etc.

P.S. $iPID isn't a great name here IMO since doesn't contain and integer or a PID 😉

Posted

Thanks  Danp2,

This is just a point made in order to illustrate the limitation.

Posted

I'd say it's more of an over-sight. The documentation says that it searches for a name when it is specified, so technically you did specify a name albeit it doesn't contain any words, so it doesn't match anything.

Did you try with values other than an empty string? I'd suggest trying Default, 0, Null, False etc.

In any case, this should be filed as a bug so that the check also takes an empty string into account.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted

@Danp2 Right, I'd guess there is type casting happening here which converts all values to strings, and all of the values except 0 and False should turn into empty strings. In any case, doesn't look like it's possible to achieve the default behavior without using hacks like this:

Func ProcessListFixed($iPID = "")
    If $iPID = "" Then
        Return ProcessList()
    Else 
        Return ProcessList($iPID)
    EndIf
EndFunc

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted
  On 1/20/2022 at 6:16 PM, Danp2 said:

So, you're wanting to know why an empty array is returned when you pass an empty string to ProcessList()?

Only a dev can say for sure, but my guess is that ProcessList detects the existence of the parameter without checking for "", Default, etc.

P.S. $iPID isn't a great name here IMO since doesn't contain and integer or a PID 😉

Expand  

@Danp2 function should check/detect the existence of parameter but the question os what it should to do when there is no parameter given ?

Taking a look into documenation:

https://www.autoitscript.com/autoit3/docs/functions/ProcessList.htm

  Quote

ProcessList

Returns an array listing the currently running processes (names and PIDs).

ProcessList ( ["name"] )

Parameters

name [optional] If a name is given only processes of the same name will be returned.
Expand  

as you can see the "name" parameter is optional, and descripition for parameters doesn't say anything what will do when the parameters is not given.
There is statement 

  Quote

Returns an array listing the currently running processes

Expand  

So we can only guess that it should return all running processes.

I think we must wait to check it by dev I propose to wait for @jpm  presence.
Hope he will be able answer soon.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

But first of all.

@Deye please check this code:

#include <Array.au3>

Example()

Func Example()
    ; Display a list of processes returned by ProcessList
    Local $aProcessList = ProcessList()
    _ArrayDisplay($aProcessList, '$aProcessList')
EndFunc   ;==>Example

And say if it works for you or not ?
And what you expected in your case ?

EDIT:
As so far I think that function work as intended, at least reading HelpFile:

  Quote

Parameters

name [optional] If a name is given only processes of the same name will be returned.
Expand  

Optional mean that when you give any name then it must exist, if the name is empty string then it is a fact that such process should never exist.
So what you expected ?

As a solution to your needs you should use @TheDcoder proposals:

  On 1/20/2022 at 7:09 PM, TheDcoder said:

In any case, doesn't look like it's possible to achieve the default behavior without using hacks like this:

Func ProcessListFixed($iPID = "")
    If $iPID = "" Then
        Return ProcessList()
    Else 
        Return ProcessList($iPID)
    EndIf
EndFunc

 

Expand  

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks mLipok,

More or less of the workarounds I know of
The point mainly referred to the natural idea that the function "should" be able to accept a variable (in the main case of our interest - coding Etc.)

 

Posted (edited)

You should avoid passing empty string, by your own, and not expecting that AutoIt do it for you internally.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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