Jump to content

[VBScript]Clipboard


Recommended Posts


As far as I'm aware, you could be out of luck.

You could access the clipboard data, but whether there would be a way, without possibly using the clipboard object in VB, to ascertain the data type would be doubtful.

My best guess would be to see if there was something distinguishable in all images and try to parse the clipboard data using the ADOStream object to read it as binary.

Link to comment
Share on other sites

I don't know if you can call into the API with VBscript, but...

The GetClipboardData function retrieves data from the clipboard in a specified format. The clipboard must have been opened previously.

HANDLE GetClipboardData(

UINT uFormat // clipboard format

);

Parameters

uFormat

Specifies a clipboard format. For a description of the clipboard formats, see the SetClipboardData function.

Return Values

If the function succeeds, the return value is the handle of a clipboard object in the specified format.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

An application can enumerate the available formats in advance by using the EnumClipboardFormats function.

The clipboard controls the handle that the GetClipboardData function returns, not the application. The application should copy the data immediately. The application cannot rely on being able to make long-term use of the handle. The application must not free the handle nor leave it locked.

The operating system performs implicit data format conversions between certain clipboard formats when an application calls the GetClipboardData function. For example, if the CF_OEMTEXT format is on the clipboard, a window can retrieve data in the CF_TEXT format. The format on the clipboard is converted to the requested format on demand. The following table shows the clipboard data type conversions that are available. Note that some of these automatic type conversions are not available on all platforms.

Clipboard Format Conversion Format Platform Support

CF_BITMAP CF_DIB Windows NT, Windows 95

CF_DIB CF_BITMAP Windows NT, Windows 95

CF_DIB CF_PALETTE Windows NT, Windows 95

CF_ENHMETAFILE CF_METAFILEPICT Windows NT, Windows 95

CF_METAFILEPICT CF_ENHMETAFILE Windows NT, Windows 95

CF_OEMTEXT CF_TEXT Windows NT, Windows 95

CF_OEMTEXT CF_UNICODETEXT Windows NT

CF_TEXT CF_OEMTEXT Windows NT, Windows 95

CF_TEXT CF_UNICODETEXT Windows NT

CF_UNICODETEXT CF_OEMTEXT Windows NT

CF_UNICODETEXT CF_TEXT Windows NT

If the operating system provides an automatic type conversion for a particular clipboard format, there is no advantage to placing the conversion format(s) on the clipboard.

If the system provides an automatic type conversion for a particular clipboard format, and you call EnumClipboardFormats to enumerate the clipboard data formats, the operating system first enumerates the format that is on the clipboard, followed by the formats to which it can be converted.

If the clipboard contains data in the CF_PALETTE format, the application should use the SelectPalette and RealizePalette functions to realize any other data in the clipboard against that logical palette.

See SetClipboardData for further information on specific clipboard data formats.

...and...
The EnumClipboardFormats function lets you enumerate the data formats that are currently available on the clipboard.

Clipboard data formats are stored in an ordered list. To perform an enumeration of clipboard data formats, you make a series of calls to the EnumClipboardFormats function. For each call, the format parameter specifies an available clipboard format, and the function returns the next available clipboard format.

UINT EnumClipboardFormats(

UINT format // specifies a known available clipboard format

);

Parameters

format

Specifies a clipboard format that is known to be available.

To start an enumeration of clipboard formats, set format to zero. When format is zero, the function retrieves the first available clipboard format. For subsequent calls during an enumeration, set format to the result of the previous EnumClipboardFormat call.

Return Values

If the function succeeds, the return value is the clipboard format that follows the specified format. In other words, the next available clipboard format.

If the function fails, the return value is zero. To get extended error information, call GetLastError. If the clipboard is not open, the function fails.

If there are no more clipboard formats to enumerate, the return value is zero. In this case, the GetLastError function returns the value NO_ERROR. This lets you distinguish between function failure and the end of enumeration.

Remarks

You must open the clipboard before enumerating its formats. Use the OpenClipboard function to open the clipboard. The EnumClipboardFormats function fails if the clipboard is not open.

The EnumClipboardFormats function enumerates formats in the order that they were placed on the clipboard. If you are copying information to the clipboard, add clipboard objects in order from the most descriptive clipboard format to the least descriptive clipboard format. If you are pasting information from the clipboard, retrieve the first clipboard format that you can handle. That will be the most descriptive clipboard format that you can handle.

The operating system provides automatic type conversions for certain clipboard formats. In the case of such a format, this function enumerates the specified format, then enumerates the formats to which it can be converted. For more information about clipboard formats and automatic clipboard format type conversions, see the GetClipboardData and SetClipboardData functions.

Link to comment
Share on other sites

well, after searching Microsoft for some info, i found out about getting the info from the Clipboard here.

the current code that i have right now is this.

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
clpData = objIE.document.parentwindow.clipboardData.GetData("text")
objIE.Quit

Set objShell = CreateObject("Wscript.Shell")

right now, i'm not really sure how to make the script figure out if the Clipboard contains a string.

Link to comment
Share on other sites

This will only confirm if there is a text string in the clip board

Dim clpData, objIE
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
clpData = objIE.document.parentwindow.clipboardData.GetData("text")
objIE.Quit
If InStr(clpData,"clpData") Then
MsgBox "Nothing In The Clip Board", 0 + 32 + 4096,"Clip Board Data"
Else
MsgBox "Found This Text string : " & clpData, 0 + 32 + 4096,"Clip Board Data"
End If

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...