Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #29778
    Patrick C
    Participant

    This question is in the context of:
    https://www.emeditor.com/forums/topic/active-string-add-control-modifier/
    Yutaka suggested to do this with a macro.

    I.e. run a macro when a mouse clicks on an active string, e.g. URI / URL, and check whether a modifier key is pressed / was pressed when clicking on the active string.

    I couldn`t find any EmEditor specific way to do this in the documentation.

    Typically Javascript couples the modifier key query to an event object (MouseEvent).
    E.g. something like macro_event.ctrlKey, macro_event.altKey and macro_event.shiftKey

    I also tried the doing this with the Windows Script Host.
    Visual basic allows querying with My.Computer.Keyboard.CtrlKeyDown / AltKeyDown / ShiftKeyDown, but there doesn`t seem to be an equivalent Windows Script Host implementation.

    Resorting to an external code (e.g. AutoHotKey, Powershell with C#, …) is something I`d like to avoid as the Macro should run reasonably smoothly.

    → Any hints?

    #29796
    Yutaka Emura
    Keymaster

    I don’t think it is easy to find which keys are pressed at a certain time in macros. I will consider adding a new property or method to retrieve the keys pressed in macros in a future version.

    #29797
    Patrick C
    Participant

    Thanks!
    My only use would be the Active String ctrl modifier, just in case that’s easier.
    But anyway, adding the modifiers just a suggestion, if you can add it: Great. If not: I’ll be fine and appreciate all the other features that are added instead.

    #29805
    Yutaka Emura
    Keymaster

    v24.1.901 added the GetKeyState method to the Shell object.

    For example,

    
    bCtrlDown = shell.GetKeyState( 0x11 ) < 0;
    if( bCtrlDown ) {
        alert( "Ctrl key is down" );
    }
    else {
        alert( "Ctrl key is up" );
    }
    
    #29806
    Patrick C
    Participant

    Oh thank you Yutaka 😃, I`m super grateful for this and for EmEditor as a whole – best text editor ever 😃 🙏 🙇

    #29896
    Patrick C
    Participant

    I just realised that this also allows querying the Num, Caps and Scroll lock states 🙂🙃😃

    let iScrollState = 0;
    
    iScrollState = shell.GetKeyState(0x91);
    
    if(iScrollState === 1) {
        alert("Scroll Lock is enabled");
    } else if(iScrollState === 0 ) {
        alert("Scroll Lock is disabled");
    } else if(iScrollState === -127) {
        alert("Scroll Lock is enabled and its key is down, i.e. pressed");
    } else if(iScrollState === -128) {
        alert("Scroll Lock is disabled and its key is down, i.e. pressed");
    } else {
        alert("Unexpected Scroll Lock state:" + iScrollState);
    }

    🙏 🙇

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.