Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Menu from selected text (google, translate, dictionary, etc)
Macro Menu from selected text
Trigger #CSR     Help - how to add the trigger to the macro
Select All      Help
;This is similar to Accelerators in Internet Explorer 8. Works anywhere.
;Trigger: Ctrl+Shift+ right click.
;Gets selected text. If there is no selection, or selection is the same as previously, double-clicks to select word from mouse and gets the word.
;Then shows menu. You can google for the text, open as URL, translate, etc.
;Requires QM 2.3.2 or later.


spe 10
str+ g_mfst g_mfst2
str s.getsel; s.trim
if !s.len or s=g_mfst
,dou; 0.1
,s.getsel; s.trim

if(!s.len) ret

str sEsc=s; sEsc.escape(9)
str pt=g_mfst2; if(pt.len>50) pt.fix(50); pt+"..."


;This code defines default menu items and code for them.
;You can change all it.

str menuItems=
;1 Google search
;6 Wikipedia
;2 URL open
;9 Longman dictionary
;4 MW dictionary
;10 Wordnik dictionary
;11 Wiktionary
;3 Urban dictionary
;5 Speak
;7 Map of address
;21 Google translate to EN
;1000 Previous text ({pt})
;1002 Input text
;1001 Edit this menu

MenuPopup m
;here you can add/remove/disable items depending on conditions: if(condition) m.AddItems(...).

sel m.Show()
,case 1 run F"{sEsc}"
,case 6 run F"{sEsc}"
,case 2 run s
,case 9 run F"{sEsc}"
,case 4 run F"{sEsc}"
,case 10 run F"{sEsc}"
,case 11 run F"{sEsc}"
,case 3 run F"{sEsc}"
,case 5 Speak s
,case 7 run F"{sEsc}"
,case 21 run F"|en|{sEsc}"
,case 1000 s=g_mfst2; goto g2
,case 1002 if(inp(s "" "" s)) goto g2
,case 1001 mac+ getopt(itemid)


DestroyMenu m; m=0
goto g1

I use this function instead of run. It opens url in separate IE window. Does not create new tab in IE.
Function MFST_Open
Select All      Help
function# $url [flags] ;;flags: 1 wait

;Opens URL in IE.
;Uses separate IE window.
;Returns IE window handle.

int w1=FindTaggedWindow("qm_mfst" " Internet Explorer" "IEFrame")
if w1
,act w1
,run "iexplore.exe" "" "" "" 0x2800 win(" Internet Explorer" "IEFrame") w1
,TagWindow w1 "qm_mfst"
,wait 30 WC child("" "Internet Explorer_Server" w1)

web url flags&1 w1

ret w1
i use Wf (windows f) as trigger. now i finally have a global find menu.

Forum Jump:

Users browsing this thread: 1 Guest(s)