Posts: 1,049
Threads: 249
Joined: Jul 2022
11-20-2022, 12:30 AM
(This post was last modified: 11-20-2022, 12:54 AM by Davider.)
Hi,
in powershell ISE, I want to displays the autoText menu below caret point, But it seems impossible to find the caret point location, in QM, there is the same problem
I tried another AutoText software, and it was easy to get it right, see below demo
I looked up some related materials and it seems that there is a solution in this article below, but I don't know how to use it
https://learn.microsoft.com/en-us/answer...-from.html
Related code:
using UIAutomationClient;
var guid = typeof(IAccessible).GUID;
object accessibleObject = null;
var retVal = WinApiProvider.AccessibleObjectFromWindow(hwnd, WinApiProvider.OBJID_CARET, ref guid, ref accessibleObject);
var accessible = accessibleObject as IAccessible;
accessible.accLocation(out int left, out int top, out int width, out int height, WinApiProvider.CHILDID_SELF);
Thanks in advance for any advice and help
david
Posts: 12,095
Threads: 142
Joined: Dec 2002
I tested PE current version (free) on Win11. In PS it shows menu at mouse position.
AccessibleObjectFromWindow fails.
print.clear();
//wnd.find(1, "LibreAutomate", "HwndWrapper[Au.Editor;*");
wnd.find(1, "Administrator: Windows PowerShell ISE", "HwndWrapper[powershell_ise.exe;*").Activate();
500.ms();
if (miscInfo.getTextCursorRect(out var r, out var w2)) print.it(r, w2);
else print.it("failed");
print.it(wnd.focused);
var e = elm.fromWindow(wnd.focused, EObjid.CARET, EWFlags.NoThrow | EWFlags.NotInProc); //AccessibleObjectFromWindow
print.it(e.Rect);
Posts: 1,049
Threads: 249
Joined: Jul 2022
11-20-2022, 06:22 AM
(This post was last modified: 11-21-2022, 03:18 AM by Davider.)
my systtem: win7 64bit ps5.1
Tick the options below in PE
In the above code, the test failed
In the address bar of Google Chrome, the menu list overwrites the typing text
Posts: 12,095
Threads: 142
Joined: Dec 2002
Now PE works in PS. But does not work in Chrome.
AccessibleObjectFromWindow works in Chrome but not in PS.
I don't know other ways to get caret position.
Posts: 1,049
Threads: 249
Joined: Jul 2022
11-20-2022, 08:02 AM
(This post was last modified: 11-20-2022, 08:04 AM by Davider.)
Probably this interesting problem can be solved in the near future
In PS it shows menu at mouse position.
Can add two options for menu?
If the control can be found, it is centered on the control ①
else If the control is not found, it is centered in the window where the control is located ②
Posts: 12,095
Threads: 142
Joined: Dec 2002
11-20-2022, 08:09 AM
(This post was last modified: 11-20-2022, 08:12 AM by Gintaras.)
I think it's better to show menu at mouse position, because when editing text usually it is near caret position. And can click faster.
Does PE have this option?
Posts: 1,049
Threads: 249
Joined: Jul 2022
11-20-2022, 08:26 AM
(This post was last modified: 11-20-2022, 08:37 AM by Davider.)
Yes
other Two questions
1. In QM(add /m) and PE, after typing the abbreviation, the menu can be displayed directly
However, in LA, I need to press the Tab key or space key
LA can be achieved?
2. In QM and PE, after typing the abbreviation, press the space key and do not respond
However, in LA, it responds to the menu, how to cancel the response
I'm used to using spaces in QM and PE
Posts: 12,095
Threads: 142
Joined: Dec 2002
Quote:Probably this interesting problem can be solved in the near future
In next program version.
Also in next version:
tt.MenuOptions = new(PMFlags.ByCaret | PMFlags.WindowCenter);
Posts: 1,049
Threads: 249
Joined: Jul 2022
11-21-2022, 01:55 AM
(This post was last modified: 11-21-2022, 03:18 AM by Davider.)
Great! Thank you so much
About the following suggestion, I forgot one thing:
use the Chinese input method, to make the text output, I need to press the spacebar, The spacebar is used very frequently
Maybe my expression is not clear, for example, I want to typing the 世界 I need to press:
a n spacebar l w j spacebar
So I've been using QM's AutoText, Works well! and LA's current situation(Sensitive to spacebar), I'm not used to it
Quote:2. In QM and PE, after typing the abbreviation, press the space key and do not respond
However, in LA, it responds to the menu, how to cancel the response
I'm used to using spaces in QM and PE
The following feature is also very useful, Many autotext software can automatically pop up menus by default, the spacebar doesn't respond to it
Quote:1. In QM(add /m) and PE, after typing the abbreviation, the menu can be displayed directly
However, in LA, I need to press the Tab key or space key
LA can be achieved?
Posts: 12,095
Threads: 142
Joined: Dec 2002
12-05-2022, 05:44 AM
(This post was last modified: 12-05-2022, 05:47 AM by Gintaras.)
I'm not sure I understand 1 and 2 correctly. An autotext code example may help.
Also, what input language do you use? I see there are Chinese simplified, traditional Taiwan, etc.
Posts: 1,049
Threads: 249
Joined: Jul 2022
12-06-2022, 01:12 AM
(This post was last modified: 12-06-2022, 01:26 AM by Davider.)
Quote:what input language do you use? I see there are Chinese simplified, traditional Taiwan, etc
Chinese simplified
--------------------------------------------------------------------------------------------------------
QM: qq has been defined, When type qq, AutoText menu can be displayed automatically
phraseexpress: we has been defined, When type we, AutoText menu can be displayed automatically, too
L A: ww has been defined, When type ww, AutoText menu does not display automatically, Spacebar must be pressed
suggest:
in LA: no longer necessary to press the spacebar and the menu can be displayed directly, just like QM and PE
This also solves the problem of the input method mentioned above
Posts: 1,338
Threads: 61
Joined: Jul 2006
12-06-2022, 04:04 AM
(This post was last modified: 12-06-2022, 04:29 AM by Kevin.)
tt.DefaultPostfixType = TAPostfix.None;
tt["ww"] = o => o.Menu("This is a test text", "This is a test text 2");
check out
Class ActionTriggers | LibreAutomate for more information
Posts: 1,049
Threads: 249
Joined: Jul 2022
Posts: 1,049
Threads: 249
Joined: Jul 2022
12-24-2022, 11:42 PM
(This post was last modified: 12-24-2022, 11:47 PM by Davider.)
Now, LA can recognize the position of the text cursor in almost all software except linqpad
But many input methods can identify, I think it is possible
I use this input methods wubi
Posts: 12,095
Threads: 142
Joined: Dec 2002
I think it is possible only for IME software. LA cannot be an IME software.
Posts: 1,049
Threads: 249
Joined: Jul 2022
#8
@ Gintaras Can you enhance this feature of QM? Or create a filter function?
Almost all of my autotext files about powershell ISE and others are in QM
I'm learning LA, anyway, thanks so much
|