Modify

Opened 12 years ago

Closed 11 years ago

#2109 closed Feature Request (Rejected)

ProcessList and WinList should accept Default or -1

Reported by: MrCreatoR <mscreator@…> Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: ProcessList WinList Default Cc:

Description

When we use ProcessList or WinList with Default keyword or with -1, the function recognize it like a string, and searches for window/process with Default/-1 title/process name.

Sometimes we need to pass the parameters of our UDF to ProcessList/WinList function, and we should be able to set it as Default/-1.

Example:

Func _MyUDF($sTitle = Default)
	$aWinList = WinList($sTitle)
	
	....
EndFunc

If the user omit the $sTitle parameter, the result will be wrong.

For now i must do this:

Func _MyUDF($sTitle = Default)
	If (IsKeyword($sTitle) And $sTitle = Default) Or $sTitle = -1 Then
		$aWinList = WinList()
	Else
		$aWinList = WinList($sTitle)
	EndIf
	
	....
EndFunc

The same issue with ProcessList.

Attachments (0)

Change History (5)

comment:1 Changed 12 years ago by TicketCleanup

  • Version 3.3.8.0 deleted

Automatic ticket cleanup.

comment:2 Changed 12 years ago by Valik

  • Resolution set to Rejected
  • Status changed from new to closed

The functions will never accept -1 because -1 is a number. To specify an default parameter for a string you use "". There is some merit to accepting the Default keyword. However your usage case just boils down to I'm too lazy to write If $param = Default Then $param = "" before you pass it to a function so I'm not inclined to make changes to the language itself to save you a single line of code.

comment:3 follow-up: Changed 12 years ago by MrCreatoR <mscreator@…>

Replying to Valik:

To specify an default parameter for a string you use ""

It's the same, it will not return all processes/windows list. Perhaps it's a bug (if you say it should work).

And it's not about me been lazy (it's not in my nature :) ), this is about inconsistency with other functions that accept Default, and we talking about [optional] parameter.

comment:4 in reply to: ↑ 3 Changed 12 years ago by Valik

  • Resolution Rejected deleted
  • Status changed from closed to reopened

Replying to MrCreatoR <mscreator@…>:

It's the same, it will not return all processes/windows list. Perhaps it's a bug (if you say it should work).

Without looking the code probably does something different when there are no parameters. What that means is the function doesn't support any form of default behavior so adding Default isn't just filling in missing functionality but adding new functionality.

And it's not about me been lazy (it's not in my nature :) ), this is about inconsistency with other functions that accept Default, and we talking about [optional] parameter.

Look at many of the cases where Default is supported. It's in places where you want to skip parameters so you can access later parameters. For example, in WinMove() you might use Default for width so you can specify a new height. In this case you are asking for Default to exist on the only parameter the function takes (in the case of ProcessList()). So no, it's really not inconsistent.

I'll re-open this merely to remind myself to look and see what is going on with the functions. I'm still not convinced supporting Default is really useful for these functions.

comment:5 Changed 11 years ago by Jon

  • Resolution set to Rejected
  • Status changed from reopened to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.