APL calls Windows .NET to generate Display Capture

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

APL calls Windows .NET to generate Display Capture

Postby woody on Wed Jan 06, 2021 6:55 pm

Greetings.

Is there already a utility or tool that can be called from Dyalog APL to generate a Windows screen capture?

I see that MS Windows 10 has an API to do this ...
but requires some .NET coding and deeper understanding of Windows Threads.

I have an APL application developed that is tightly integrated with EXCEL. APL updates EXCEL with some data, and EXCEL draws some charts.

I'd like APL to then invoke a Windows Screen Capture ...
best if I could specify the display X1, X2 and Y1, Y2 coordinates for the capture.
(Or the EXCEL object name for the target chart)

The captured image would then be SAVED to a Windows file in a target folder path.

Thoughts?

https://docs.microsoft.com/en-us/window ... en-capture

Thanks!

//W
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 142
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA

Re: APL calls Windows .NET to generate Display Capture

Postby RichardP|Dyalog on Thu Jan 07, 2021 9:52 am

If by "tightly integrated" you mean using OLE to communicate, then you can export the charts as images directly from Excel. This will be both less fiddly than taking screenshots, and also probably allow you better control of the image resolution.

Had a look just now and after some teething pains managed to export a chart directly from Excel via OLE using:

Code: Select all
(XL.Workbooks[1].Sheets[1].ChartObjects ⍬)[1].Activate
XL.ActiveChart.Export⊂('c:\d\tmp\MyChart.jpg')


All the Chart object properties and methods are documented here:
https://docs.microsoft.com/en-us/office ... art(object)
although it is a bit of a task deciphering the VB/VBA/C# examples for APL (e.g. https://docs.microsoft.com/en-us/office ... art.export)
RichardP|Dyalog
 
Posts: 12
Joined: Fri Oct 12, 2018 3:05 pm

Re: APL calls Windows .NET to generate Display Capture

Postby ray on Thu Jan 07, 2021 4:43 pm

I am not sure if function I wrote many years ago would help:

Code: Select all
 PrintScreen;keybd_event;ke;cl;bm
⍝ Copies the ACTIVE window to the clipboard

⍝An application can simulate a press of the PRINTSCREEN key in order
⍝to obtain a screen snapshot and save it to the clipboard.
⍝To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT,
⍝and the bScan parameter set to 0 for a snapshot of the full screen
⍝or set bScan to 1 for a snapshot of the active window.

⍝ VOID keybd_event(
⍝  BYTE bVk,           // virtual-key code
⍝  BYTE bScan,         // hardware scan code
⍝  DWORD dwFlags,      // flags specifying various function options
⍝  DWORD dwExtraInfo   // additional data associated with keystroke
⍝);

⍝ VK_SNAPSHOT 2C PRINT SCREEN key

 'ke'⎕NA'user32.C32|keybd_event I1 I1 I4 I4'
 ke 44 1 0 0


I am unable to test this code at the moment as on my PC, the "PrintScreen" button now activates "LightShot".
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 192
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: APL calls Windows .NET to generate Display Capture

Postby woody on Sat Jan 09, 2021 5:20 am

Thanks, Richard and Ray !

I'll give the EXCEL code a try.
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 142
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest