jeeswg's characters tutorial

Helpful script writing tricks and HowTo's
User avatar
jeeswg
Posts: 1023
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: 2017-05-19]

I will be posting external links with full AutoHotkey tutorials etc in future,
but until then I will post occasional things here.

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

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

CHARACTERS THAT LOOK SIMILAR

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



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

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)
% variables (command style), variables (expression style), function names
& address, bitwise-and, && AND
'
( continuation section, if statements, functions, objects
) continuation section, if statements, functions, objects
* multiply, dereference, variadic functions, ** powers, /* comment block start, */ comment block end, (hotkeys: wildcard: ignore modifiers)
+ add, ++ increment, (SendInput: shift)
, (warning: not decimal point), multi-statement
- subtract, -- decrement
. decimal point, concatenate, objects
/ divide, // floor divide, /* comment block start, */ comment block end
: ?: ternary operator
; comments
< 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 sequences
{ code blocks, (SendInput)
| bitwise-or, GUI parameters, || OR
} code blocks, (SendInput)
~ 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] [Expand] [Download] GeSHi © Codebox Plus



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

LIST UNICODE CHARACTERS 1-65535

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



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

UNICODE CHARACTERS GET NAMES

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



[list of Unicode characters]
NamesList.txt
http://www.unicode.org/Public/UNIDATA/NamesList.txt

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

FORMAT FUNCTION EXAMPLES

;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

;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

;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_

;date/time
vYear := 2006, vMonth := 5, vDay := 4, vHour := 3, vMin := 2, vSec := 1
MsgBox, % Format("{:04}{:02}{:02}", vYear, vMonth, vDay)
MsgBox, % Format("{:04}{:02}{:02}{:02}{:02}{:02}", vYear, vMonth, vDay, vHour, vMin, vSec)
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

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

- what a stunning cast of characters -
Last edited by jeeswg on 22 May 2017, 12:12, edited 18 times in total.
wolf_II
Posts: 1245
Joined: 08 Feb 2015, 20:55

Re: jeeswg's tutorial pages

20 Jan 2017, 07:17

jeeswg wrote:note: file names (minus dirs) cannot start/end in .

Are you sure?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 1023
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: 1245
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.

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 6 guests