Git Product home page Git Product logo

regexhotstring's Introduction

RegExHotstrings

Provides RegEx in hotstring triggering like normal hotstring.

Use Space, Tab or Enter to trigger RegExHotstring.

Usage

RegExHotstring(String, CallBack, Options, OnOffToggle, Params*)
  • String:

  • CallBack:

  • Options:

    A string of zero or more of the following options (in any order, with optional spaces in between)

    Use the following options follow by a zero to turn them off:

    • * (asterisk): An ending character (e.g. Space, Tab, or Enter) is not required to trigger the hotstring.

    • ? (question mark): The hotstring will be triggered even when it is inside another word; that is, when the character typed immediately before it is alphanumeric.

    • B0 (B followed by a zero): Automatic backspacing is not done to erase the abbreviation you type. Use a plain B to turn backspacing back on after it was previously turned off.

    • C: Case sensitive: When you type an abbreviation, it must exactly match the case defined in the script.

    • O: Omit the ending character of auto-replace hotstrings when the replacement is produced.

    • T: Use SendText instead of SendInput to send the replacement string. Only works when CallBack is a string.

  • OnOffToggle

    One of the following values:

    • On or 1 (true): Enables the hotstring.

    • Off or 0 (false): Disables the hotstring.

    • Toggle or -1: Sets the hotstring to the opposite state (enabled or disabled).

  • Params:

    additional params pass to CallBack, check Variadic functions and Variadic function calls, only works when CallBack is a function.

Demo

Demo.gif

FAQ

How to trigger regular hotstring in the same script?

Set SendLevel higher than #InputLevel (default is 0), and set RegHook.MinSendLevel higher than SendLevel to avoid triggering InputHook recursively.

#Include RegExHotstring.ahk

::btw::by the way

RegHook.MinSendLevel := 2
SendLevel(1)
RegExHotstring(...)

Important

Only last SendLevel takes effect.

Limitations

  • incompatible with #IfWin or #HotIf
  • unable to match white space characters.

regexhotstring's People

Contributors

8lwxpg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

regexhotstring's Issues

! # ^ { } and + will not trigger match with \W

I use:
RegExHotstring("psa(s)?(\W)", "Please see the attached document$1$2", "*C")

! # ^ { } and + will not trigger match when they are the terminal characters. Practically speaking , the only one likely to cause me issue in the day to day is the !.

Regular hotstrings stop working when #Include-ing RegExHotString.ahk

I'm trying to extend my existing Hotkey script with regex hotstrings, based on your script.
Whenever I try to #Include the RegExHotString.ahk file, though, my "regular" hotstring definitions stop working.

Example script 1, without #Include RegExHotString.ahk:

#SingleInstance Force
TrayTip("AHK script '" . A_ScriptName . "' loading ...", , 1)

:X:;dt::SendInput(FormatTime(, "yyyy-MM-dd HH'h'mm"))

#Home::SoundSetMute(!SoundGetMute())

→ the ;dt hotstring works, the #Home hotkey works.

Example script 2, with #Include RegExHotString.ahk and an example regex hotstring to generate a Markdown link:

#SingleInstance Force
TrayTip("AHK script '" . A_ScriptName . "' loading ...", , 1)

:X:;dt::SendInput(FormatTime(, "yyyy-MM-dd HH'h'mm"))

#Home::SoundSetMute(!SoundGetMute())

#Include %A_ScriptDir%\_inc\RegExHotstring.ahk
RegExHotstring(";issue([0-9]+)", "[ISSUE-$1](http://jira.mydomein.com/browse/PROJ-$1)", "O")

→ the #Home hotkey still works, the ;issue regex hotstring works... but the regular ;dt hotstring does NOT work anymore.

I'm guessing this has to do with some interference between the InputHook in RegExHotString versus my regular hotstrings... but I don't know anything about how those work.

Can you see what's causing the problem? How to make this work?

double press issue

my script is from demo:

#Requires AutoHotkey v2.0
#Include RegExHotstring.ahk
#SingleInstance Force

; the upmost function will be triggered first

; replace with regex string

RegExHotstring("(\w*)c", call)
; receives RegExMatchInfo
call(match) {
	MsgBox("matched: " match[1])
}

when I press a button, it does not do anything untill I press it again. Then it produces one symbol as expected.
e.g. to enter word
example
I need to press
eexxaammppllee
same time hotstring functionality works, e.g. if I enter
eexxaammpplleecc
then it would trigger call function (assuming hitting space at the end)

I am using fresh (just downladed) ahk v2 install, also have v1.1 instaled alongside (ahk claims they compatible to be installed together) and no other scripts running. As soon as I close this test script, doublepress issue gone.

What can I do to debug? where to watch?

Dead keys not registered


Description

I've encountered an issue while using the RegExHotstring.ahk script, where dead keys are not being registered as expected. Dead keys, such as '^', '¨', and '´', are not modifying characters when used in conjunction with the script.

Thank you for your assistance.


Steps to reproduce

  1. Download RegExHotstrings.ahk and set up following script:
    line 1: #Include RegExHotstrings.ahk
  2. Use a French keyboard
    Windows 10:
    2.a. Settings >Time & Language > Language > Preferred languages > [Language] > Options > Add a keyboard > French
    2.b. To switch between keyboard layouts, press Alt+Shift.
  3. Attempt to use dead keys (e.g., '^', '¨', '´') with the script active.
  4. Observe that the dead keys do not modify characters as intended.

Dead keys

Dead keys are keys on a keyboard that don't produce a character on their own when pressed, but instead modify the character that is entered when you press another key immediately after the dead key. These keys are commonly used in languages that require diacritics or accent marks to be placed on top of certain characters. Keyboards designed for languages like French, Spanish, German, or Portuguese often include dead keys to make it easier to input accented characters.

For example, the '^' key is a dead key for adding circumflex accents (ex. â) , the '¨' key is a dead key for adding diaeresis (umlaut) accents (ex. ä). When you press one of these dead keys and then press a letter, the dead key modifies the letter accordingly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.