Transform

Performs miscellaneous math functions, bitwise operations, and tasks such as ASCII/Unicode conversion.

Deprecated: This command is not recommended for use in new scripts. For details on what you can use instead, see the sub-command sections below.

Transform, OutputVar, SubCommand, Value1 , Value2

The OutputVar parameter is the name of the variable in which to store the result. The SubCommand, Value1 and Value2 parameters are dependent upon each other and their usage is described below.

Sub-commands

For SubCommand, specify one of the following:

Unicode

Deprecated: Not recommended for use in new scripts. Use the Unicode version of AutoHotkey instead.

Retrieves or stores Unicode text on the clipboard (for ANSI builds only).

Transform, OutputVar, Unicode , String

Note: The entire clipboard may be saved and restored by means of ClipboardAll, which allows this sub-command to operate without losing the original contents of the clipboard.

There are two modes of operation as illustrated in the following examples:

Transform, OutputVar, Unicode  ; Retrieves the clipboard's Unicode text as a UTF-8 string.
Transform, Clipboard, Unicode, %MyUTF_String%  ; Places Unicode text onto the clipboard.

In the second example above, a literal UTF-8 string may be optionally used in place of %MyUTF_String%.

Use a hotkey such as the following to determine the UTF-8 string that corresponds to a given Unicode string:

^!u::  ; Control+Alt+U hotkey.
MsgBox Copy some Unicode text onto the clipboard, then return to this window and press OK to continue.
Transform, ClipUTF, Unicode
Clipboard := "Transform, Clipboard, Unicode, %ClipUTF%`r`n"
MsgBox The clipboard now contains the following line that you can paste into your script. When executed, this line will cause the original Unicode string you copied to be placed onto the clipboard:`n`n%Clipboard%
return

Note: The Send {U+nnnn} command is an alternate way to produce Unicode characters.

Deref

Deprecated: Not recommended for use in new scripts. Use the expression syntax or a custom function such as Deref() instead.

Expands variable references and escape sequences contained inside other variables.

Transform, OutputVar, Deref, String

Any badly formatted variable references will be omitted from the expanded result. The same is true if OutputVar is expanded into itself; in other words, any references to OutputVar inside String's variables will be omitted from the expansion (note however that String itself can be %OutputVar%). In the following example, if Var1 contains the string "test" and Var2 contains the literal string "%Var1%", OutputVar will be set to the string "test": Transform, OutputVar, Deref, %Var2%. Within a function, each variable in String always resolves to a local variable unless there is no such variable, in which case it resolves to a global variable (or blank if none).

HTML

Deprecated: Not recommended for use in new scripts. Use a custom function such as EncodeHTML() instead.

Converts String into its HTML equivalent by translating characters whose ASCII values are above 127 to their HTML names (e.g. £ becomes £).

Transform, OutputVar, HTML, String , Flags

In addition, the four characters "&<> are translated to &quot;&amp;&lt;&gt;. Finally, each linefeed (`n) is translated to <br>`n (i.e. <br> followed by a linefeed). The Flags parameter is ignored.

For Unicode executables: In addition of the functionality above, Flags can be zero or a combination (sum) of the following values. If omitted, it defaults to 1.

Only non-ASCII characters are affected. If Flags is the number 3, numbered expressions are used only where a named expression is not available. The following characters are always converted: <>"& and `n (line feed).

Asc

Deprecated: Not recommended for use in new scripts. Use Asc() instead.

Retrieves the character code (a number between 1 and 255, or 1 and 65535 if Unicode is supported) for the first character in String.

Transform, OutputVar, Asc, String

If String is empty, OutputVar will also be made empty. For example: Transform, OutputVar, Asc, %VarContainingString%. To allow for Unicode supplementary characters, use Ord() instead.

Chr

Deprecated: Not recommended for use in new scripts. Use Chr() instead.

Retrieves the single character corresponding to the character code indicated by the specified number.

Transform, OutputVar, Chr, Number

