Hotstring options¶
This module contains the declared option model, inheritance sentinel, semantic enums, and fully resolved option model.
The declared send mode uses SendMode (INPUT, PLAY, and EVENT). Fully
resolved options use the separate ResolvedSendMode enum so Input's Play and
Event fallback behaviors remain explicit without complicating the field type.
options ¶
Parse, normalize, and resolve AutoHotkey v2 hotstring option strings.
HotstringOptions is the single source
of truth for interpreting per-hotstring option strings in this project.
Omitted inheritable options are represented by the enum member INHERIT of
InheritedState.
ResolvedHotstringOptions
represents the corresponding fully resolved semantic state.
InheritedState ¶
Bases: Enum
Represent an option value inherited from the applicable defaults.
Attributes:
| Name | Type | Description |
|---|---|---|
INHERIT |
The option is not explicitly set and should inherit from the applicable default. |
Source code in hotstring\core\options.py
27 28 29 30 31 32 33 34 35 36 | |
SettingState ¶
Bases: Enum
Represent the explicit state of a two-state option.
Attributes:
| Name | Type | Description |
|---|---|---|
ENABLED |
The option behavior is explicitly enabled. |
|
DISABLED |
The option behavior is explicitly disabled. |
Source code in hotstring\core\options.py
39 40 41 42 43 44 45 46 47 48 49 50 | |
CaseMode ¶
Bases: Enum
Represent AutoHotkey hotstring case-matching behavior.
Attributes:
| Name | Type | Description |
|---|---|---|
SENSITIVE |
Match the trigger case-sensitively. |
|
INSENSITIVE_CONFORMING |
Match case-insensitively and allow replacement case conformation. |
|
INSENSITIVE_FIXED |
Match case-insensitively without replacement case conformation. |
Source code in hotstring\core\options.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
ReplacementMode ¶
Bases: Enum
Represent AutoHotkey replacement-text interpretation behavior.
Attributes:
| Name | Type | Description |
|---|---|---|
NORMAL |
Use normal replacement processing. |
|
RAW |
Use raw replacement processing. |
|
TEXT |
Use text-mode replacement processing. |
Source code in hotstring\core\options.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
SendMode ¶
Bases: Enum
Represent the explicitly selected hotstring send mode.
Attributes:
| Name | Type | Description |
|---|---|---|
INPUT |
Explicitly select SendInput. |
|
PLAY |
Explicitly select SendPlay. |
|
EVENT |
Explicitly select SendEvent. |
Source code in hotstring\core\options.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
ResolvedSendMode ¶
Bases: Enum
Represent the fully resolved hotstring send behavior.
Attributes:
| Name | Type | Description |
|---|---|---|
INPUT_WITH_PLAY_FALLBACK |
Explicit |
|
INPUT_WITH_EVENT_FALLBACK |
Built-in default: use SendInput with SendEvent fallback. |
|
PLAY |
Use SendPlay. |
|
EVENT |
Use SendEvent. |
Source code in hotstring\core\options.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
HotstringOptions
dataclass
¶
Represent a validated per-hotstring AutoHotkey option declaration.
The original option string is retained in options. Every omitted option
is represented by the singleton InheritedState.INHERIT, preserving the
distinction between an inherited value and an explicitly selected value.
Attributes:
| Name | Type | Description |
|---|---|---|
options |
str
|
Original validated option string with surrounding horizontal whitespace removed. |
ending_character_optional |
SettingState | InheritedState
|
Whether the hotstring may activate without an ending character,
or |
trigger_inside_word |
SettingState | InheritedState
|
Explicit inside-word matching state, or |
automatic_backspacing |
SettingState | InheritedState
|
Explicit automatic-backspacing state, or |
case_mode |
CaseMode | InheritedState
|
Explicit case-matching mode, or |
key_delay |
int | InheritedState
|
Explicit key delay, or |
omit_ending_character |
SettingState | InheritedState
|
Explicit ending-character omission state, or |
priority |
int | InheritedState
|
Explicit priority, or |
replacement_mode |
ReplacementMode | InheritedState
|
Explicit replacement-processing mode, or |
suspend_exempt |
SettingState | InheritedState
|
Explicit suspension-exemption state, or |
send_mode |
SendMode | InheritedState
|
Explicit send mode, or |
execute |
SettingState | InheritedState
|
Explicit execute state, or |
reset_recognizer |
SettingState | InheritedState
|
Explicit recognizer-reset state, or |
Source code in hotstring\core\options.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
__post_init__ ¶
__post_init__() -> None
Validate and parse the supplied option string.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the string contains an unsupported option or an invalid numeric value. |
Source code in hotstring\core\options.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
declaration ¶
declaration() -> str
Return a canonical option string for the parsed semantic state.
Returns:
| Type | Description |
|---|---|
str
|
Canonical option text in dataclass field order. Inherited options |
str
|
are omitted. |
Source code in hotstring\core\options.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
ResolvedHotstringOptions
dataclass
¶
Represent a fully resolved AutoHotkey hotstring option state.
Unlike HotstringOptions, every
field contains a concrete semantic value. InheritedState is therefore
absent from every field annotation.
Attributes:
| Name | Type | Description |
|---|---|---|
ending_character_optional |
SettingState
|
Whether the hotstring may activate without an ending character. |
trigger_inside_word |
SettingState
|
Whether the trigger may begin after an alphanumeric character. |
automatic_backspacing |
SettingState
|
Whether AutoHotkey automatically erases the typed trigger. |
case_mode |
CaseMode
|
Effective case-matching mode. |
key_delay |
int
|
Effective hotstring key delay. |
omit_ending_character |
SettingState
|
Whether an ending character is omitted from replacement output. |
priority |
int
|
Effective hotstring thread priority. |
replacement_mode |
ReplacementMode
|
Effective replacement-text processing mode. |
suspend_exempt |
SettingState
|
Whether the hotstring is exempt from suspension. |
send_mode |
ResolvedSendMode
|
Effective replacement send mode. |
execute |
SettingState
|
Whether inline content is executed rather than used as literal replacement text. |
reset_recognizer |
SettingState
|
Whether the recognizer resets after activation. |
Source code in hotstring\core\options.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
__post_init__ ¶
__post_init__() -> None
Validate the resolved option state.
Raises:
| Type | Description |
|---|---|
TypeError
|
If any field has an invalid type. |
ValueError
|
If any numeric field is outside its accepted range. |
Source code in hotstring\core\options.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
from_options
classmethod
¶
from_options(
options: HotstringOptions,
*,
defaults: ResolvedHotstringOptions,
) -> Self
Resolve one parsed declaration against concrete applicable defaults.
Each explicitly set value in options overrides the corresponding
value in defaults; each InheritedState.INHERIT value leaves the
applicable default unchanged.
Explicit SI is resolved to SendInput with SendPlay fallback, while
an inherited built-in default can remain SendInput with SendEvent
fallback. This preserves AutoHotkey's distinction between those cases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
HotstringOptions
|
Parsed per-hotstring declaration to resolve. |
required |
defaults
|
ResolvedHotstringOptions
|
Fully resolved defaults applicable to the declaration. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
New fully resolved option state. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If either argument has an invalid type. |
RuntimeError
|
If the parsed and resolved option models stop exposing the same option field names. |
Source code in hotstring\core\options.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |