Page 1 of 1

Clipboard copy triggers

PostPosted: Tue Mar 03, 2009 8:03 pm
by Gintaras
Download and import this, and you will have "Clipboard copy" trigger type in Properties.
The macro runs when you copy text in any program and it matches or contains specified text.

Re: Clipboard copy triggers

PostPosted: Fri Aug 09, 2013 3:42 pm
by ssimop
Dear Gintaras,

There exist cases that this trigger ceases working. I still cannot find why. In any case relevant macros, in folder Clipboard Triggers, are not disabled by the user. Furthermore, they do not show at their side any disable icon. How could this can be justified? Moreover to re-enable this trigger you have to exit QM and restart it. Is there any other fast way to re-enable? I tried a couple but I failed.

Any advice much appreciated.

Best regards, Simos.

Re: Clipboard copy triggers

PostPosted: Fri Aug 09, 2013 4:46 pm
by Gintaras
Look in Running items pane, is clipboard_copy_triggers thread running when triggers don't work? It may be hidden, need to check 'Show hidden Running items' in Options -> General.

Re: Clipboard copy triggers

PostPosted: Fri Aug 09, 2013 4:52 pm
by ssimop
Deast Gintaras,

Thanks for an extremely fast response, as usually with You and QM! Yes, this very moment, that this trigger is working perfrctly, it is running. I will let you know when the trgger will cease working.


Re: Clipboard copy triggers

PostPosted: Sat Aug 10, 2013 9:58 am
by ssimop
Dear Gintaras,

Working continuously since my last post, I just realised that clipboard copy tigger ceased responding. The thread is still there.

Regards, Simos

Re: Clipboard copy triggers

PostPosted: Sat Aug 10, 2013 10:36 am
by ssimop
Dear Gintaras,

I am sorry for any inconvenience, it was my fault. One of my macros was incidentally and by mistake killing the thread. Nevertheless, the thread was itself re-generated, but not working properly. I understand this thread is generated when QM is loaded-started. Could you please advise on the way to restart it when QM is running?

Many thanks, Best regards

Re: Clipboard copy triggers

PostPosted: Sun Aug 11, 2013 6:01 am
by Gintaras
Trigger threads should not be killed/restarted. But if need, use this code:

Macro Macro2120     ?
shutdown -6 0 "clipboard_copy_triggers"
;mac "clipboard_copy_triggers" ;;will not work. The thread must be started by the trigger management function, which must be called by QM; QM passes trigger data to it.
;Need to restart QM, or reload file.
;Or add a trigger of this type:
int iid=newitem("" "" "" "^Clipboard_copy ``" "\User\Temp" 128)
newitem iid "" "" "" "\User\Temp" 32 ;;delete

Re: Clipboard copy triggers

PostPosted: Sun Aug 11, 2013 6:08 am
by ssimop
Dear Gintaras,

Many thanks. This is actually what I was doing, but in a more "manual" way. Much obliged, Best personal regards, Simos.

Re: Clipboard copy triggers

PostPosted: Sun Sep 21, 2014 2:26 pm
by Gintaras
Function my_clipboard_triggers     ?

;A lightweight version of clipboard triggers. Can be used in exe. Not integrated into the Properties dialog.
;To define strings and macros, edit the sel code at the end.

AddTrayIcon "$qm$\copy.ico" "Clipboard triggers.[]Ctrl+click to exit." ;;remove this if don't need tray icon

str dd=
;0 "" 0x80C800C8 0x0 0 0 224 136 "My Clipboard Triggers"
;DIALOG EDITOR: "" 0x2040201 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0 HWND_MESSAGE 128)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,int-- t_hwndnext=SetClipboardViewer(hDlg)
,SetTimer hDlg 23 1000 0
,ChangeClipboardChain hDlg t_hwndnext
,case WM_TIMER
,sel wParam
,,case 23 ;;auto restore if another viewer did not remove itself correctly
,,if(!GetClipboardViewer) t_hwndnext=SetClipboardViewer(hDlg)
,case WM_COMMAND ret 1
,if(wParam=t_hwndnext) t_hwndnext=lParam
,else if(t_hwndnext) SendMessage t_hwndnext message wParam lParam
,case WM_DRAWCLIPBOARD ;;clipboard contents changed
,SendMessage t_hwndnext message wParam lParam
,goto onEvent

str s.getclip; err ret
;out s

;edit this code: add/remove case statements with your strings and functions
sel s 2 ;;flag 2 - wildcard. In recent QM versions you also can use flag 4 to support regular expressions.
,case "*Quick*"
,out "Quick"
,;mac "Function301" ;;runs Function301 in new thread. Or you can call it directly, if its execution time is less than 0.1 s.
,case "*Macros*"
,out "Macros"
,;mac "Function302"