StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Syrianux  
#1 Posted : Thursday, June 13, 2024 12:12:45 PM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Hello!

I have an action consisting in just one Mouse Click X,Y step assigned to a shorcut (not a gesture in this case). But I've been struggling to find a way to immediately use text expansion right after this action. I have TAB set up as the trigger, so if I use this action and then right after I type the text expansion shorcut, TAB just works as a normal tabulation. If I try again, then it does do the text expansion. Basically the workaround is that if I press any key after the Mouse Click X,Y event, then I can use the text expansion, otherwise the first TAB won't work. Is there any step I can add after the Mouse Click X,Y to make text expansion work immediately after it?

Thanks for any help!
Rob  
#2 Posted : Sunday, July 21, 2024 7:10:43 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,382
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 430 time(s) in 363 post(s)
Does pressing TAB work after a short pause? Like if you did the mouse click, then added a Delay of 100ms? If this is tied to a hotkey, it may be trying to send TAB before you've released the hotkey keys.
Syrianux  
#3 Posted : Monday, July 22, 2024 12:00:39 PM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Originally Posted by: Rob Go to Quoted Post
Does pressing TAB work after a short pause? Like if you did the mouse click, then added a Delay of 100ms? If this is tied to a hotkey, it may be trying to send TAB before you've released the hotkey keys.


Nope, I'm afraid it doesn't work. No matter how long I wait, even a few seconds, the text expansion doesn't work the first time. I had actually already tried to insert a Delay after the Mouse Click, but didn't work. I also tried the "Stop" command in my desperation, but the effect is the same. The workaround I have now is pressing backspace after using the hotkey for Mouse Click X,Y and then use text expansion, but it'd be great to skip that.

The settings for Mouse Click X,Y are:

X: 764
Y: -199
button: left (DI)
down: true (DI)
up: true (DI)
Rob  
#4 Posted : Monday, July 22, 2024 2:29:06 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,382
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 430 time(s) in 363 post(s)
Hmm, it works fine when I try that.

You might need to run the S+ tracing build:

https://forum.strokesplus.net/posts/t3012-Tracing-Logging-Builds-for-Troubleshooting

Once running, right-click tray icon and clear all option except TextExpansionEvents.

Then close S+, start S+ and immediately do your steps without your workaround.

After it fails to expand, then backspace and type expansion again + TAB (so it works).

Then close S+.

This is to keep the trace log as small as possible, so it's easier to examine. The post above details where the trace log will be.

Syrianux  
#5 Posted : Monday, July 22, 2024 3:19:03 PM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
All right, I normally use it in a different software, but I used MS Word for this example.

The hot key I use is Win + Shift + Z and then a text expansion with automation triggered with "da" for date.

There's certainly a lot of repetition for a particular instruction Blink .

