Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mouse Select Text Trigger
#1
I'd like to have a toolbar pop-up (or several) when I've selected text in a certain program. I there a way to have it trigger toolbars and place them around the mouse pointer when you release the left-button when doing a drag select?
An old blog on QM coding and automation.

The Macro Hook
#2
Toolbar tb_drag_select
Code:
Copy      Help
;/mov {ret xm-10} {ret ym+10}

Function tb_drag_select_f
Trigger #Lh1 0x1 /WORDPAD /FF_tb_drag_select     Help - how to add the trigger to the macro
Code:
Copy      Help
;is drag distance >=4 pixels?
POINT+ g_tbds
POINT p; xm p
if(_hypot(p.x-g_tbds.x p.y-g_tbds.y)<4) ret

;is text selection?
str s.getsel
if(!s.len) ret

int h=win("TB_DRAG_SELECT" "QM_Toolbar")
if(h) mov xm-10 ym+10 h
else mac "tb_drag_select"

Function FF_tb_drag_select (this is filter function. Set it in Properties)
Code:
Copy      Help
;/
function# iid FILTER&f

;if(!childtest(f.hwnd2 ...)) ret -2

POINT+ g_tbds
xm g_tbds
ret iid

;ret iid    - run the macro.
;ret macro    - run other macro. Here 'macro' is its id or name.
;ret 0        - don't run any macros.
;ret -1        - don't run any macros but eat the key. Eg if the filter function started a macro using mac.
;ret -2        - don't run this macro. Other macros with the same trigger can run.

On mouse left button down in client area of a WORDPAD window, runs FF_tb_drag_select. Edit it. ret -2 if it is wrong window or wrong child window. On button up, runs tb_drag_select_f. It measures drag distance, checks whether there is selected text, and if all ok launches the toolbar or moves it to mouse position.
#3
awesome! thanks.
An old blog on QM coding and automation.

The Macro Hook
#4
BTW: let me know when you can make a toolbar circular...that'd be Awesome for this.
An old blog on QM coding and automation.

The Macro Hook
#5
is there a way to have it close if i click some where else like a menu (as if i didn't need it) does?
An old blog on QM coding and automation.

The Macro Hook
#6
Function tb_drag_select_f
Trigger #Lh1 0x1 /WORDPAD /FF_tb_drag_select     Help - how to add the trigger to the macro
Code:
Copy      Help
;is drag distance >=4 pixels?
POINT+ g_tbds
POINT p; xm p
if(_hypot(p.x-g_tbds.x p.y-g_tbds.y)<4) ret

;is text selection?
str s.getsel
if(!s.len) ret

int h=win("TB_DRAG_SELECT" "QM_Toolbar")
if(h) mov xm-10 ym+10 h
else h=mac("tb_drag_select")

;wait for click, and close
rep
,wait 0 ML
,if(win(mouse)!=h)
,,clo h
,,break
#7
works great!
since i need it to close even if i choose a toolbar button I changed that new code to this.

Function tb_drag_select_f
Trigger #Lh1 0x1 /NOTEPAD++ /FF_tb_drag_select     Help - how to add the trigger to the macro
Code:
Copy      Help
rep
,wait 0 ML
,clo h
,break
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 1 Guest(s)