Posts: 1,031
Threads: 246
Joined: Jul 2022
11-01-2022, 05:19 AM
(This post was last modified: 11-01-2022, 05:19 AM by Davider.)
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"
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↑
Posts: 1,336
Threads: 61
Joined: Jul 2006
try this
Function autotext_pop
Trigger !v"" "QM_PopupList"
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
;/
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)
Posts: 1,031
Threads: 246
Joined: Jul 2022
11-04-2022, 07:57 PM
(This post was last modified: 11-04-2022, 09:48 PM by Davider.)
Adding the / key to close the list has no effect
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
Posts: 1,336
Threads: 61
Joined: Jul 2006
11-08-2022, 03:15 AM
(This post was last modified: 11-08-2022, 06:25 AM by Kevin.)
autotext_pop and DynamicLVKeys can become 1 function with a couple small adjustments.
Function DynamicLVKeys
Trigger !v"" "" "" "SysListView32" /QM
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.
Posts: 1,031
Threads: 246
Joined: Jul 2022
thank you so much, Works perfectly!
Posts: 1,031
Threads: 246
Joined: Jul 2022
the following code, the QM AutoText list has no effect
if _s="Tab"
,,if(!up)
,,,SendKeysToWindow2(hlv key(Y))
,,ret 1
Posts: 1,336
Threads: 61
Joined: Jul 2006
11-08-2022, 06:27 AM
(This post was last modified: 11-08-2022, 06:41 AM by Kevin.)
I had mention that in a previous post, but doesn't matter fixed in code above
https://www.libreautomate.com/forum/show...6#pid36046
Posts: 1,031
Threads: 246
Joined: Jul 2022
11-08-2022, 09:45 AM
(This post was last modified: 11-08-2022, 09:50 AM by Davider.)
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
Posts: 1,336
Threads: 61
Joined: Jul 2006
11-08-2022, 01:06 PM
(This post was last modified: 11-08-2022, 01:28 PM by Kevin.)
Works for me on both. Your using wrong code
should be
if _s="Tab"
,,if(!up)
,,,SendKeysToWindow2(hwnd key(Y))
,,ret 1
copy code from #7 and try again
Posts: 1,031
Threads: 246
Joined: Jul 2022
Thanks again, Works perfectly!
Posts: 1,031
Threads: 246
Joined: Jul 2022
@ Kevin
Can implement the same key mapping in LA?
The two controls overlapped,
Posts: 12,073
Threads: 140
Joined: Dec 2002
Quote:Can implement the same key mapping in LA?
, and . to select items? No.
Posts: 1,031
Threads: 246
Joined: Jul 2022
Is there no other way?
Using the QM code below has no effect
Function autotext_pop3
Trigger !v"" "Au completion list"
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)
Posts: 1,031
Threads: 246
Joined: Jul 2022
11-12-2022, 07:09 AM
(This post was last modified: 11-12-2022, 07:10 AM by Davider.)
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
, = ↓
. = ↑
/ = Esc
Posts: 1,031
Threads: 246
Joined: Jul 2022
11-16-2022, 10:06 AM
(This post was last modified: 11-16-2022, 10:11 AM by Davider.)
@ 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
Posts: 12,073
Threads: 140
Joined: Dec 2002
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.
// 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);
Posts: 1,031
Threads: 246
Joined: Jul 2022
Great,
Can I change the font of the menu?
I want to change to a monospace font that is more comfortable to look at
Posts: 12,073
Threads: 140
Joined: Dec 2002
m.Font = new(Name: "Consolas");
|