Skip to main content

W$BITMAP and opcode WBITMAP-CAPTURE-IMAGE, a great tool for technical support

  • February 4, 2011
  • 6 replies
  • 0 views

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.

6 replies

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.
Gisle,

I put the following line in my code: SET ENVIRONMENT "KEYSTROKE" TO "HOT-KEY=SupportScreen ^P"

This did not seem to work, shouldn't it be the same as having it in a config file? I copied your code over and compiled SupportScreen with out errors. I pressed Ctrl-P and nothing happened.

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.
On follow up to my previous post, I put it in my config file as well and still did not see anything happen when I pressed Ctrl-P.

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.
Never mind, I found the problem. One of the other programs that was being called remapped the Ctrl-P for a print function. Once I re-compiled that, it worked just fine. This will be a very useful tool. The only issue that I see is that the area where the "OPENSAVE" box comes up is blanked out. If that happens to be where the error message or strange data is at, then we wouldn't be able to see it. I'll have to play with this some to see if I can get rid of that issue.

Thanks for your input over the years, it has been very helpful.

Steven

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.
Hi Steven

glad to hear you find the example useful.

Interesting to hear that you get a copy of the dialog. May I suggest you do an ACCEPT OMITTED BEFORE TIME 0 prior to the call to the w$bitmap, that should ensure the screen is updated.

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.
Cheesle originally wrote:
Hi Steven

glad to hear you find the example useful.

Interesting to hear that you get a copy of the dialog. May I suggest you do an ACCEPT OMITTED BEFORE TIME 0 prior to the call to the w$bitmap, that should ensure the screen is updated.


Actually, what I got working was essentially the same thing. I put CALL "C$SLEEP" USING "1" before the W$BITMAP call and that took care of the problem. I noticed that it only catches the currently active screen, plus it will not work if you have a display message box up.

[Migrated content. Thread originally posted on 19 January 2011]

Most of us working with software have often had the desire to see what the customer see. Granted, there are many alternatives for remote desktop today, but then there is the issue about having the same type of tool and the always problematic firewalls.

One easy way around this, may be the image capture feature of the library function W$BITMAP. Add the HOT-KEY feature and you would promptly have a nice tool to improve support.

Assume you have application Cool, and you have a configuration file for this application. To this application add the following line:

KEYSTROKE HOT-KEY=SupportScreen ^P

What this does, is to tell the runtime that whenever a Ctrl P is pressed by the user, invoke the program SupportScreen. If you already use the Ctrl P for something, you are free to select any other key as hot key. Look up the documentation on configuring your terminal for other keystrokes.

The program SupportScreen, looks like this:

IDENTIFICATION               DIVISION.
PROGRAM-ID. SupportScreen.
| Copyright (c) 2011 by Micro Focus.  Users of Extend
| may freely modify and redistribute this program.
       WORKING-STORAGE SECTION.
    77  OPENSAVE-STATUS          PIC S99.
        88  OPENSAVE-OK          VALUE 1.
COPY "ACUGUI.DEF".
COPY "OPENSAVE.DEF".
PROCEDURE DIVISION.
MAIN-LOGIC.
    INITIALIZE               OPENSAVE-DATA
    MOVE    "Bitmap files (*.bmp)" TO OPNSAV-FILTERS
    MOVE    "bmp"            TO OPNSAV-DEFAULT-EXT
    MOVE    OPENSAVE-PATHMUSTEXIST TO OPNSAV-FLAGS
    CALL    "C$OPENSAVEBOX"  USING
        OPENSAVE-SAVE-BOX
        OPENSAVE-DATA
        GIVING           OPENSAVE-STATUS
    IF      OPENSAVE-OK
         | Capture the active window, client area only, 8 bit colors:
         CALL "W$BITMAP" USING WBITMAP-CAPTURE-IMAGE
            OPNSAV-FILENAME 0 1 8
            GIVING OPENSAVE-STATUS
                   IF OPENSAVE-STATUS > 0
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Capture successfull"
                TYPE 1
                ICON 1
              ELSE
              DISPLAY MESSAGE BOX
                OPNSAV-FILENAME
                TITLE "Error storing image"
                TYPE 1
                ICON 3
            END-IF
        END-IF
    GOBACK
    .


Now, compile this program and add it to your application suite, note the dependency on the standard copybooks acugui.def and opnsave.def. They should be available in the def subdirectory of your Extend installation.

Make sure the new entry is in the configuration file and run the cool application. Press Ctrl P anywhere and a file save dialog should appear. Select a directory and a name and press OK.

A snapshot of your application should now be found in the directory of your choice and at the name you selected.
Obviously, we need to get the image to us, don’t we? Well, that is another story :-).

Note the limitation of OPNSAV-FILENAME, the full path of a filename may not be longer than 256 bytes.
You can specify alternate targets for what you want to capture. This example just captures the window that has focus. Which is why I suggested doing the accept omitted to ensure we had the right focus.

Look at the documentation of the w$bitmap function to see how you can alter your printscreen targets from only the particular entry field and all the way to a full screen dump.