If Number is not between 1 and 255 inclusive (or 1 and 65535 if Unicode is supported), OutputVar will be made blank to indicate the problem. For example: Transform, OutputVar, Chr, 130. Unlike Chr(), this sub-command does not support Unicode supplementary characters (character codes 0x10000 to 0x10FFFF).

Mod

Deprecated: Not recommended for use in new scripts. Use Mod() instead.

Retrieves the remainder of the specified dividend divided by the specified divisor.

Transform, OutputVar, Mod, Dividend, Divisor

If Divisor is zero, OutputVar will be made blank. Dividend and Divisor can both contain a decimal point. If negative, Divisor will be treated as positive for the calculation. In the following example, the result is 2: Transform, OutputVar, Mod, 5, 3.

Exp

Deprecated: Not recommended for use in new scripts. Use Exp() instead.

Retrieves e (which is approximately 2.71828182845905) raised to the Nth power.

Transform, OutputVar, Exp, N

N may be negative and may contain a decimal point.

Sqrt

Deprecated: Not recommended for use in new scripts. Use Sqrt() instead.

Retrieves the square root of the specified number.

Transform, OutputVar, Sqrt, Number

If Number is negative, OutputVar will be made blank.

Log

Deprecated: Not recommended for use in new scripts. Use Log() instead.

Retrieves the logarithm (base 10) of the specified number.

Transform, OutputVar, Log, Number

If Number is negative, OutputVar will be made blank.

Ln

Deprecated: Not recommended for use in new scripts. Use Ln() instead.

Retrieves the natural logarithm (base e) of the specified number.

Transform, OutputVar, Ln, Number

If Number is negative, OutputVar will be made blank.

Round

Deprecated: Not recommended for use in new scripts. Use Round() instead.

Retrieves the specified number rounded to N decimal places.

Transform, OutputVar, Round, Number , N

If N is omitted, OutputVar will be set to Number rounded to the nearest integer. If N is positive number, Number will be rounded to N decimal places. If N is negative, Number will be rounded by N digits to the left of the decimal point. For example, -1 rounds to the ones place, -2 rounds to the tens place, and-3 rounds to the hundreds place. Note: The Round sub-command does not remove trailing zeros when rounding decimal places. For example, 12.333 rounded to one decimal place would become 12.300000. This behavior can be altered by using something like SetFormat, Float, 0.1 prior to the operation (in fact, SetFormat might eliminate the need to use the Round sub-command in the first place).

Ceil

Deprecated: Not recommended for use in new scripts. Use Ceil() instead.

Retrieves the specified number rounded up to the nearest integer.

Transform, OutputVar, Ceil, Number

Floor

Deprecated: Not recommended for use in new scripts. Use Floor() instead.

Retrieves the specified number rounded down to the nearest integer.

Transform, OutputVar, Floor, Number

Abs

Deprecated: Not recommended for use in new scripts. Use Abs() instead.

Retrieves the absolute value of the specified number.

Transform, OutputVar, Abs, Number

This is computed by removing the leading minus sign (dash) from Number if it has one.

Sin

Deprecated: Not recommended for use in new scripts. Use Sin() instead.

Retrieves the trigonometric sine of the specified number.

Transform, OutputVar, Sin, Number

Number must be expressed in radians.

Cos

Deprecated: Not recommended for use in new scripts. Use Cos() instead.

Retrieves the trigonometric cosine of the specified number.

Transform, OutputVar, Cos, Number

Number must be expressed in radians.

Tan

Deprecated: Not recommended for use in new scripts. Use Tan() instead.

Retrieves the trigonometric tangent of the specified number.

Transform, OutputVar, Tan, Number

Number must be expressed in radians.

ASin

Deprecated: Not recommended for use in new scripts. Use ASin() instead.

Retrieves the arcsine (the number whose sine is the specified number) in radians.

Transform, OutputVar, ASin, Number

If Number is less than -1 or greater than 1, OutputVar will be made blank.

ACos

Deprecated: Not recommended for use in new scripts. Use ACos() instead.

Retrieves the arccosine (the number whose cosine is the specified number) in radians.

Transform, OutputVar, ACos, Number

If Number is less than -1 or greater than 1, OutputVar will be made blank.

