Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM Two files follow
- REM PrintClip.bat
- REM This file compiles PrintClip.vb to PrintClip.exe
- REM PrintClip.exe prints any text on the clipboard to a console. The inbuilt command Clip.exe only puts text on the clipboard
- REM To use
- REM PrintClip
- "C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\PrintClip.exe" "%~dp0\PrintClip.vb" /verbose
- pause
- --------------------------------------------------------------
- 'PrintClip.vb
- Imports System
- Imports System.IO
- Imports System.Runtime.InteropServices
- Imports Microsoft.Win32
- Public Module PrintClip
- Public Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Integer
- Public Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As IntPtr
- Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As IntPtr) As Integer
- Public Declare Function CloseClipboard Lib "user32" () As Integer
- Public Const CF_TEXT = 1
- Public Const CF_BITMAP = 2
- Public Const CF_METAFILEPICT = 3
- Public Const CF_SYLK = 4
- Public Const CF_DIF = 5
- Public Const CF_TIFF = 6
- Public Const CF_OEMTEXT = 7
- Public Const CF_DIB = 8
- Public Const CF_PALETTE = 9
- Public Const CF_PENDATA = 10
- Public Const CF_RIFF = 11
- Public Const CF_WAVE = 12
- Public Const CF_UNICODETEXT = 13
- Public Const CF_ENHMETAFILE = 14
- Public Const CF_OWNERDISPLAY = &H80
- Public Const CF_DSPTEXT = &H81
- Public Const CF_DSPBITMAP = &H82
- Public Const CF_DSPMETAFILEPICT = &H83
- Public Const CF_DSPENHMETAFILE = &H8E
- Sub Main()
- ' On Error Resume Next
- Dim Ret as IntPtr
- If OpenClipboard(0) = 0 then
- Console.Writeline(err.lastdllerror)
- Console.Writeline("Clipboard is locked by another application")
- Environment.ExitCode = 2
- Else
- If IsClipboardFormatAvailable(CF_UNICODETEXT) = 0 then
- Console.writeline("No text on clipboard")
- Environment.ExitCode = 1
- Else
- Ret = GetClipboardData( CF_UNICODETEXT)
- Console.writeline(Marshal.PtrToStringUni(Ret))
- Environment.ExitCode = 0
- End If
- CloseClipboard()
- End If
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment