View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Thu Aug 21, 2014 7:38 pm Post subject: Monitor clipboard |
|
|
I am trying to monitor the clipboard for changes using AddClipboardFormatListener and WM_CLIPBOARDUPDATE but no luck. Can anyone give some help?
Here are the pages from MS:
http://msdn.microsoft.com/en-us/library/ms649033(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms649021(VS.85).aspx
This is the code I wrote, but doesn't work.
Code: |
DIALOG CREATE,New Dialog,-1,0,240,160,ontop
REM *** Modified by Dialog Designer on 8/21/2014 - 14:29 ***
DIALOG SHOW
%%CLIPMON = $00000031D
%%WindowID = @winexists(New Dialog)
loadlib user32.dll
%t = @lib(User32,AddClipboardFormatListener,INT,INT:%%WindowID)
freelib user32.dll
option msgevent,%%CLIPMON,CLIPMON,HANDLED
:evloop
wait event
%e = @event()
goto %e
:close
stop
:CLIPMON
info here
goto evloop
|
_________________ Chris
Http://theblindhouse.com
Last edited by LiquidCode on Fri Aug 22, 2014 4:54 pm; edited 2 times in total |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Thu Aug 21, 2014 9:15 pm Post subject: |
|
|
I made a clipboard monitor just using the clipboard function in VDS itself. Worked just fine. Drawback is that it requires actually pulling the data from the clipboard and comparing what you previously had from the clipboard. That, and I only dealt with text data only, didn't try to do anything with any other form of data.
Made another little app for monitoring for URLs on the clipboard and keeping a database of copied URLs for later use, such as keeping them or not. Was going to make an external standalone bookmarks program.
All of what I did was pretty simple stuff though and maybe not the most efficient.
Was the clipboard function not usable for what you needed?
~Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Fri Aug 22, 2014 1:15 pm Post subject: |
|
|
I am using that right now. I save the clipboard text to a var and then check it against what is in there BUT for me even if it is the same text it sometimes (more than not) says it is not the same. I have tried a few different ways (encoding the string and such) with no luck.
I thought the clipboard monitoring would be best if I could get it to work.
May I ask how you were using the VDS clipboard tools? Same way? _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Aug 22, 2014 7:02 pm Post subject: |
|
|
Code: |
TITLE "FreewareHome - Quick Search"
%%SearchIndex = @path(%0)"FreewareHomeSearch.lst"
LIST CREATE,4
LIST LOADFILE,4,%%SearchIndex
IF @greater(@count(4),0)
LIST SEEK,4,0
END
LIST CREATE,1
LIST PASTE,1
IF @text(1)
LIST SEEK,1,0
%%ClipBrdData = @item(1)
ELSE
%%ClipBrdData =
END
DIALOG CREATE,FreewareHome - Clipboard Search,-1,0,180,160,CLASS FREEWAREHOME-CLIPBOARDSEARCH,RESIZABLE,SAVEPOS
DIALOG ADD,CHECK,CHECKENABLE,12,12,60,18,Enable,,,CLICK,SAVE
DIALOG ADD,CHECK,CHECKDISABLE,12,80,60,18,Disable,1,,CLICK,SAVE
DIALOG ADD,LIST,LIST1,40,0,180,120
DIALOG SHOW
:EVENTLOOP
IF @dlgtext(CHECKENABLE)
WAIT EVENT,"0.5"
ELSE
WAIT EVENT
END
GOTO @event()
:RESIZE
IF @greater(130,@dlgpos(,w))
WINDOW POSITION,#FREEWAREHOME-CLIPBOARDSEARCH,,,132,
END
IF @greater(63,@dlgpos(,h))
WINDOW POSITION,#FREEWAREHOME-CLIPBOARDSEARCH,,,,64
END
DIALOG SETPOS,LIST1,,,@dlgpos(,w),@fsub(@dlgpos(,h),40)
GOTO EVENTLOOP
:TIMER
LIST CLEAR,1
LIST PASTE,1
IF @text(1)
LIST SEEK,1,0
%%ClipBrdDataTmp = @item(1)
ELSE
%%ClipBrdDataTmp =
END
IF @unequal(%%ClipBrdDataTmp,%%ClipBrdData)
%%ClipBrdData = %%ClipBrdDataTmp
GOSUB SEARCHNOW
END
GOTO EVENTLOOP
:CLOSE
EXIT
:CHECKENABLECLICK
DIALOG SET,CHECKDISABLE,
%E = @event()
GOTO EVENTLOOP
:CHECKDISABLECLICK
DIALOG SET,CHECKENABLE,
%E = @event()
GOTO EVENTLOOP
:SEARCHNOW
LIST CLEAR,LIST1
LIST CREATE,5
REM DIALOG DISABLE,CHECKDISABLE
REM DIALOG DISABLE,CHECKENABLE
%A = @dlgpos(LIST1,h)
REPEAT
DIALOG SETPOS,LIST1,,,,@fsub(@dlgpos(LIST1,h),1)
UNTIL @equal(@dlgpos(LIST1,h),1)
IF @greater(@count(4),0)
LIST SEEK,4,0
REPEAT
IF @greater(@pos(%%ClipBrdData,@item(4)),0)
LIST ADD,LIST1,@item(4)
END
%%Null = @next(4)
UNTIL @not(@ok())
END
IF @null(@text(LIST1))
LIST ADD,LIST1,"[ No hits for: "%%ClipBrdData" ]"
PLAY @path(%0)hit-null.wav
ELSE
PLAY @path(%0)hit-yes.wav
END
REPEAT
DIALOG SETPOS,LIST1,,,,@sum(@dlgpos(LIST1,h),1)
UNTIL @equal(@dlgpos(LIST1,h),%A)
REM DIALOG ENABLE,CHECKDISABLE
REM DIALOG ENABLE,CHECKENABLE
LIST CLEAR,5
LIST CLOSE,5
EXIT |
You can run this as is, but you'll be missing the database file(s) used to compare the clipboard text against in the search. So just make a text file with single words on each line use that instead.
The above worked just fine for me and I never had any misfires or any problems. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Aug 22, 2014 7:04 pm Post subject: |
|
|
I apologize. I thought I was using clipboard but now I see that I was not. I was using "LIST PASTE" instead. Really sorry about that. It's been a while since I looked at this code or used it. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Sat Aug 23, 2014 1:01 am Post subject: |
|
|
I'll take a look. List paste might just work for me. I don't really need to keep any formatting so it just might be what I need. I didn't think of doing it that way. Thanks! _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Sat Aug 23, 2014 1:17 am Post subject: |
|
|
Using VDS 5 or 6? It seems like it might not be the clipboard, but @unequal() that the issue is with. But I am not 100% sure. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Aug 23, 2014 4:20 am Post subject: |
|
|
That was done in VDS 6. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|