Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

request: on text_resize / on Ctrl-MouseWheelUp/Dn

Jul
576
10
So, I’m learning the “on” stuff a bit more, and I hit a situation where I guess... I found a need to request a new “on” type?

So we have these “mouse-based” ons:

ON DBLCLICK [command]
ON LBUTTON [command]
ON MBUTTON [command]
ON RBUTTON [command]

These are great. I don’t even really know how to use them, but I’m excited they exist.

I’m in a situation where I want to respond to the text size being increased. Which is, specifically for me, Ctrl-MouseWheelUp / Ctrl-MouseWheelDown.

It’s another mouse-based event, but there’s no corresponding “on” handler for it.

(It turns out if you lock certain rows to be non-scrollable, your cursor can either be in the normal part, or the locked part -- typically a 1–3 line statusbar. You can end up getting trapped inside the status bar if and only if the text size is changed without re-segregating the status bar with the new row number, which is going to be a different value with a differently-zoomed text size. So I want to react to text size changes with an “on” event that will recalculate this)
 
Do they really exist. All I get is this.

Code:
v:\> on rbutton dir
Usage : ON BREAK [command]

v:\> on lbutton echo foo
Usage : ON BREAK [command]

v:\> on dblclick echo foo
Usage : ON BREAK [command]

v:\> on mbutton echo foo
Usage : ON BREAK [command]
 
I think they only work inside a bat file?
 
I dunno. The help for ON starts with this.

Purpose:Execute a command at the command prompt or in a batch file when a specific condition occurs

I tried this BTM in a console, WT, and TCMD and got no beeps.

Code:
on lbutton beep 440 2
do forever
    set s=b
enddo
quit
 
Can't you do that with a WH_MOUSE_LL hook? This works in WT. With a little modification it might work elsewhere.

Code:
LRESULT CALLBACK LLMouseHookProc(INT nCode, WPARAM wParam, LPARAM lParam)
{
    HWND h = GetCascadiaWindow();
    if ( nCode >= 0 && GetForegroundWindow() == h && MouseInWindow(h) && wParam == WM_LBUTTONDOWN )
    {
        Beep(440, 200);
    }
    return CallNextHookEx(nullptr, nCode, wParam, lParam); // pass it on to WT?
}
 
side-comment: on break cancel is definitely suuuuuuuuuuuuuuuper useful for me in Windows Terminal, otherwise i get caught in scripts that i absolutely cannot break out of . I had to put it in every dang bat file.

[Except those ones i DON’T want this behavior in .. situations where i might want to ^C out of a nested bat without wanting to cancel the parent bat’s operation]

A lot of things slow things down erratically. That’s just life in the big city to me. Test, if bad don’t do, if good do. :)
 
Back
Top