Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wait for ... new clipboard item
#1
is there a way i can have QM do something when a new clipboard item appears....

i see the s.getclip but how can i get QM to 'listen' for this event (new clip) so i can process the clip automatically (executes a macro). So i guess the new clipboard item would be like a trigger

i have a program that automatically selects and copies text so i wont be sending any keyboard keys (ctrl+c). so i need it to monitor the clipboard

thanks
#2
Function clipboard_text_viewer
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Clipboard text viewer" "4"
;3 Edit 0x54200844 0x20000 0 0 224 136 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret ;;hide dialog with flag 128


#sub DlgProc
function# hDlg message wParam lParam

dll user32 #AddClipboardFormatListener hwnd
dll user32 #RemoveClipboardFormatListener hwnd
def WM_CLIPBOARDUPDATE 0x031D

sel message
,case WM_INITDIALOG
,AddClipboardFormatListener(hDlg)
,
,case WM_DESTROY
,RemoveClipboardFormatListener(hDlg)
,
,case WM_CLIPBOARDUPDATE
,SetTimer hDlg 1 150 0 ;;get clipboard text after some time. Not now, because it creates problems for other apps and scripts, for example for QM clipboard functions.
,
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hDlg wParam
,,str s.getclip; err
,,s.setwintext(id(3 hDlg))
,,
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#3
thanks for the code. i get an error on line 18, in the function, 'AddClipboardFormatListener'  is there a file with functions i am supposed to import?
 
Code:
Copy      Help
sel message
,case WM_INITDIALOG
,AddClipboardFormatListener(hDlg)
#4
I forgot to add API declarations in the code. Now fixed.
#5
thanks alot. it works, i have been trying to unpack this (dont understand C++ nor QM well) and i am struggling with the logic and using it for my own.

i want to use the clipboard as a trigger. just like i can use the folder/file as a trigger on append or create etc... it just works in the background without me needing to do anything and whatever is in the macro (that is assigned this trigger) gets executed... same concept but for the clipboard

if window name =  then add clipboard item to this text file
if window name = then do this with clipboard item
if clipboard item contains then do this
else
do nothing
(i can do this part just need help with the clipboard trigger and returning the clip as a variable so i can process)

i try to remove everything related to dialogue box and tried to put it back together but am struggling.  hopefully i made more sense now. i appreciate the help


Forum Jump:


Users browsing this thread: 1 Guest(s)