Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access to clipboard content other than wshextra? 1

Status
Not open for further replies.

jfdabiri

MIS
Feb 27, 2007
282
US
Hi,
is there a way to have access to contents of clipboard object other than using wshextra? i have looked for this in tek-tip, and i found wshextra and it's usage. but i'm trying to implement this with existing object. my idea is to set: some_variable = contents of clipboard.
any ideas?
 
What script host? If you're writing an HTA you have clipboard access via the IE object model (window.clipboardData object).

There is nothing built into WSH for this though.
 
[tt]dim s
'clipboard : text only
with createobject("internetexplorer.application")
.navigate "about:blank"
s=.document.parentwindow.clipboarddata.getdata("text")
.quit
end with
if not isempty(s) then
wscript.echo s
else
wscript.echo "nothing captured"
s=""
end if
[/tt]
 
everybody, thanks so much.
tsuji,
that was great. it worked just fine. cool. i tested. i can place the content of clipboard in a variable even in a vb script without having i.e. being visible. i can examine the content of the variable and process the info.
my question is this: is there a way to paste this info onto notepad? right now, i process the info, open a text file, and append successive contents to it. i'm just wondering if there is a so called "paste" method in this.
thanks.
 
Always not to consider keyboard emulation unless it is the last resort. You can save s to a text file and open it with a notepad of any editor.
[tt]
dim spath
spath=[green]"d:\test\cb_data.txt"[/green] 'your input

if not isempty(s) then
with createobject("scripting.filesystemobject").opentextfile(spath,2,true)
.write s
.close
end with
end if
'then open the file with notepad or something (add path to notepad if necessary)
wscript.sleep 50
createobject("wscript.shell").run "notepad.exe " & spath
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top