Book a Demo

Author Topic: Is it possible to access Clipboard from a script? [SOLVED]  (Read 7558 times)

Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 344
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Is it possible to access Clipboard from a script? [SOLVED]
« on: June 28, 2018, 08:05:42 am »
I need to access to the data in the clipboard in a Jscript in the model. Is this possible?
« Last Edit: March 14, 2019, 02:50:25 am by Arquesoft »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Is it possible to access Clipboard from a script?
« Reply #1 on: June 28, 2018, 09:54:06 am »
No way that I know of to access the clipboard from scripting languages. I think you'd need to write your program in a more full featured language such as C#.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Is it possible to access Clipboard from a script?
« Reply #2 on: June 28, 2018, 02:00:14 pm »
There are actually a number of ways (or workarounds) to get access to the clipboard.

Here's a few of them: https://stackoverflow.com/questions/19696308/how-can-i-use-clipboard-in-vbscript

Geert

Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 344
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Re: Is it possible to access Clipboard from a script?
« Reply #3 on: March 14, 2019, 02:50:08 am »
The solution:
Create a VBscript with this:

Code: [Select]
sub ClipBoard(input)
'@description: A quick way to set and get your clipboard.
'@author: Jeremy England (SimplyCoded)
  If IsNull(input) Then
    ClipBoard = CreateObject("HTMLFile").parentWindow.clipboardData.getData("Text")
    If IsNull(ClipBoard) Then ClipBoard = ""
  Else
    CreateObject("WScript.Shell").Run _
      "mshta.exe javascript:eval(""document.parentWindow.clipboardData.setData('text','" _
      & Replace(Replace(Replace(input, "'", "\\u0027"), """","\\u0022"),Chr(13),"\\r\\n") & "');window.close()"")", _
      0,True
  End If
End sub

Then create your own vbscript including the previous one and use the ClipBoard function to put the text in the clipboard.