Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AutoText item selection 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)


Messages In This Thread
AutoText item selection key - by Davider - 11-01-2022, 05:19 AM
RE: AutoText item selection key - by Kevin - 11-02-2022, 01:43 PM
RE: AutoText item selection key - by Davider - 11-04-2022, 07:57 PM
RE: AutoText item selection key - by Kevin - 11-08-2022, 03:15 AM
RE: AutoText item selection key - by Davider - 11-08-2022, 03:40 AM
RE: AutoText item selection key - by Davider - 11-08-2022, 04:47 AM
RE: AutoText item selection key - by Kevin - 11-08-2022, 06:27 AM
RE: AutoText item selection key - by Davider - 11-08-2022, 09:45 AM
RE: AutoText item selection key - by Kevin - 11-08-2022, 01:06 PM
RE: AutoText item selection key - by Davider - 11-08-2022, 09:30 PM
RE: AutoText item selection key - by Davider - 11-11-2022, 10:07 AM
RE: AutoText item selection key - by Gintaras - 11-11-2022, 10:20 AM
RE: AutoText item selection key - by Davider - 11-12-2022, 02:11 AM
RE: AutoText item selection key - by Davider - 11-12-2022, 07:09 AM
RE: AutoText item selection key - by Davider - 11-16-2022, 10:06 AM
RE: AutoText item selection key - by Gintaras - 11-16-2022, 12:43 PM
RE: AutoText item selection key - by Davider - 11-16-2022, 01:21 PM
RE: AutoText item selection key - by Gintaras - 11-16-2022, 01:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)