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).
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).