ATan

Deprecated: Not recommended for use in new scripts. Use ATan() instead.

Retrieves the arctangent (the number whose tangent is the specified number) in radians.

Transform, OutputVar, ATan, Number

Pow

Deprecated: Not recommended for use in new scripts. Use the ** operator instead.

Retrieves Base raised to the power of Exponent.

Transform, OutputVar, Pow, Base, Exponent

Both Base and Exponent may contain a decimal point. If Exponent is negative, OutputVar will be formatted as a floating point number even if Base and Exponent are both integers. A negative Base combined with a fractional Exponent such as 1.5 is not supported; it will cause OutputVar to be made blank.

BitNot

Deprecated: Not recommended for use in new scripts. Use the ~ operator instead.

Retrieves the bit-inverted version of the specified number.

Transform, OutputVar, BitNot, Number

Floating point values are truncated to integers prior to the calculation. If Number is between 0 and 4294967295 (0xffffffff), it will be treated as an unsigned 32-bit value. Otherwise, it is treated as a signed 64-bit value. In the following example, the result is 0xfffff0f0 (4294963440): Transform, OutputVar, BitNot, 0xf0f.

BitAnd

Deprecated: Not recommended for use in new scripts. Use the & operator instead.

Retrieves the result of the bitwise-AND of Number1 and Number2.

Transform, OutputVar, BitAnd, Number1, Number2

Floating point values are truncated to integers prior to the calculation. In the following example, the result is 0xff00 (65280): Transform, OutputVar, BitAnd, 0xff0f, 0xfff0.

BitOr

Deprecated: Not recommended for use in new scripts. Use the | operator instead.

Retrieves the result of the bitwise-OR of Number1 and Number2.

Transform, OutputVar, BitOr, Number1, Number2

Floating point values are truncated to integers prior to the calculation. In the following example, the result is 0xf0f0 (61680): Transform, OutputVar, BitOr, 0xf000, 0x00f0.

BitXOr

Deprecated: Not recommended for use in new scripts. Use the ^ operator instead.

Retrieves the result of the bitwise-EXCLUSIVE-OR of Number1 and Number2.

Transform, OutputVar, BitXOr, Number1, Number2

Floating point values are truncated to integers prior to the calculation. In the following example, the result is 0xff00 (65280): Transform, OutputVar, BitXOr, 0xf00f, 0x0f0f.

BitShiftLeft

Deprecated: Not recommended for use in new scripts. Use the << operator instead.

Retrieves the result of shifting the specified number to the left by N bit positions.

Transform, OutputVar, BitShiftLeft, Number, N

This is equivalent to multiplying Number by "2 to the Nth power". Floating point values are truncated to integers prior to the calculation. In the following example, the result is 8: Transform, OutputVar, BitShiftLeft, 1, 3.

BitShiftRight

Deprecated: Not recommended for use in new scripts. Use the >> operator instead.

Retrieves the result of shifting the specified number to the right by N bit positions.

Transform, OutputVar, BitShiftRight, Number, N

This is equivalent to dividing Number by "2 to the Nth power", truncating the remainder. Floating point values are truncated to integers prior to the calculation. In the following example, the result is 2: Transform, OutputVar, BitShiftRight, 17, 3.

FromCodePage / ToCodePage

[AHK_L 54+]: Removed. Use StrPut/StrGet instead.

Remarks

Sub-commands that accept numeric parameters can also use expressions for those parameters.

If one of the parameters is a floating point number, the following sub-commands will retrieve a floating point number rather than an integer: Mod, Pow, Round, and Abs. The number of decimal places retrieved is determined by SetFormat.

To convert a radians value to degrees, multiply it by 180/pi (approximately 57.29578). To convert a degrees value to radians, multiply it by pi/180 (approximately 0.01745329252).

The value of pi (approximately 3.141592653589793) is 4 times the arctangent of 1.

Math Functions, SetFormat, Expressions, Operators, StringLower, if var is type

Examples

Retrieves the ASCII code of the letter A and stores it in OutputVar.

Transform, OutputVar, Asc, A