Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st March 2019, 19:49   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
ClipBoard v0.04 - 26 Mar 2019

Original thread which prompted ClipBoard plugin:- https://forum.doom9.org/showthread.p...rd#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

Code:
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
Code:
# 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
Code:
# 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
Code:
# 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
Code:
# 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
Code:
# 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)


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).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th March 2019 at 05:15. Reason: Update
StainlessS is offline   Reply With Quote
Old 1st March 2019, 20:25   #2  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,371
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.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 1st March 2019, 21:58   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
OK, I'll give it a try, but gotta get this damn RgbAdapt_graffer thing working properley with clipboard first.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 1st March 2019, 22:43   #4  |  Link
Bernardd
Registered User
 
Join Date: Jan 2012
Location: Toulon France
Posts: 240
Hi StainlessS
Fabulous, with my computer, it speak french.
Thus the clipboard result for this three lines
Quote:
ClipBoard_PutText("some thing")
e = ClipBoard_GetLastErrorString()
ClipBoard_PutText(e)
is
Quote:
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.
Bernardd is offline   Reply With Quote
Old 2nd March 2019, 00:38   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
Quote:
Originally Posted by Bernardd View Post
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).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 2nd March 2019 at 00:46.
StainlessS is offline   Reply With Quote
Old 25th March 2019, 04:42   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
Quote:
Originally Posted by wonkey_monkey View Post
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]

Code:
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
Code:
# 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
Code:
# 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)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th March 2019 at 05:03.
StainlessS is offline   Reply With Quote
Old 26th March 2019, 05:02   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
ClipBoard v0.04, new version, see 1st post.

Added ClipBoard_GetDIB().
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 30th March 2019, 20:22   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
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).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th March 2019 at 20:26.
StainlessS is offline   Reply With Quote
Old 30th March 2019, 22:32   #9  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,371
Does it work if you disable "Use DirectX for display panes" in Preferences?
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 30th March 2019, 22:53   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,152
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]

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).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th March 2019 at 23:20.
StainlessS is offline   Reply With Quote
Reply

Tags
clipboard

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:40.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.