Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AutoText item selection key
#1
Hi,

When the AutoText list pops up, I want to use the , key instead of the down arrow key , use the . key instead of the up arrow key

Is there an easy way to implement it?

Thanks in advance for any advice and help
david


Function autotext_pop
Trigger !v"" "QM_PopupList"     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=TriggerWindow
int hlv=child("" "SysListView32" hwnd)
;Todo: use the , key instead of the down arrow key ↓, with . key instead of the up arrow key↑
#2
try this

Function autotext_pop
Trigger !v"" "QM_PopupList"     Help - how to add the trigger to the macro
 
Code:
Copy      Help
int hwnd=TriggerWindow
int- hlv=child("" "SysListView32" hwnd)
int hh=SetWindowsHookEx(WH_KEYBOARD_LL &sub.Hook_WH_KEYBOARD_LL _hinst 0)
opt waitmsg 1
rep
,0.2 -WV hlv
,err
,,continue
,break
UnhookWindowsHookEx hh

#sub Hook_WH_KEYBOARD_LL
function# nCode message KBDLLHOOKSTRUCT&k
if(nCode<0) goto gNext
int- hlv 
int isActive=hlv
if(!isActive) SendMessage hlv WM_ACTIVATE WA_ACTIVE 0
int up=k.flags&LLKHF_UP
FormatKeyString k.vkCode 0 &_s;
if _s=","
,if(!up)
,,SendKeysToWindow2(hlv key(D))
,ret 1
if _s="."    
,if(!up)
,,SendKeysToWindow2(hlv key(U))    
,ret 1

;gNext
ret CallNextHookEx(0 nCode message &k)

also need this function
Function SendKeysToWindow2
Code:
Copy      Help
;/
function hwnd ARRAY(KEYEVENT)'a

;Sends keys to a child window using WM_KEYDOWN/WM_KEYUP messages.
;The window can be inactive, but with some windows then does not work.

;hwnd - child window handle. Or main window handle, if it receives keys.
;a - the <help>key</help> function.

;EXAMPLE
;int hwnd=id(15 "Notepad")
;SendKeysToWindow2 hwnd key("text[]" Cs)


int i lparam m up alt ati
str sk
ifk(A) alt=1

for i 0 a.len
,KEYEVENT k=a[i]
,if(k.flags&0x80) i+1; continue ;;wait
,sel(k.vk)
,,case [16,17,18]
,,int th1=GetCurrentThreadId
,,int th2=GetWindowThreadProcessId(hwnd &i)
,,ati=AttachThreadInput(th1 th2 1)
,,sk.all(256)
,,0.01
,,break

for i 0 a.len
,k=a[i]
,
,if(k.flags&0x80) ;;wait
,,i+1
,,opt waitmsg -1
,,wait (a[i].wt/1000.0)
,,continue
,
,lparam=k.sc<<16|1
,if(k.flags&KEYEVENTF_EXTENDEDKEY) lparam|0x01000000
,if(k.flags&KEYEVENTF_KEYUP) lparam|0xC0000000; up=1; else up=0
,
,if(alt) m=iif(up WM_SYSKEYUP WM_SYSKEYDOWN); lparam|0x20000000
,else m=iif(up WM_KEYUP WM_KEYDOWN)
,
,if(k.vk=VK_RETURN) 0.01 ;;some controls, eg PSPad, would insert new line too early
,
,PostMessage hwnd m k.vk lparam
,0.01
,
,sel(k.vk)
,,case [16,17,18] ;;modifier keys
,,;wait while processes prev keys
,,if(i) SendMessage hwnd 0 0 0
,,0.01
,,
,,GetKeyboardState sk
,,sk[k.vk]=iif(up 0 0x80)
,,SetKeyboardState sk
,
,if(k.vk=VK_MENU) alt=!up

if(ati) ati=AttachThreadInput(th1 th2 0)
#3
Adding the / key to close the list has no effect
 
Code:
Copy      Help
if _s="/"
,if(!up)
,,SendKeysToWindow2(hlv key(Z))
,ret 1


Function autotext_pop   and  Function DynamicLVKeys   The code is the same, just the trigger window is different, can it be combined into one?

https://www.libreautomate.com/forum/show...9#pid36039


The Function autotext_popup_resize in the following post is related to the above two functions, if the three can be combined into one, it would be more appropriate, otherwise, when executed, three threads will be executed at the same time

https://www.libreautomate.com/forum/show...9#pid35679
#4
autotext_pop   and DynamicLVKeys can become 1 function with a couple small adjustments.

Function DynamicLVKeys
Trigger !v"" "" "" "SysListView32" /QM     Help - how to add the trigger to the macro
 
Code:
Copy      Help
int- hwnd=TriggerWindow
int- hlv=child("" "SysListView32" hwnd)
int cid=GetWinId(hlv)
if(SelInt(cid 8888 3)=0) ret
int hh=SetWindowsHookEx(WH_KEYBOARD_LL &sub.Hook_WH_KEYBOARD_LL _hinst 0)
opt waitmsg 1
rep
,0.2 -WV hlv
,err
,,continue
,break
UnhookWindowsHookEx hh

