View Full Version : ClipBoard v0.04 - 26 Mar 2019


StainlessS
1st March 2019, 19:49
Original thread which prompted ClipBoard plugin:- https://forum.doom9.org/showthread.php?p=1862931&highlight=clipboard#post1862931

Giving this its own thread due to usage via RgbAdapt_Graffer.

RgbAdapt:-
https://forum.doom9.org/showthread.php?t=170642

and Bernardd's Automatic white balance with RGBAdapt plugin:-
https://forum.doom9.org/showthread.php?t=174411


ClipBoard() v0.04, by StainlessS, http://forum.doom9.org/showthread.php?t=173538

ClipBoard_GetText() : Get text from ClipBoard.
Returns:-
Int,
0 : ANSI text not available on ClipBoard
-1: Cannot Open Clipboard
-2: Cannot get ClipBoard data
-3: Lock ClipBoard memory failed
String,
ANSI TEXT String from ClipBoard.

###

ClipBoard_Clear() : Clear everything from ClipBoard [TAKE CARE, should only really be done by the USER].
Int Returns:-
0 : SUCCESS
-1: Cannot Open Clipboard
-2: Cannot CLEAR ClipBoard

###

ClipBoard_PutText(String s) : Clear ClipBoard and then set string s as ANSI Text on ClipBoard [Error alert if s==""].
[TAKE CARE, only USER should set ClipBoard data].
Returns:-
Int,
0 : SUCCESS
-1: Cannot Open Clipboard
-2: Cannot CLEAR ClipBoard
-3: Cannot SET ClipBoard Text
-4: Cannot Allocate system GLOBAL memory

###

ClipBoard_GetLastError() : Get system error code as Int for previous call to ClipBoard functions. (Error Code cleared on entry to ClipBoard functions)

Returns:-
0 : No Error
Else Some system Error Code.

###

ClipBoard_GetLastErrorString() : Get system error as String, for previous call to ClipBoard functions. (Error Code cleared on entry to ClipBoard functions)

Returns:- Error String describing error code.


###

ClipBoard_GetDIB(Bool "Debug"=False) : Get DIB/BitMap from ClipBoard (RGB24 and RGB32[as RGB24] Only).

Debug, Default False, sends some debug stuff to the DebugView window (Google). May be removed in future version.

Returns:-
Int,
0 : DIB Bitmap not available on ClipBoard
-1: Cannot Open Clipboard
-2: Cannot get ClipBoard data
-3: Lock ClipBoard memory failed
-?: Other errors (See DebugView output, Google)
Clip,
DIB/Bitmap from ClipBoard. (Single Frame RGB24 @ 24FPS).

###


Clear_Text.avs

# Need DebugView (Google)

# Copy entire script to clipboard before play script [CTRL/A then CTRL/C]

S=ClipBoard_Clear()

RT_DebugF("%s",String(S),name="ClipBoard_ClearText: ")

Return MessageClip("OK")


PutText.avs

# Need DebugView (Google)

PPP="""
Some Demo text
And some more.
"""

E=ClipBoard_PutText(PPP)
S=ClipBoard_GetText()

RT_DebugF("PutError=%s\nGetText='%s'",String(E),String(S),name="ClipBoard_PutText: ")

Return MessageClip("OK")


GetText.avs

# Need DebugView (Google)

# Copy entire script to clipboard before play script [CTRL/A then CTRL/C]

S=ClipBoard_GetText()

RT_DebugF("%s",String(S),name="ClipBoard_GetText: ")

Return MessageClip("OK")


GetLastError.avs

# Need DebugView (Google)

# Just to show error code 0

ClipBoard_Clear() # No Text Available on ClipBoard
S = ClipBoard_GetText() # No text is Available on ClipBoard [Error code == 0, not an error]
E = ClipBoard_GetLastError() # == 0
ES= ClipBoard_GetLastErrorString()
RT_DebugF("ClipBoard_GetText()=%s\nERROR CODE = %d ($%08X) ['%s']",String(S),E,E,ES,name="ClipBoard_GetLastError: ")
Return MessageClip("OK")


ShowAndWriteClipBoard_DIB.AVS Requires Groucho2004 SysInfo plugin v0.1.0.7:- https://forum.doom9.org/showthread.php?t=176131

# ShowAndWriteClipBoard_DIB.AVS
# Show & Write to Image file, last Bitmap copied to ClipBoard (eg "CTRL/Print_Screen" or "CTRL/Fn/Print_Screen" or whatever your key combo is)
# VDub2 does NOT need be TOP Window to CAP & Write Screen Using eg CTRL/Print_Screen
####### CONFIG ################
W=640 # If W > 0 then resize clipBoard Bitmap to W : Else use Original Screen X Dimension
H=480 # If Y > 0 then resize clipBoard Bitmap to H : Else use Original Screen Y Dimension
CHECKEVERY=24 # Check for ClipBoard BitMap every CHECKEVERY frames (24 = once per second for 24FPS Blankclip)
# MPC-HC seems a little unresponsive to this script, VDub2 plays fine, x86 and x64.
WRITE=True # Write BitMap to eg D:\CB_000000.BMP, Requires RT_Stats v1.43 if WRITEFILE NOT FullPathName (Incl COLON eg 'D:\')
WRITEFILE="D:\ClipBoard\CB_" # Path MUST Exist
DEBUG=False
######## End Of CONFIG ###############
WRITEFILE = (WRITE && FindStr(WRITEFILE,":")==0) ? RT_GetFullPathName(WRITEFILE) : WRITEFILE
XRES=SI_ScreenResX YRES=SI_ScreenResY # Req Groucho2004 SysInfo plugin v0.1.0.7
W = (W<=0) ? XRES : W H = (H<=0) ? YRES : H RESIZE = (W!=XRES || H!=YRES)
BlankClip(Width=W,Height=H,Length=24*60*60,Pixel_Type="RGB24").KillAudio
CLP=Trim(0,-1) WrClp=CLP.BlankClip(Length=0) IMGN=0 # Dummy Prep
SSS="""
n = current_frame
CB=(n % CHECKEVERY == 0) ? ClipBoard_GetDIB(Debug=DEBUG) : 0
GotDIB=(CB.IsClip)
(GotDIB) ? ClipBoard_Clear() : NOP
CB = (GotDIB&&RESIZE) ? CB.BiCubicResize(W,H) : CB
WrClp= (GotDIB&&WRITE) ? WrClp++CB : WrClp
current_frame = (GotDIB&&WRITE) ? IMGN : n # Force ImageWriter to use our ClipBoard CAP frame number
CLP = (GotDIB&&WRITE) ? WrClp.ImageWriter(WRITEFILE,type="bmp") : CLP
IMGN = (GotDIB&&WRITE) ? IMGN + 1 : IMGN
return CLP
"""
Scriptclip(SSS)

https://i.postimg.cc/7GS0RjPT/Show-Clip-Board-DIB.jpg (https://postimg.cc/7GS0RjPT)

Plugin for avs v2.58, avs v2.6, Avs+ x86 and x64, with source code and full VS 2008 project files.

See MediaFire in sig below this post (~70KB).

wonkey_monkey
1st March 2019, 20:25
Any chance of a ClipBoard_GetImage, which returns any DIB on the clipboard (if there is one) as an RGB24 clip, or otherwise throws an error? Could be a very useful thing for debugging and developing.

StainlessS
1st March 2019, 21:58
OK, I'll give it a try, but gotta get this damn RgbAdapt_graffer thing working properley with clipboard first.

Bernardd
1st March 2019, 22:43
Hi StainlessS
Fabulous, with my computer, it speak french.
Thus the clipboard result for this three lines
ClipBoard_PutText("some thing")
e = ClipBoard_GetLastErrorString()
ClipBoard_PutText(e)
is
L’opération a réussi. (0x00000000)

And good news, i have no problem to export to clipboard, the computed args of Automatic white balance with RGBAdapt plugin.

