This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Taking screen shots with Extra Basic vs VBS

I have an Extra! Basic macro that calls a VB script to take a screenshot.  I would prefer to have all functions contained in the macro and not make outside calls to a VB script.  The first two billets below are how it currently functions and the third is my failed attempted to eliminate the additional file. How can I embed VBS code into Extra Basic, or better yet, is there a more efficient way to take a screen shot within Extra Basic? I know screen shots are not the best way to grab data but that’s what has been requested of me.

  • Extra Basic call: 

    Call Shell("Explorer.exe ""c:\screenShot.vbs") 

  • screenShot.vbs:

                 Set Wshshell=CreateObject("Word.Basic")
                WshShell.AppActivate "AppName"
                WshShell.sendkeys"%{prtsc}"
                set WshShell = CreateObject("WScript.Shell")
                WshShell.SendKeys "{NUMLOCK}"

  • Failed embedding attempt:

            Call Shell("Explorer.exe ""Set Wshshell=CreateObject('Word.Basic')")
            Call Shell("Explorer.exe ""WshShell.AppActivate 'AppName'")
            Call Shell("Explorer.exe ""WshShell.sendkeys'%{prtsc}'")
            Call Shell("Explorer.exe ""set WshShell = CreateObject('WScript.Shell') ")
            Call Shell("Explorer.exe ""WshShell.SendKeys '{NUMLOCK}'")

NOTE: The numlock was only added because the vbs kept turning it off after executing.

Labels:

Mainframe Access
  • Verified Answer

    +1

    I've made some progress, the following code will take a screenshot when executed in a Extra! Basic macro.  Unfortunately its not the most responsive, so if I jump to another app too soon it screenshots the wrong item.  Any recommendations on improving this or a more efficient way to accomplish a screenshot using Extra! Basic? 

    With CreateObject("Word.Basic")
             .AppActivate "MyApp"
             .SendKeys "%{prtsc}"
             .SendKeys "{NUMLOCK}"
    End With

  • Verified Answer

    +1  

    Hi Dave, 

    I don't have a <scroll lock> so I don't know if the following macro will toggle it. But if it does we can always figure that out.

    Declare Sub keybd_event Lib "user32" (ByVal bVk As Integer, ByVal bScan As Integer, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

    Const KEYEVENTF_KEYUP = &H2
    Const VK_SNAPSHOT = &H2C
    Const VK_MENU = &H12

    Sub Main
        Dim myShell as Object
        Dim myTitleBarText as String
        myTitlebarText =  "Untitled - Notepad"
        Set myShell = CreateObject("WScript.Shell")
        myShell.appactivate myTitlebarText

        keybd_event VK_MENU, 0, 0, 0
        keybd_event VK_SNAPSHOT, 0, 0, 0
        keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
        keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
    End Sub


    Question what are you doing with the screenshot after you put it in the clipboard?

    Tom

  • 0 in reply to   

    Hi Tom,

        I’m just getting off my rest days and will be working night shift Friday.   When I have some down time at work I’ll, give this code a try and play around with it.  I’ll let you know how it works for me.  As for the screen shots, they post them to typical things like word and outlook.   Personally I’d rather send as text but management wants screen shots.  

    thanks,

    David

  • 0 in reply to   

    Tom,

       That was perfect, took a screen shoot with zero lag time.

    Thank you,

    David