end2endzone / ShellAnything

ShellAnything is a C++ open-source software which allow one to easily customize and add new options to *Windows Explorer* context menu. Define specific actions when a user right-click on a file or a directory.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set a property value from a random value (generate random values).

end2endzone opened this issue · comments

Is your feature request related to a problem? Please describe.
Scripting usually requires to generate some sort of random value to prevent conflicting with other scripts or command runs.
It would be useful to be able to set a property from a random value.

Describe the solution you'd like
A random attribute should be added to the <property> element.

<property name="my_random_numeric_id" random="#####" />
<property name="my_random_name" random="Aaaaaaaa" />
<property name="my_random_string" random="zZ" />
<property name="my_random_guid" random="guid" />

where

  • # generates a random numeric digit.
  • a generates a random alphabetic lowercase letter.
  • A generates a random alphabetic uppercase letter.
  • z or Z generates a random alphanumeric character (digits, uppercase and lowercase letters).
  • GUID generates a random GUID.

Additional properties for numeric values should also be considered.
For example attributes such randommin and randommax would allow ranged value generation:

<property name="my_dice_roll" random="#" randommin="1" randommax="6" />
<property name="my_coin_flip" random="#" randommin="0" randommax="1" />
<property name="my_random_card" random="#" randommin="1" randommax="52" />

Describe alternatives you've considered
You could generate random numbers with the following steps:

  • Execute an external script with <exec>.
  • Wait for the execution to complete.
  • Dump the output to a file.
  • Read the file as a property.

However, that would be unnecessary complicated and ugly.

Additional context
N/A

Support for <property name="my_random_guid" random="guid" /> was replaced in favor of random.guid live property. See eda0993 for details.