Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displays the autoText menu below caret point
#1
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

[Image: zzz.gif]

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:
 
Code:
Copy      Help
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
#2
I tested PE current version (free) on Win11. In PS it shows menu at mouse position.

AccessibleObjectFromWindow fails.

Code:
Copy      Help
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);
#3
my systtem: win7 64bit ps5.1
Tick the options below in PE

[Image: abc.png]

In the above code, the test failed

In the address bar of Google Chrome, the menu list overwrites the typing text
#4
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.
#5
Probably this interesting problem can be solved in the near future  Smile

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 ②

[Image: ISE.png]
#6
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?
#7
Yes
[Image: cc.png]

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
#8
Quote:Probably this interesting problem can be solved in the near future
In next program version.

Also in next version:
Code:
Copy      Help
tt.MenuOptions = new(PMFlags.ByCaret | PMFlags.WindowCenter);
#9
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?
#10
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.
#11
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

LA:  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

[Image: abc.gif]
#12
Code:
Copy      Help
        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
#13
@Kevin
thank you so much
#14
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
[Image: 1672184508]
#15
I think it is possible only for IME software. LA cannot be an IME software.
#16
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)