dcandygmailcom

PrintClip.exe prints any text on the clipboard to a console.

Feb 16th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.08 KB | None | 0 0
  1. REM Two files follow
  2. REM PrintClip.bat
  3. REM This file compiles PrintClip.vb to PrintClip.exe
  4. REM PrintClip.exe prints any text on the clipboard to a console. The inbuilt command Clip.exe only puts text on the clipboard
  5. REM To use
  6. REM PrintClip
  7. "C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\PrintClip.exe" "%~dp0\PrintClip.vb" /verbose
  8. pause
  9.  
  10. --------------------------------------------------------------
  11.  
  12. 'PrintClip.vb
  13. Imports System
  14. Imports System.IO
  15. Imports System.Runtime.InteropServices
  16. Imports Microsoft.Win32
  17.  
  18. Public Module PrintClip
  19.     Public Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Integer
  20.     Public Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Integer) As IntPtr
  21.     Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As IntPtr) As Integer
  22.     Public Declare Function CloseClipboard Lib "user32" () As Integer
  23.  
  24.     Public Const CF_TEXT = 1
  25.     Public Const CF_BITMAP = 2
  26.     Public Const CF_METAFILEPICT = 3
  27.     Public Const CF_SYLK = 4
  28.     Public Const CF_DIF = 5
  29.     Public Const CF_TIFF = 6
  30.     Public Const CF_OEMTEXT = 7
  31.     Public Const CF_DIB = 8
  32.     Public Const CF_PALETTE = 9
  33.     Public Const CF_PENDATA = 10
  34.     Public Const CF_RIFF = 11
  35.     Public Const CF_WAVE = 12
  36.     Public Const CF_UNICODETEXT = 13
  37.     Public Const CF_ENHMETAFILE = 14
  38.     Public Const CF_OWNERDISPLAY = &H80
  39.     Public Const CF_DSPTEXT = &H81
  40.     Public Const CF_DSPBITMAP = &H82
  41.     Public Const CF_DSPMETAFILEPICT = &H83
  42.     Public Const CF_DSPENHMETAFILE = &H8E
  43.  
  44.  
  45.     Sub Main()
  46. '       On Error Resume Next
  47.         Dim Ret as IntPtr
  48.         If OpenClipboard(0) = 0 then
  49.             Console.Writeline(err.lastdllerror)
  50.             Console.Writeline("Clipboard is locked by another application")
  51.             Environment.ExitCode = 2
  52.         Else
  53.             If IsClipboardFormatAvailable(CF_UNICODETEXT) = 0 then
  54.                 Console.writeline("No text on clipboard")
  55.                 Environment.ExitCode = 1
  56.             Else
  57.                 Ret = GetClipboardData( CF_UNICODETEXT)
  58.                 Console.writeline(Marshal.PtrToStringUni(Ret))
  59.                 Environment.ExitCode = 0
  60.             End If
  61.             CloseClipboard()
  62.         End If
  63.  
  64.     End Sub
  65. End Module
Advertisement
Add Comment
Please, Sign In to add comment