Code:
22/07/2024 16:05:55: frmSurface.cs::.ctor(): Adding traces for ServerStateGeneralEvents and frmLoadingEvents until settings are loaded and checked for saved trace selections
22/07/2024 16:05:55: frmLoading.cs::.ctor(): Initialize
22/07/2024 16:05:57: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:05:58: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:00: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:00: KeyboardHook.cs::KeyboardProc(): Delete, clearing token: 
22/07/2024 16:06:00: KeyboardHook.cs::KeyboardProc(): Character added to token: Z
22/07/2024 16:06:00: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token (Z)
22/07/2024 16:06:00: KeyboardHook.cs::KeyboardProc(): Character added to token: d
22/07/2024 16:06:01: KeyboardHook.cs::KeyboardProc(): Character added to token: da
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token (da)
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:02: KeyboardHook.cs::KeyboardProc(): Decrementing token: 
22/07/2024 16:06:02: KeyboardHook.cs::KeyboardProc(): Character added to token: d
22/07/2024 16:06:02: KeyboardHook.cs::KeyboardProc(): Character added to token: da
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Possible trigger, test token here, token: da
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Trigger match, token: da
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Setting application
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): HWnd: 69968 - Text: WindowsForms10.Window.8.app.0.1f1986c_r3_ad1
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Error setting application: Access is denied - Inner: 
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Application match: Date
22/07/2024 16:06:03: [1] HookState.cs::TextExpansionComplete(): Enter function: 
22/07/2024 16:06:03: [5] HookState.cs::FireTextExpansionThread(): Entering function
22/07/2024 16:06:03: [5] HookState.cs::FireTextExpansionThread(): Sending backspaces
22/07/2024 16:06:03: [5] HookState.cs::FireTextExpansionThread(): Name: Date - TextExpansionType: Script
22/07/2024 16:06:03: [5] HookState.cs::FireTextExpansionThread(): Script: sp.SendVKey(vk.F2); sp.SendKeys('SD'); sp.SendString(DateTime.Now.ToString("ddMMyy")); sp.SendVKey(vk.SPACE);
22/07/2024 16:06:05: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
22/07/2024 16:06:06: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
Rob  
#6 Posted : Monday, July 22, 2024 4:29:55 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,382
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 430 time(s) in 363 post(s)
So it definitely has to do with focus changing, which causes the text expansion token to be reset (thinks you're changing to a new window).
Code:
22/07/2024 16:06:00: KeyboardHook.cs::KeyboardProc(): Character added to token: Z
22/07/2024 16:06:00: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token (Z)
^^ clearly pressing the hotkey here
....
vv Appears to be typing the first da here, which is sees, then (I'm guessing) when you hit TAB, that's causing 
   something to change window focus (?), which then causes S+ to clear the token
22/07/2024 16:06:00: KeyboardHook.cs::KeyboardProc(): Character added to token: d
22/07/2024 16:06:01: KeyboardHook.cs::KeyboardProc(): Character added to token: da
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token (da)
22/07/2024 16:06:01: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
....
vv This is likely you pressing Backspace (which decrements token), then `da`+tab and it works
22/07/2024 16:06:02: KeyboardHook.cs::KeyboardProc(): Decrementing token: 
22/07/2024 16:06:02: KeyboardHook.cs::KeyboardProc(): Character added to token: d
22/07/2024 16:06:02: KeyboardHook.cs::KeyboardProc(): Character added to token: da
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Possible trigger, test token here, token: da
22/07/2024 16:06:03: KeyboardHook.cs::KeyboardProc(): Trigger match, token: da

You might also enable the tracing for WinEventHookGeneralEvents, though it doesn't look like the code logs any data specific to what is gaining focus by default.

I'm not sure what would be causing so many focus changes, but that definitely seems to be the source of the issue. I'll have to think about it some more...
Syrianux  
#7 Posted : Monday, July 22, 2024 4:48:44 PM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Oh, I see! Well, that makes a lot of sense, because that's what I use it for. I have a big screen with one window covering the right side and then two other windows on the left (sharing a 25% space each). And so I use this Mouse Click XY event to automatically set the cursor on the bottom of that window on the "center-left", regardless of where the cursor is at that particular moment. And so that window gains focus when pressing the hotkey, so probably that's why the first text expansion doesn't work?

Hmmmm, but it shouldn't be this, because I'm trying the shortcut while having MS Word already active and still it doesn't work the first time either. Very mysterious...

Thanks a lot for your time and sorry for the trouble!
Rob  
#8 Posted : Monday, July 22, 2024 4:59:27 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,382
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 430 time(s) in 363 post(s)
Right, it's changing the focus fine and clears the token.

But then, after da is typed it's losing focus (I'm guessing when TAB is pressed) - several times in a row there are focus change events. (note these events are sent to S+ by Windows, not some logic S+ has built-in to detect focus changes)

That's the mystery: what would cause focus changes in this scenario? I'm not quite sure and it may be difficult for me to troubleshoot.

So is the mouse click within the window? Or is it on the window's border? Just wondering if there's any kind of odd behavior there. It seems like if an edit type of control isn't active, that pressing TAB would change controls..? But I don't think that would trigger this type of focus change.

I know I've seen some similar oddities with the autocomplete popup in Notepad++, where it was changing window focus because the popup is really a separate window - but it doesn't sound like that's the case here, or text expansion would always fail.

Edited by user Monday, July 22, 2024 5:00:09 PM(UTC)  | Reason: Not specified

Syrianux  
#9 Posted : Tuesday, July 23, 2024 11:05:29 AM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Hello!

Yes, the mouse click is within the window. I've used a Python code in order to get the current mouse coordinates, so I entered the values after locating an ideal position for the cursor withing that window (or, more specifically for my case, a window within a window). In order to make it simpler I was just using MS Word for these tests, and so I recalculated the coordinates to make sure they were within the Word window. And still it didn't work, until... I changed the hot keys!

I use 3 mouse clicks: one for the top, one for the top-middle and one for the bottom. And the hot keys assigned were:

Win + Shift + Q: top
Win + Shift + A: top-middle
Win + Shift + Z: bottom

I changed them to these ones and now it works immediately after the mouse click!

Win + Ctrl + TAB: top (I can't use Win + Ctrl + Q because it triggers Quick Assist in my computer)
Win + Ctrl + A: top-middle
Win + Ctrl + Z: bottom

So now I don't have those trillion "Foreground Window Changed, clear current token" until the end, when I went to close the tracing exe (it's still quite a few though). But the rest looks nice and clean! So is it the Shift key what's causing the issue? I've also tried Win+OEM_102 and it works just as well.


Code:
23/07/2024 11:47:45: frmSurface.cs::.ctor(): Adding traces for ServerStateGeneralEvents and frmLoadingEvents until settings are loaded and checked for saved trace selections
23/07/2024 11:47:45: frmLoading.cs::.ctor(): Initialize
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Delete, clearing token: 
23/07/2024 11:47:52: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Character added to token: d
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Character added to token: da
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Possible trigger, test token here, token: da
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Trigger match, token: da
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Setting application
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): HWnd: 462618 - Text: Document1 - Word
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Process: WINWORD.EXE - Text: Document1 - Word - Owner Title: Document1 - Word
23/07/2024 11:47:52: KeyboardHook.cs::KeyboardProc(): Application match: Date
23/07/2024 11:47:52: [1] HookState.cs::TextExpansionComplete(): Enter function: 
23/07/2024 11:47:52: [14] HookState.cs::FireTextExpansionThread(): Entering function
23/07/2024 11:47:52: [14] HookState.cs::FireTextExpansionThread(): Sending backspaces
23/07/2024 11:47:52: [14] HookState.cs::FireTextExpansionThread(): Name: Date - TextExpansionType: Script
23/07/2024 11:47:52: [14] HookState.cs::FireTextExpansionThread(): Script: sp.SendVKey(vk.F2); sp.SendKeys('SD'); sp.SendString(DateTime.Now.ToString("ddMMyy")); sp.SendVKey(vk.SPACE);
23/07/2024 11:47:52: [1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token () ***same line 14 times***
Rob  
#10 Posted : Wednesday, July 24, 2024 2:48:10 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,382
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 430 time(s) in 363 post(s)
That's weird - I wonder what would happen if you put a Send Shift Up (or w/e it's called) in your hotkey, before the mouse click?
Syrianux  
#11 Posted : Wednesday, July 24, 2024 4:11:10 PM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Wow, great idea! BigGrin

Yep, that works as well. I've run a few more tests and, interestingly enough, now it seems to work as well most of the time without that additional step, but behind the scenes there is a big difference. With the Send Shift Up, there is no "[1] HookState.cs::WinEventProc(): Foreground Window Changed, clear current token ()" before the expansion is triggered. If I remove the Send Shift Up, it mostly works but there are 16 lines of that "HookState.cs::WinEventProc etc." before the text expansion. So I think I will go with the Shift Up in order to use my original shortcuts, thanks! Also because the code looks way leaner.

I still don't know why it works now (mostly) with the original shortcut, since it never did before when I was trying multiple times Confused.
Syrianux  
#12 Posted : Tuesday, September 3, 2024 10:36:57 AM(UTC)
Syrianux

Rank: Member

Reputation:

Groups: Approved
Joined: 11/17/2023(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Okay, it took me a while, but I found the reason and the solution!

It seems that I actually don't need to send any keys up, I just need to... use a mouse click outside the window I'm working on.

This window can be customized and has four rows. If I am working on row one and use this shortcut to insert a text expansion on row 4, it doesn't work immediately after the shortcut. However, it does if I click with the mouse outside that window with four rows. If the last click happens to be outside that window, then it works immediately. So what I did for this particular shortcut is just add another mouse click xy with different coords (clicking on the window I normally have on the right with this layout) and now it works perfectly BigGrin.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.