#sub Hook_WH_KEYBOARD_LL
function# nCode message KBDLLHOOKSTRUCT&k
if(nCode<0) goto gNext
int- hlv
int- hwnd
int isActive=hlv
if(!isActive) SendMessage hlv WM_ACTIVATE WA_ACTIVE 0
int up=k.flags&LLKHF_UP
FormatKeyString k.vkCode 0 &_s;
if _s=","
,if(!up)
,,SendKeysToWindow2(hlv key(D))
,ret 1
if _s="."    
,if(!up)
,,SendKeysToWindow2(hlv key(U))    
,ret 1
if _s="/"    
,if(!up)
,,clo hwnd    
,ret 1    
if _s="Tab"    
,,if(!up)
,,,SendKeysToWindow2(hwnd key(Y))    
,,ret 1    
;gNext
ret CallNextHookEx(0 nCode message &k)

and in DynamicLV
change this line
;0 "" 0x90080AC8 0x0 0 0 184 108 "Dialog_DLV"
to
0 "" 0x90080AC8 0x0 0 0 184 108 ""

the other function will need to remain separate as the hook function needs to be just the keyboard hook.
#5
thank you so much, Works perfectly!
#6
the following code, the QM AutoText list has no effect
Code:
Copy      Help
if _s="Tab"    
,,if(!up)
,,,SendKeysToWindow2(hlv key(Y))    
,,ret 1
#7
I had mention that in a previous post, but doesn't matter fixed in code above

https://www.libreautomate.com/forum/show...6#pid36046
#8
Remove the code below, using tab in the DynamicLV list has no effect, the QM AutoText list has effect
Is it possible to add a judgment to solve the problem

if _s="Tab"
    judgment in the DynamicLV
    if(!up)
        SendKeysToWindow2(hlv key(Y))
    ret 1
#9
Works for me on both. Your using wrong code
should be 
 
Code:
Copy      Help
if _s="Tab"    
,,if(!up)
,,,SendKeysToWindow2(hwnd key(Y))    
,,ret 1    

copy code from #7 and try again
#10
Thanks again, Works perfectly!
#11
@Kevin

Can implement the same key mapping in LA? 

The two controls overlapped, Smile ​​​​​​​

[Image: La.gif]
#12
Quote:Can implement the same key mapping in LA?
, and . to select items? No.
#13
Is there no other way?
Using the QM code below has no effect

Function autotext_pop3
Trigger !v"" "Au completion list"     Help - how to add the trigger to the macro
Code:
Copy      Help
int+ hwnd=TriggerWindow
int- hlv=child("" "Static" hwnd)
int hh=SetWindowsHookEx(WH_KEYBOARD_LL &sub.Hook_WH_KEYBOARD_LL _hinst 0)
opt waitmsg 1
rep
,0.2 -WV hlv
,err
,,continue
,break
UnhookWindowsHookEx hh

#sub Hook_WH_KEYBOARD_LL
function# nCode message KBDLLHOOKSTRUCT&k
if(nCode<0) goto gNext
int- hlv
int isActive=hlv
if(!isActive) SendMessage hlv WM_ACTIVATE WA_ACTIVE 0
int up=k.flags&LLKHF_UP
FormatKeyString k.vkCode 0 &_s;
if _s=","
,if(!up)
,,SendKeysToWindow2(hlv key(D))
,ret 1
if _s="."
,if(!up)
,,SendKeysToWindow2(hlv key(U))
,ret 1
if _s="/"
,out _s
,if(!up)
,,clo hwnd
,ret 1
if _s="Tab"
,if(!up)
,,SendKeysToWindow2(hwnd key(Y))
,ret 1
;gNext
ret CallNextHookEx(0 nCode message &k)
#14
When the autocomplete list appears, it is really convenient to use the mapping of these keys below 
The right hand does not need to move to the position of the keyboard's arrow keys Smile

, = ↓
. = ↑
/ = Esc
#15
@Gintaras

In QM, the dynamic menu can be selected using letter,  (Currently, items in the LA menu can only be selected using the keyboard's arrow keys)
if the letter is unique, it will be selected and execute directly
if there are multiple identical, press the letter key, it will switch between multiple items, as shown in the figure below, can it be achieved in LA? This will be more convenient

In the below, Press the S letter key several times without using the arrow keys
[Image: zzz.gif]
#16
Quote:if there are multiple identical, press the letter key, it will switch between multiple items, as shown in the figure below, can it be achieved in LA?

Currently no. Need to &-mark different characters. In next program version multiple items can have the same character marked.

Code:
Copy      Help
// script ""
var m = new popupMenu();

m["&some"] = o => { print.it(o); };
m["s&ure"] = o => { print.it(o); };
m["s&ine"] = o => { print.it(o); };
m["&several"] = o => { print.it(o); }; //currently this cannot be selected with 's', but in next program version it will work

m.Show(PMFlags.Underline);
#17
Great, 

Can I change the font of the menu?
I want to change to a monospace font that is more comfortable to look at
#18
Code:
Copy      Help
m.Font = new(Name: "Consolas");


Forum Jump:


Users browsing this thread: 3 Guest(s)