Skip to main content
karit66557003
Participant
Feb 10, 2018 6:35 PM UTC
Question

Programmatically Copying a Screenshot to the Clipboard

When extending the functionality of Microsoft Word and Excel, one can program with Visual Basic (VBA) to do some clever things.  I had created a small VBA function to take a screenshot. It works well when called from Excel. And when I save it as a local .VBS file and double-click it from my desktop, it works fine.

I would like to do the same thing from Captivate.

Here's a sample of the VBS code:

Sub TakeScreenShot()

   With CreateObject("Word.Basic")
       .SendKeys "{prtsc}"
   End With

    WScript.Sleep 1000
End Sub
   

Call TakeScreenShot

I have two separate problems:

  • From Captivate (On Success)
    • When I have an object (Click Box or SmartShape used as a button) and then On Success to Open URL or File, the .VBS file generates two separate banners in the browser, neither of which are desired.
      • Do you want to open or save [filename.vbs] (460 bytes) from (location) > with Open, Save, and Cancel.
        • I click Open (and it leads to the next warning).
      • The publisher of [filename.vbs] couldn't be verified. Are you sure you want to run the program > with Open and View Downloads
        • I click Open (and it copied the screen as a graphic into the clipboard)
  • From Captivate (JavaScript)
    • I would think there is a way to translate the code above into a similar JavaScript formatted syntax to accomplish the same thing; however, I've not been able to do that as of yet.

Questions:

  • Would you be able to guide me in how to fashion the VBS into the JavaScript syntax that Captivate would require?
  • Do you have a method/means (or code) that would enable a full screenshot being copied to the clipboard?

Thanks, in advance.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    Eric Dumas
    Community Expert
    Community Expert
    Feb 13, 2018 9:23 AM UTC

    Hi,

    that makes sense. In the past, I used a script that would save a 'certificate of completion' (quiz result slide) as an image by 'printing' a pdf or saving a windows bmp (not great).

    If I find the script again I will post here

    Translate
    karit66557003
    Participant
    Jul 4, 2018 6:11 PM UTC

    Hope you're enjoying the holiday and not worrying about issues/requests.

    That said, any update on this?

    Translate
    Eric Dumas
    Community Expert
    Community Expert
    Feb 10, 2018 8:40 PM UTC

    Hi,

    That is an interesting challenge.

    Can you describe what you want to achieve? without using the technical VB description.

    for example: when the learner does X, a screenshot is captured, then Y happens. I think you might overcomplicate things and we can have a workaround to achieve your goal.

    Translate
    karit66557003
    Participant
    Feb 10, 2018 11:52 PM UTC

    I would like to have a button, that when clicked, would take a copy of the screen just as it is.  (This would be similar to pressing WIN+PrnScr). Nothing else happens.

    The only difference at this point is that the user obtained the screen copy by a clicking an object rather than having to remember a keyboard combination.

    From here, I would like to extend it so that the graphical image in the Clipboard can either be:

    a) pasted in an email

    b) pasted into a file & saved

    For now, baby steps. If I can achieve a screen shot into the clipboard with a click of an object (instead of keystrokes), that would be a great start.

    Translate