StainlessS
2nd March 2019, 00:38
my computer, it speak french.

Stop bragging, mine cant speak French, and neither can I.

Give it a whirl please.
(I thought clipboard might be preferable to writing to file).

StainlessS
25th March 2019, 04:42
Any chance of a ClipBoard_GetImage, which returns any DIB on the clipboard (if there is one) as an RGB24 clip, or otherwise throws an error? Could be a very useful thing for debugging and developing.

Wanna give this a whirl:- LINK REMOVED.
3 dll's, v2.58, avs/+ x86 And x64, full source + VS2008 project files. [Consider it Beta]


ClipBoard_GetDIB() : Get DIB/BitMap from ClipBoard (RGB24 and RGB32[as RGB24] Only).
Returns:-
Int,
0 : DIB Bitmap not available on ClipBoard
-1: Cannot Open Clipboard
-2: Cannot get ClipBoard data
-3: Lock ClipBoard memory failed
-?: Other errors (See DebugView output, Google)
Clip,
DIB/Bitmap from ClipBoard. (Single Frame RGB24 @ 24FPS).



GetDIB.avs

# Need DebugView (Google)

E=ClipBoard_GetDIB()

(!E.IsClip) ? RT_DebugF("Error=%d",E,name="ClipBoard_GetDIB: ") : NOP

Return E.IsClip ? E : MessageClip("Result="+String(e))


Time For Bed.

EDIT: Requires Groucho2004 SysInfo:- https://forum.doom9.org/showthread.php?t=176131
ShowClipBoard_DIB.AVS

# ShowClipBoard_DIB.AVS
# Show last Bitmap copied to ClipBoard (eg CTRL/ALT/Print Screen or whatever your key combo is)

W=SI_ScreenXRes # Req Groucho2004 SysInfo plugin v0.1.0.6
H=SI_ScreenYRes

BlankClip(Width=W,Height=h,Length=24*60*60,Pixel_Type="RGB24")
CLP=Trim(0,-1) # Dummy Prep
SSS="""
CB=ClipBoard_GetDIB()
GotDIB=(CB.IsClip)
CLP = (GotDIB) ? CB : CLP
(GotDIB) ? ClipBoard_Clear() : NOP
return CLP
"""
Scriptclip(SSS)

https://i.postimg.cc/7GS0RjPT/Show-Clip-Board-DIB.jpg (https://postimg.cc/7GS0RjPT)

StainlessS
26th March 2019, 05:02
ClipBoard v0.04, new version, see 1st post.

Added ClipBoard_GetDIB().

StainlessS
30th March 2019, 20:22
Just a heads up,

If using VDub2 with ShowAndWriteClipBoard_DIB.Avs, and enlarge Input Pane until it snaps full width, then for some reason Print Screen (copy screen to clipboard)
copies only the black frame contents, and nothing else (ie not the Vdub2 GUI or desktop), no real idea why it does that.
Although it works ok if you switch to a different screen (put VDub2 in background).

wonkey_monkey
30th March 2019, 22:32
Does it work if you disable "Use DirectX for display panes" in Preferences?

StainlessS
30th March 2019, 22:53
Actually, I was talking rubbish, I could have sworn that it does not cap the VDub GUI, but it does (with/without DirectX),
Its just that the visible frame is full black, and when capped, is exactly same as previous frame with full black contents.
(The GUI will be present but off bottom [and top] of frame and not visible in VDub, and so not subsequently capped later )
If not snapped full width, then each successive cap frame gets smaller as in below [edit: Or more specifically the cap of the copies of all preceding images get smaller]
https://i.postimg.cc/7GS0RjPT/Show-Clip-Board-DIB.jpg (https://postimg.cc/7GS0RjPT)
Judging by above, it looks to be the 13th cap frame.

This is what comes out after several caps when snapped full width frame (but appears in VDub2 as just black frame due to vertical centering).
https://i.postimg.cc/XqrSZsgC/CB-000000.jpg (https://postimages.org/)