LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

screen capture durin run time.

hello everyone,

 

ill be short and i hope someone will know how to help me.

 

I have an application, in wich in its end, i want to make a screen capture after hiding the main panel.

Meanning i dont need the panel`s capture, but the windows and whatever programs are working at that time.

Plus i need the screen capture photo in a bitmap/jpg/atc. file.

 

thanks in advance,

Adi.

 

0 Kudos
Message 1 of 8
(4,832 Views)

Hello, you could use GetPanelDisplayBitmap and SaveBitmapToPngFile (or to other file format like jpg: look at available functions in the help)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 8
(4,826 Views)

Just reading your post better and my answer is not what you are looking for.

 

Take a look at this thread and at NickB code in this other one



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 8
(4,824 Views)

Not sure i can use these previos posts...

hope i just didnt miss understand it.

 

I need the screen capture to happend by it self.

 

The operator presses a command botton that generats few thing, then hides the panel - and only then takes the screen shot...

I dont want the operator to be involved in the capture process.

 

But i do need it in a file.

thanks.

0 Kudos
Message 4 of 8
(4,812 Views)

i just need hiding the panel 

and saving a screen capture

 

there is my spesific code :

...

HidePanel (panelHandle);

keybd_event(0x2C, 0, 0, 0);
ClipboardGetBitmap (&image, NULL);
SaveBitmapToJPEGFile (image, machinestr3, 0, 100);

QuitUserInterface (0);

...

I keep getting things I dont understand why they happen.

first one after saving my code and running:

NON-FATAL RUN-TIME ERROR: "NewScap.c", line 449, col 17, thread id 0x0000255C: Library function error (return value == -127 [0xffffff81]). Bitmap is invalid

then when i press again on run - it runs perfect the first time,

then when i run again and again I keep getting the screen capture of time I pressed the first time.

 

plz help i am a bit frustrated.

tnx Adi.

 

0 Kudos
Message 5 of 8
(4,797 Views)

I have problems myself with this function, even though different from yours. In my case it keeps saving simply the previous image pasted to the clipboard: that is, if I execute the function at 9:00:00 it saves the screenshot taken e.g. at 8:58:00; next time it will save screenshot taken at 9:00:00 and so on.

I supposed I am simply too fast in saving the image: in effect adding a small delay corrected the problem.

The complete function, with error trapping added, is the following:

 

int		avail, bitmap = 0, error = 0;
char	msg[512];

// ... other code here

keybd_event (VK_SNAPSHOT, 0, 0, 0);
DelayWithEventProcessing (1.0);  // Delay added
ClipboardGetBitmap (&bitmap, &avail);
if (!avail)
    MessagePopup ("Warning", "No bitmap available in the clipboard!");
else
    error = SaveBitmapToPNGFile (bitmap, "c:\\temp\\bitmap.png");

// Clearing resources and error warning
if (bitmap) DiscardBitmap (bitmap);
if (error < 0) {
    sprintf (msg, "Error %d found:\n%s", error, GetGeneralErrorString (error));
    MessagePopup ("Warning", msg);
}

 

Check your situation and see if this workaround can fix your problems too.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 8
(4,779 Views)

THANK YOU VERY MUCH !!! Smiley Happy

 

And the part i needed the most is indeed the delay function....

It solved 3 problems i had.

(i am writing it so if more ppl would get in trouble with it)

 

1.At initial run it couldnt find the bitmap, and the application kept crushing down, i guess its like u wrote - that was too fast.

2.The image i got was of previos run not corrent run.

3.The images were saved with the application`s panel in it.

 

here is the code I finaly used :

 

//...........rest of code

 

HidePanel (panelHandle);
DelayWithEventProcessing (1.0);
keybd_event(VK_SNAPSHOT, 0, 0x0001, 0);
DelayWithEventProcessing (1.0);
ClipboardGetBitmap (&image, NULL);
SaveBitmapToJPEGFile (image, "IMAGE_NAME", 0, 100);

 

//...........rest of code

 

{ill take the error traping to another place in my code 🙂 }

 

Thank you very much Mr. Bozzolo.

I hope this post would help more ppl.

Adi.

0 Kudos
Message 7 of 8
(4,770 Views)

Good to know you've solved your problem Smiley Happy

 

Another hint I can give you: if the panel has elementos with a transparent background (labels, pictures and so on) you will receive errors in SaveBitmapToJPEGFile since jpg format cannot handle transparency: in this case you can use png format and the corresponding SaveBitmapToPNGFile.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 8 of 8
(4,767 Views)