jeeswg's characters tutorial

Helpful script writing tricks and HowTo's
User avatar
jeeswg
Posts: 5265
Joined: 19 Dec 2016, 01:58
Location: UK

jeeswg's characters tutorial

04 Jan 2017, 16:49

[this page was called 'jeeswg's tutorial pages']
[updated: 2018-09-22]

For this syntax character guide, please state any omissions, or make any comments.

See also:
jeeswg's RegEx tutorial (RegExMatch, RegExReplace) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28031
jeeswg's strings tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=32985

==================================================

CHARACTERS THAT LOOK SIMILAR

Code: Select all

32	0020	 	SPACE
160	00A0	 	NO-BREAK SPACE

39	0027	'	APOSTROPHE
96	0060	`	GRAVE ACCENT
180	00B4	´	ACUTE ACCENT
697	02B9	ʹ	MODIFIER LETTER PRIME
8216	2018	‘	LEFT SINGLE QUOTATION MARK [ANSI 145]
8217	2019	’	RIGHT SINGLE QUOTATION MARK [ANSI 146]

34	0022	"	QUOTATION MARK
8220	201C	“	LEFT DOUBLE QUOTATION MARK [ANSI 147]
8221	201D	”	RIGHT DOUBLE QUOTATION MARK [ANSI 148]

45	002D	-	HYPHEN-MINUS
173	00AD	­	SOFT HYPHEN

8211	2013	–	EN DASH [ANSI 150]
8722	2212	−	MINUS SIGN

8212	2014	—	EM DASH [ANSI 151]
9644	25AC	▬	BLACK RECTANGLE

183	00B7	·	MIDDLE DOT
8226	2022	•	BULLET [ANSI 149]

176	00B0	°	DEGREE SIGN
186	00BA	º	MASCULINE ORDINAL INDICATOR
8304	2070	⁰	SUPERSCRIPT ZERO
8728	2218	∘	RING OPERATOR
9675	25CB	○	WHITE CIRCLE
9702	25E6	◦	WHITE BULLET

216	00D8	Ø	LATIN CAPITAL LETTER O WITH STROKE
8709	2205	∅	EMPTY SET

47	002F	/	SOLIDUS
8260	2044	⁄	FRACTION SLASH

58	003A	:	COLON
1475	05C3	׃	HEBREW PUNCTUATION SOF PASUQ

181	00B5	µ	MICRO SIGN
956	03BC	μ	GREEK SMALL LETTER MU

955	03BB	λ	GREEK SMALL LETTER LAMDA
8257	2041	⁁	CARET INSERTION POINT
8908	22CC	⋌	RIGHT SEMIDIRECT PRODUCT

46	002E	.	FULL STOP
8230	2026	…	HORIZONTAL ELLIPSIS [ANSI 133]
==================================================

OPERATOR PRECEDENCE

Variables and Expressions
https://autohotkey.com/docs/Variables.htm#Operators

Expression Operators (in descending precedence order)
%Expr%
x.y [note: x.y (obj.key)]
new
++ --
**
- ! ~ & * [note: - (unary minus), & (address), * (dereference)]
* / // [note: * (multiply)]
+ - [note: - (subtract)]
<< >>
& ^ | [note: & (bitwise-and)]
. [note: . (concatenate)]
~=
> < >= <=
= == <> != !==
IS IN CONTAINS
NOT
AND &&
OR ||
?: [note: ?: (ternary operator)]
:= += -= *= /= //= .= |= &= ^= >>= <<=
=> [note: () => expr (fat arrow function)]
, [note: , (multi-statement)]

operators with two meanings:
. concatenate/obj.key [concatenate is redundant, you can omit the .]
- subtract/unary minus [virtually the same meaning]
& address/bitwise-and
* multiply/dereference

bitwise operators v. logical operators:
& bitwise-and, && AND
^ bitwise-exclusive-or
| bitwise-or, || OR
~ bitwise-not, ! NOT [note: '!' and 'NOT' have different precedences]

note: AHK v1 only: * (dereference), <>
note: AHK v2 only: => (fat arrow function), !==

note: AHK v1/v2 differences
!= (AHK v1): case sensitivity depends on A_StringCaseSense on/off/locale
!= (AHK v2): case insensitive (insensitivity mode depends on A_StringCaseSense off/locale)

==================================================

OPERATOR SUMMARY

mathematical:
++ -- **
-[unary] ~
* / // + - << >> & ^ |
+= -= *= /= //= |= &= ^= >>= <<=

general:
%Expr% x.y new ! &[address] *[deref] .[concatenate] ~=
> < >= <= = == <> != !==
IS IN CONTAINS
NOT AND && OR ||
?: := .= => ,

==================================================

AUTOHOTKEY SYNTAX: CHARACTER GUIDE

[ANSI (CP-1252) 32-255]
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ

(note: ANSI CP-1252 characters 128-159, differ from Unicode characters 128-159)

==================================================

[USEFUL LINK]
Variables and Expressions
https://autohotkey.com/docs/Variables.htm#Operators

[ASCII CHARACTERS 33-126 MINUS LETTERS/DIGITS][126-32-52-10=32]
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
! NOT, (SendInput: alt)
" assign text
# directives, (SendInput: win)
$ (hotkeys: hook)
% variable dereference (command style), variable double-dereference (expression style), function names, force an expression
& address, bitwise-and, && AND
'
( continuation section, if statements, functions, objects
) continuation section, if statements, functions, objects
* multiply, dereference, variadic function calls(/used in objects), DllCall (pointers), ** powers, /* comment block start, */ comment block end, (hotkeys: wildcard: ignore modifiers)
+ add, ++ increment, (SendInput: shift)
, (warning: not decimal point), delimiter, multi-statement
- subtract, -- decrement
. decimal point, concatenate, objects
/ divide, // floor divide, /* comment block start, */ comment block end
: ?: ternary operator
; comments (comment flag)
< less than, << bit shift left, <> not equal to
= [SEE EQUALS SECTIONS AT BOTTOM]
> greater than, >> bit shift right, <> not equal to
? ?: ternary operator
@
[ objects
\
] objects
^ (warning: not powers), bitwise-exclusive-or, (SendInput: ctrl)
_
` escape character
{ code blocks, (SendInput), (Format)
| bitwise-or, GUI parameters, || OR
} code blocks, (SendInput), (Format)
~ bitwise-not, (hotkeys: native)

==================================================

[EQUALS]
:= assign
+= add
-= subtract
*= multiply
/= divide
//= floor divide
.= append
|= bitwise-or
&= bitwise-and
^= bitwise-exclusive-or
>>= bit shift right
<<= bit shift left

[EQUALS][FURTHER USES]
= assign, compare case insensitive
== compare case sensitive
~= RegExMatch
>= greater than or equal to
<= less than or equal to
!= not equal to

==================================================

[FURTHER USES]
!
" paths (command line parameters), (invalid filename character)
# url fragment identifier, (issue with WB object Navigate)
$
% paths (environment variables), URI
& menu item text
' (Excel VBA single-line comments)
(
)
* FileAppend, Ptr* (PtrP), loop files wildcard, (invalid filename character)
+
, paths (command line parameters+)
-
. (invalid filename character+)
/ (invalid filename character), paths (command line parameters+), // C++ single-line comments
: (invalid filename character)
; ini files (comments)
< (invalid filename character)
= ini files
> (invalid filename character)
? (invalid filename character)
@ email address, reg files (default registry value)
[ ini files (section header)
\ (invalid filename character)
] ini files (section header)
^
_
`
{ CLSIDs
| (invalid filename character), || GuiControl
} CLSIDs
~

==================================================

[CHARACTERS THAT SOMETIMES REQUIRE ESCAPING]
! SendInput
" expression style
# SendInput
$
% command style, expression style (AHK v2)
& InputBox
' expression style (AHK v2)
(
) continuation section
*
+ SendInput
, command style, if var contains, if var in
-
.
/
:
; command style, expression style, hotkeys, IniWrite
<
= IniWrite
>
?
@
[ IniWrite
\
]
^ SendInput
_
` command style, expression style, (SendInput/hotstrings)
{ SendInput
|
} SendInput
~

==================================================

[CHARACTERS THAT SOMETIMES REQUIRE ESCAPING]
SendInput: {+} {^} {#} {!} {{} {}} ``
Format: {{} {}}

general: ` ; % "
general (AHK v2): '
commands: ,
if var in/contains: ,
continuation sections: )

InputBox: &
ini files (IniWrite): = [ ;

[RegEx] 12 characters that need escaping in RegEx generally:
not brackets (8): \ .*?+ | ^$
open brackets (3): [ { (
close brackets (1): )

[RegEx] 4 characters that need escaping in a RegEx character class:
^ - ] \

==================================================

INVALID FILENAME CHARACTERS

invalid filename characters (in a name without a path) (9):
\ / : * ? " < > |
invalid filename characters (in a full path) (7):
/ * ? " < > |
note: chars 1-31 are also invalid dir/name characters
note: file names (minus dirs) cannot start/end in .

Excel VBA type-declaration characters:
integer %, long &, currency @, single !, double #, string $

==================================================

HOTKEYS

In all the hotkey labels (not hotstrings) I use I found the following 22 characters
other than space and the 62 alnum: !#$&'*+,-./:;<=>[\]^`~

They are all from the 'classic 32' (my coinage): !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

special characters (11): : & +^#! $~* <>
normal keys (11): ',-./;=[\]`
from the classic 32 chars not in list (10): "%()?@_{|}
(special + normal): #

Note: hash hotkey: '#::', win+hash hotkey: '##::', win hotkey: 'LWin::' or 'RWin::'
Note: semicolon hotkey: '`;::' or 'SC027::', ctrl+semicolon hotkey: '^;::' or '^SC027::'
Note: AltGr hotkey: 'RAlt', AltGr+t: 'RAlt & t' or '<^>!t'

==================================================

HOTSTRINGS

;certain hotstrings with colon may not work:
:c*:i-::I- ;a hotstring that works
:c*:i:::I: ;doesn't work

==================================================

ANSI (CP-1252) CHARACTERS (VERBATIM) (WYSIWYG) (CONTINUATION SECTIONS)

Code: Select all

;AHK v1 command style
;ANSI (CP-1252) 32-255 verbatim
vOutput = ;continuation section
(% ` Join`r`n
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
)

;AHK v1 expression style
;ANSI (CP-1252) 32-255 verbatim except double quote
vOutput := " ;continuation section
(` Join`r`n
!""#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
)"

;AHK v2
;ANSI (CP-1252) 32-255 verbatim
vOutput := " ;continuation section
(` Join`r`n
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
)"
==================================================

PREPARE TEXT FOR STORING IN A VARIABLE

Code: Select all

q:: ;prepare text for storing in a variable
vText := ""
Loop, 255
	vText .= Chr(A_Index)
vText := StrReplace(vText, "``", "````")
vText := StrReplace(vText, "`r", "``r")
vText := StrReplace(vText, "`n", "``n")
if !!SubStr(1,0) ;vIsV1
	vText := StrReplace(vText, Chr(34), Chr(34) Chr(34))
else
	vText := StrReplace(vText, Chr(34), "``" Chr(34))
Clipboard := "var := " Chr(34) vText Chr(34)
return
==================================================

LIST UNICODE CHARACTERS 1-65535

Code: Select all

vOutput := ""
VarSetCapacity(vOutput, 100000*2)
Loop, 65535
{
	if (Mod(A_Index, 32) = 31)
		vOutput .= Chr(A_Index) "`r`n"
	else
		vOutput .= Chr(A_Index)
}
Clipboard := vOutput
MsgBox, % "done"
return
==================================================

UNICODE CHARACTERS GET NAMES

Code: Select all

q:: ;Unicode character get name (same method as Character Map)
vPath := "C:\Windows\System32\getuname.dll"
hModule := DllCall("LoadLibrary", Str,vPath)

vChar := "!"
vNum := Asc(vChar)
VarSetCapacity(vName, 1024)
DllCall("LoadString", Ptr,hModule, UInt,vNum, Str,vName, Int,1024)
MsgBox, % vName

VarSetCapacity(vOutput, 1000000*2)
Loop, 65536
{
	VarSetCapacity(vName, 1024)
	DllCall("LoadString", Ptr,hModule, UInt,A_Index-1, Str,vName, Int,1024)
	vOutput .= (A_Index-1) "`t" vName "`r`n"
}
Clipboard := vOutput
MsgBox, % vOutput
DllCall("FreeLibrary", Ptr,hModule)
return
  • NamesList.txt
    http://www.unicode.org/Public/UNIDATA/NamesList.txt

    ==================================================

    ANSI AND UNICODE CHARACTERS (STRGET AND STRPUT)

    Code: Select all

    ;get 255 ANSI characters (in AHK Unicode versions)
    vText := ""
    VarSetCapacity(vText, 255, 0)
    Loop, 255
    	NumPut(A_Index, vText, A_Index-1, "UChar")
    vOutput := StrGet(&vText, 255, "CP0")
    MsgBox, % Clipboard := "[" vOutput "]"
    
    ;square root sign, Chr(8730) (UTF-8 bytes) (in AHK Unicode versions)
    vUTF16 := Chr(8730)
    vSize := StrPut(vUTF16, "UTF-8")
    vUTF8 := ""
    VarSetCapacity(vUTF8, vSize, 0)
    StrPut(vUTF16, &vUTF8, "UTF-8")
    vOutput := StrGet(&vUTF8, vSize, "UTF-8")
    MsgBox, % vOutput
    return
    
    ==================================================

    LIST EVERY CHARACTER THAT APPEARS IN A STRING
      • Tip: use a MsgBox with a variable enclosed in square brackets (or some other characters), to check for leading/trailing whitespace.

        Code: Select all

        vText := " abc "
        MsgBox, % "[" vText "]"
        

        Code: Select all

        q:: ;list characters in string
        ;vText := JEE_GetSelectedText()
        vText := Clipboard
        vText := StrReplace(vText, Chr(1), "", vContainsChr1)
        vContainsChr1 := !!vContainsChr1
        vOutput := ""
        VarSetCapacity(vOutput, 1000000*2)
        while !(vText = "")
        {
        	vOrd := Ord(vText)
        	vText := StrReplace(vText, Chr(vOrd))
        	vOutput .= Format("{:07}", vOrd) "`t" Chr(vOrd) Chr(1)
        	if (A_Index > 300)
        		MsgBox, % vOrd " " Chr(vOrd) "`r`n" vText
        }
        Sort, vOutput, % "D" Chr(1)
        vOutput := StrReplace(vOutput, Chr(1), "`r`n")
        if vContainsChr1
        	vOutput := Format("{:07}", 1) "`t" Chr(1) "`r`n" vOutput
        Clipboard := vOutput
        MsgBox, % "done"
        return
        
        w:: ;list characters in string (simple)
        vText := "abcde `t`r`n"
        vOutput := ""
        Loop, Parse, vText
        	vOutput .= Ord(A_LoopField) "`t" A_LoopField "`r`n"
        Clipboard := vOutput
        MsgBox, % vOutput
        return
        
        ==================================================

        GET LETTERS IN KEYBOARD ORDER (E.G. 'QWERTY' ORDER)

        Code: Select all

        q:: ;get letters in keyboard order (e.g. 'qwerty' order)
        VarSetCapacity(vOutput, 26*2)
        Loop, 256
        	if !((vText := GetKeyName(Format("sc{:x}", A_Index-1))) = "")
        	&& (StrLen(vText) = 1) && RegExMatch(vText, "[A-Za-z]")
        		vOutput .= vText
        MsgBox, % Format("{:L}", vOutput) ;qwertyuiopasdfghjklzxcvbnm
        return
        
        w:: ;get letters in keyboard order (e.g. 'qwerty' order)
        VarSetCapacity(vOutput, 26*2)
        VarSetCapacity(vText, 256)
        Loop, 256
        	if DllCall("user32\GetKeyNameText", Int,(A_Index-1)<<16, Str,vText, Int,256)
        	&& (StrLen(vText) = 1) && RegExMatch(vText, "[A-Za-z]")
        		vOutput .= vText
        MsgBox, % Format("{:L}", vOutput) ;qwertyuiopasdfghjklzxcvbnm
        return
        
        ==================================================

        RECREATE AHK'S ORD/CHR FUNCTIONS

        Code: Select all

        q:: ;recreate Ord function (AHK Unicode only)
        MsgBox, % JEE_Ord(Chr(8730))
        Loop, 1114111
        {
        	vChar := Chr(A_Index)
        	if !(JEE_Ord(vChar) = Ord(vChar))
        		MsgBox, % "mismatch: " JEE_Ord(vChar) "`r`n" Ord(vChar)
        }
        MsgBox, % "done"
        return
        
        w:: ;recreate Chr function (AHK Unicode only)
        MsgBox, % JEE_Chr(8730)
        Loop, 1114111
        {
        	if !(JEE_Chr(A_Index) = Chr(A_Index))
        		MsgBox, % "mismatch: " A_Index "`r`n" JEE_Chr(vChar) "`r`n" Chr(vChar)
        }
        MsgBox, % "done"
        return
        
        ;==================================================
        
        JEE_Ord(vText)
        {
        	local vLen,vNum1,vNum2
        	vLen := StrLen(vText)
        	vNum1 := (vLen>0) ? NumGet(&vText, 0, "UShort") : 0
        	vNum2 := (vLen>1) ? NumGet(&vText, 2, "UShort") : 0
        	if (vNum1 >= 0xD800) && (vNum1 <= 0xDBFF)
        	&& (vNum2 >= 0xDC00) && (vNum2 <= 0xDFFF)
        		return ((vNum1-0xD800)<<10)+(vNum2-0xDC00)+0x10000
        	else
        		return vNum1
        }
        
        ;==================================================
        
        JEE_Chr(vNum)
        {
        	local vText
        	VarSetCapacity(vText, 6, 0)
        	if (vNum < 0) || (vNum > 0x10FFFF) || (vNum + 0 = "")
        		return
        	else if (vNum >= 0x10000)
        	{
        		vNum -= 0x10000
        		NumPut(0xD800+((vNum >> 10) & 0x3FF), &vText, 0, "UShort")
        		NumPut(0xDC00+(vNum & 0x3FF), &vText, 2, "UShort")
        	}
        	else
        		NumPut(vNum, &vText, 0, "UShort")
        	VarSetCapacity(vText, -1)
        	return vText
        }
        
        ==================================================

        FORMAT FUNCTION EXAMPLES

        - Each {} / {:f} / {n} / {n:f} contains text based on the parameters, the rest of the text is literal text.
        - {n:f}, n is a parameter number, f is a format.

        Code: Select all

        ;hex2dec (hexadecimal to decimal)
        MsgBox, % Format("{:i}", "0x" 10) ;16
        
        ;dec2hex (decimal to hexadecimal)
        MsgBox, % Format("{:X}", 65535) ;FFFF
        MsgBox, % Format("{:x}", 65535) ;ffff
        MsgBox, % Format("0x{:X}", 65535) ;0xFFFF (recommended)
        MsgBox, % Format("0x{:x}", 65535) ;0xffff (recommended)
        MsgBox, % Format("{:#X}", 65535) ;0XFFFF
        MsgBox, % Format("{:#x}", 65535) ;0xffff
        MsgBox, % Format("0x{:02X}{:02X}{:02X}", 10, 11, 12) ;0x0A0B0C
        MsgBox, % Format("0x{:02X}{:02X}{:02X}", 0xAA, 0xBB, 0xCC) ;0xAABBCC
        
        ;rounding/truncating
        MsgBox, % Format("{:0.3f}", 2/3) ;0.667
        MsgBox, % Format("{:0.4f}", 2/3) ;0.6667
        MsgBox, % Format("{:i}", 2/3) ;0
        MsgBox, % Format("{:i}", 123.1) ;123
        MsgBox, % Format("{:i}", 123.9) ;123
        MsgBox, % Format("{:i}", -123.1) ;-123
        MsgBox, % Format("{:i}", -123.9) ;-123
        
        ;padding (leading zeros)
        MsgBox, % Format("{:01}", "") ;0
        MsgBox, % Format("{:02}", 3) ;03
        MsgBox, % Format("{:04}", 15) ;0015
        MsgBox, % Format("{:04X}", 15) ;000F
        MsgBox, % Format("0x{:06X}", 15) ;0x00000F
        MsgBox, % Format("0x{:08X}", 15) ;0x0000000F
        
        ;trailing and leading padding at the same time
        MsgBox, % Format("{:09.4f}", 12.34) ;0012.3400 ;'4.4' or '3.4' if negative
        MsgBox, % Format("{:010.4f}", -12.34) ;-0012.3400
        MsgBox, % Format("{:011.6f}", 12.34) ;0012.340000 ;'4.6' or '3.6' if negative
        MsgBox, % Format("{:012.6f}", -12.34) ;-0012.340000
        MsgBox, % Format("{:013.6f}", 12.34) ;000012.340000 ;'6.6' or '5.6' if negative
        MsgBox, % Format("{:014.6f}", -12.34) ;-000012.340000
        
        ;change case
        MsgBox, % Format("{:U}", "HeLLo") ;HELLO
        MsgBox, % Format("{:T}", "HeLLo") ;Hello
        MsgBox, % Format("{:L}", "HeLLo") ;hello
        
        ;repeat string n times / padding (spaces/leading zeros)
        MsgBox, % Format("{:5}", "") ;(5 spaces)
        MsgBox, % Format("{:05}", 0) ;00000
        MsgBox, % StrReplace(Format("{:5}", ""), " ", "a") ;aaaaa
        MsgBox, % StrReplace(Format("{:5}", ""), " ", "a_") ;a_a_a_a_a_
        
        MsgBox, % "[" Format("{:6}", "abc") "]" ;pad with spaces to the left
        MsgBox, % "[" Format("{:-6}", "abc") "]" ;pad with spaces to the right
        MsgBox, % "[" Format("{:06}", "abc") "]" ;pad with zeros to the left
        ;MsgBox, % "[" Format("{:-06}", "abc") "]" ;pad with zeros to the right (doesn't work)
        
        ;date/time
        vYear := 2006, vMonth := 5, vDay := 4, vHour := 3, vMin := 2, vSec := 1
        MsgBox, % Format("{:04}{:02}{:02}", vYear, vMonth, vDay) ;yyyyMMdd
        MsgBox, % Format("{:04}{:02}{:02}{:02}{:02}{:02}", vYear, vMonth, vDay, vHour, vMin, vSec) ;yyyyMMddHHmmss
        MsgBox, % Format("{:02}/{:02}/{:04}", vDay, vMonth, vYear) ;dd/MM/yyyy
        MsgBox, % Format("{:02}/{:02}/{:04}", vMonth, vDay, vYear) ;MM/dd/yyyy
        MsgBox, % Format("{:02}:{:02}:{:02}", vHour, vMin, vSec) ;HH:mm:ss
        
        MsgBox, % Format("{:04}{:02}{:02}", 2006, 5, 4) ;20060504
        MsgBox, % Format("{:04}{:02}{:02}{:02}{:02}{:02}", 2006, 5, 4, 3, 2, 1) ;20060504030201
        MsgBox, % Format("{:02}/{:02}/{:04}", 4, 5, 2006) ;04/05/2006
        MsgBox, % Format("{:02}:{:02}:{:02}", 3, 2, 1) ;03:02:01
        
        ;convert seconds to d h m s
        vSec := 86400*4 + 3600*3 + 60*2 + 1 ;4d 3h 2m 1s
        MsgBox, % Format("{}d {}h {}m {}s", vSec//86400, Mod(vSec, 86400)//3600, Mod(vSec, 3600)//60, Mod(vSec, 60)) ;4d 3h 2m 1s
        MsgBox, % Format("{} day{} + {:02}:{:02}:{:02}", vSec//86400, (vSec//86400=1)?"":"s", Mod(vSec, 86400)//3600, Mod(vSec, 3600)//60, Mod(vSec, 60)) ;4 days + 03:02:01
        
        ;concatenation
        MsgBox, % Format("x{} y{} w{} h{}", 1, 2, 3, 4) ;x1 y2 w3 h4
        MsgBox, % Format("{},{},{}", "a", "b", "c") ;a,b,c
        MsgBox, % Format("{}-{}-{}", "a", "b", "c") ;a-b-c
        MsgBox, % Format("{}`r`n{}`r`n{}", "a", "b", "c") ;a CRLF b CRLF c
        MsgBox, % Format("path: {}`r`nname: {}", "C:\MyDir\MyFile.txt", "MyFile.txt")
        
        ;==================================================
        
        ;further examples
        MsgBox, % Format("{} {} {}", "a", "b", "c") ;a b c
        
        MsgBox, % Format("{1} {2} {3}", "a", "b", "c") ;a b c
        MsgBox, % Format("{3} {2} {1}", "a", "b", "c") ;c b a
        MsgBox, % Format("{1:} {2:} {3:}", "a", "b", "c") ;a b c
        MsgBox, % Format("{3:} {2:} {1:}", "a", "b", "c") ;c b a
        
        MsgBox, % Format("{X} {X} {X}", 10, 11, 12) ;{X} {X} {X} (doesn't work)
        MsgBox, % Format("{:X} {:X} {:X}", 10, 11, 12) ;A B C
        
        MsgBox, % Format("{1:X} {2:X} {3:X}", 10, 11, 12) ;A B C
        MsgBox, % Format("{3:X} {2:X} {1:X}", 10, 11, 12) ;C B A
        
        ==================================================

        - what a stunning cast of characters -
Last edited by jeeswg on 27 Oct 2018, 12:35, edited 60 times in total.
wolf_II
Posts: 2161
Joined: 08 Feb 2015, 20:55

Re: jeeswg's tutorial pages

20 Jan 2017, 07:17

note: file names (minus dirs) cannot start/end in .
Are you sure?

Code: Select all

FileName1 := "..txt"
FileName2 := ".123.txt"

FileAppend,, %FileName1%
FileAppend,, %FileName2%

RunWait, %FileName1%
RunWait, %FileName2%

FileDelete, %FileName1%
FileDelete, %FileName2%
User avatar
jeeswg
Posts: 5265
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's tutorial pages

20 Jan 2017, 09:27

Try creating an extensionless file in a folder e.g. 'abc', and renaming to add a dot at the front/end (on Windows 7). Btw AutoHotkey creates files it shouldn't sometimes, including a file it couldn't delete once if I remember back. As a precaution don't create experimental filenames on the Desktop but in a subfolder. It's like renaming a folder to Con, ordinarily it can't be done, but I believe there is a way to force it. Difficult with the leading/trailing dot, to say if it is 100% invalid even if it is not 100% impossible. Nice to know people are reading this page, I refer back to it sometimes myself!
wolf_II
Posts: 2161
Joined: 08 Feb 2015, 20:55

Re: jeeswg's tutorial pages

20 Jan 2017, 10:02

Ahhh, I see. I can create a file named ".abc", but I can not rename "abc" to ".abc" with AHK. Got you. I did not know.
Rohwedder
Posts: 1428
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: jeeswg's characters tutorial

21 Sep 2018, 01:25

Hallo,
CHARACTERS THAT LOOK SIMILAR
new: 25AC, 002F, 2044, 003A, 05C3

32 0020 SPACE
160 00A0 NO-BREAK SPACE

39 0027 ' APOSTROPHE
96 0060 ` GRAVE ACCENT
180 00B4 ´ ACUTE ACCENT
697 02B9 ʹ MODIFIER LETTER PRIME
8216 2018 ‘ LEFT SINGLE QUOTATION MARK [ANSI 145]
8217 2019 ’ RIGHT SINGLE QUOTATION MARK [ANSI 146]

34 0022 " QUOTATION MARK
8220 201C “ LEFT DOUBLE QUOTATION MARK [ANSI 147]
8221 201D ” RIGHT DOUBLE QUOTATION MARK [ANSI 148]

45 002D - HYPHEN-MINUS
173 00AD ­ SOFT HYPHEN

8211 2013 – EN DASH [ANSI 150]
8722 2212 − MINUS SIGN

8212 2014 — EM DASH [ANSI 151]
9644 25AC ▬ BLACK RECTANGLE

183 00B7 · MIDDLE DOT
8226 2022 • BULLET [ANSI 149]

176 00B0 ° DEGREE SIGN
186 00BA º MASCULINE ORDINAL INDICATOR
8304 2070 ⁰ SUPERSCRIPT ZERO
8728 2218 ∘ RING OPERATOR
9675 25CB ○ WHITE CIRCLE
9702 25E6 ◦ WHITE BULLET

216 00D8 Ø LATIN CAPITAL LETTER O WITH STROKE
8709 2205 ∅ EMPTY SET

47 002F / SOLIDUS
8260 2044 ⁄ FRACTION SLASH

58 003A : COLON
1475 05C3 ׃ SOF PASUQ
User avatar
jeeswg
Posts: 5265
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's characters tutorial

21 Sep 2018, 05:12

- @Rohwedder: Thanks very much, I've added them in.
- Also, I recently noticed this thread which mentions '…'.
Trouble replacing special character - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=55957
- And I remembered micro sign v. mu, and lambda lookalikes.
- So, new additions:

Code: Select all

;your suggestions:
9644	25AC	▬	BLACK RECTANGLE

47	002F	/	SOLIDUS
8260	2044	⁄	FRACTION SLASH

58	003A	:	COLON
1475	05C3	׃	HEBREW PUNCTUATION SOF PASUQ

;plus these:
181	00B5	µ	MICRO SIGN
956	03BC	μ	GREEK SMALL LETTER MU

955	03BB	λ	GREEK SMALL LETTER LAMDA
8257	2041	⁁	CARET INSERTION POINT
8908	22CC	⋌	RIGHT SEMIDIRECT PRODUCT

46	002E	.	FULL STOP
8230	2026	…	HORIZONTAL ELLIPSIS [ANSI 133]
Guest

Re: jeeswg's characters tutorial

01 Oct 2018, 20:43

Thanks For the format examples
SunAndSuch
Posts: 34
Joined: 05 Oct 2015, 12:11

Re: jeeswg's characters tutorial

31 Oct 2018, 16:23

jeeswg, what does the if !!SubStr(1,0) ;vIsV1 in "PREPARE TEXT FOR STORING IN A VARIABLE" do? Does it mean, that a function like this:[code]txt2var1(t){
t:=StrReplace(t,"``","````")
t:=StrReplace(t,"`r","``r")
t:=StrReplace(t,"`n","``n")
if !!SubStr(1,0)
t:=StrReplace(t,Chr(34),Chr(34) Chr(34))
else
t:=StrReplace(t,Chr(34),"``" Chr(34))
return Chr(34) t Chr(34)
}[/code]would return the input, converted to verbatim string in both ahk_v1 and ahk_v2, depending on which version is running the script?
Windows 7, Ahk v1 x64-bit.
User avatar
jeeswg
Posts: 5265
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's characters tutorial

31 Oct 2018, 16:35

@SunAndSuch: The script would take a string, e.g. abc"def, and prepare it in either of these two ways based on the AHK version number (determined via SubStr). Cheers.
[code]
vText := "abc""def" ;AHK v1
vText := "abc`"def" ;AHK v2
[/code]
@Guest: Cheers, no problem.

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 6 guests