Screenshot of an active Window in Progress-4GL - progress-4gl

I am working In Progress 4GL , in my application i wish to take a screeenshot of an active window on any KeyStroke Event such as (CTRL + F9) and save the same in a prespecified folder. Can anyone Help me in this ?

As mentioned in the comments this can be done by calling .NET from Progress ABL. Here's an example that takes a screenshot of the entire screen. You will need to adapt this to your needs.
USING System.Drawing.*.
USING System.Drawing.Imaging.*.
USING System.Windows.Forms.Screen.
DEFINE VARIABLE bmpScreenshot AS Bitmap NO-UNDO.
DEFINE VARIABLE gfxScreenshot AS Graphics NO-UNDO.
bmpScreenshot = NEW Bitmap(Screen:PrimaryScreen:Bounds:Width,
Screen:PrimaryScreen:Bounds:Height,
PixelFormat:Format32bppArgb).
gfxScreenshot = Graphics:FromImage(bmpScreenshot).
gfxScreenshot:CopyFromScreen(Screen:PrimaryScreen:Bounds:X,
Screen:PrimaryScreen:Bounds:Y,
0,
0,
Screen:PrimaryScreen:Bounds:Size,
CopyPixelOperation:SourceCopy).
/* Use ImageFormat:[Png|Gif|Bmp|Tiff] etc for different image formats */
bmpScreenshot:SAVE("c:\temp\Screenshot.png", ImageFormat:Png).
This is a C# to ABL translation of this question on SO.

Related

how to edit simulink plutosdr qpsk example

I am working with this example from MathWorks: https://www.mathworks.com/help/supportpkg/plutoradio/examples/qpsk-transmitter-with-adalm-pluto-radio-1.html
When i run the example it creates an sdrqpsktx variable in the matlab workspace
I want to change sdrqpsktx.MessageBits to something smaller.
When i run the following code in matlab:
a = sdrqpsktx.MessageBits(1:448);
sdrqpsktx.MessageBits = a;
I successfully change sdrqpsktx.MessageBits to a.
However when i run this in simulink sdrqpsktx.MessageBits changes back to its original size.
How do i permanently change sdrqpsktx.MessageBits and run the example with my changes?
Thank you.
There is a model callback, probably a StartFcn, that is overwriting your changes to the variable every time you start the simulation. You either need to delete or modify that code.
To see the code go to:
File->Model Properties->Model Properties, and select the Callback tab.
Any callback that is followed by a * has code in it. Click on that callback to see the code.
See Callbacks for Customized Models for more detailed information.

Qt Save form take 3-4 second to open

i'm using this on push button click in Qt:
QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"),
QString(),
tr("(*.csv));
it take 3-4 second to open the save Form. why? how i can improve speed?
Try to connect this slot to a QPushButton:
void MainWindow::openFD(){
QTime myopentime=QTime::currentTime();
for (int i=0;i<1000000;i++) ;//comment out this line for the real test
QString fileName = QFileDialog::getSaveFileName(this,QString(),QString(myopentime.toString("m.s.zzz")+" "+QTime::currentTime().toString("m.s.zzz"))
,tr("*.csv") );
}
Then try to run it with and without the count part.
You will see, that the count part adds some ms... without it there is not even ms (mili-second) of difference in the time shown in filename place.
So, you have to search somewhere else in your code or give us a better example.
PS:
1) You will need :
#include <QTime>
2) The line that counting is there to show you that my method works (since you will see some difference when uncomment)
Result and Answer: The problem is not on QFileDialog if this test will not give you differences but somewhere else in your code or possibly in the Window manager of your OS.

I want to know about where "c" file generate after making GUI in Glide

i am using GTK3.0 library and Glade tool to build GUI using "c". can anyone tell me that after making GUI in Glade where actually "c" file generate.??
Glade doesn't generate code anymore. Old versions did, but the resulting code was unmaintable as you needed to edit the code generated, making it hard to change the UI afterwards.
Nowaday, you just use the GtkBuilder class to load the GUI description, as stated in the documentation.
/* Construct a GtkBuilder instance and load our UI description */
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "builder.ui", NULL);
/* Connect signal handlers to the constructed widgets. */
window = gtk_builder_get_object (builder, "window");
Source: https://developer.gnome.org/gtk3/stable/ch01s03.html (official documentation)

Gate vs toggle clip launch in Max4Live patch

I hope someone is able to help me with this.
Ableton Live when you set a clip's launch mode to gate, it only plays when you hold down the key. I'm using a patch that takes an OSC message to launch the clip, but it will not work as a gate - it needs to have the stop all clips message, and this won't help in my situation.
I need to "call fire" when 1 and "call stop all clips" when 0, but I'm not sure how to do this.
Can anyone help me with which object I should use? I've looked at various gates and swtiches, but I'm missing something.
Thanks.
Create a new object and type "togedge" or "select" (or its shorthand "sel"). Both of them will have 2 outputs: One for 0, one for not 0.
"togedge" will only output if the input changes.
"sel" will always output, and you can enter different numbers to match your input directly (like "sel 34 56").
Btw you can also use "call stop" on the clip_slot object directly instead of "stop_all_clips" on the track object.
After fiddling with the sel object, I discovered this: I needed to change the live.text object used to launch the clip from button to toggle.

How to change active application in progress?

In Progress 11.3.2 (Developer Studio 3.7 - Eclipse 3.8.2), not using dot net at all:
How do you switch the focus to another window/application/w file?
In windows 7/8 the order of what window that is focused acts a bit different than before and does not always show the window you want to have over all the other apps.
If you have 3 windows open, and close the 3rd one and want to focus on the second one that was minimized, the first one get focus instead.
You set it to normal with WINDOW-STATE = WINDOW-NORMAL. But how to focus on it too?
If you run the secondary windows persistent you can do something like this:
In calling window:
/* In definitions */
DEFINE VARIABLE ghSecondWindow AS HANDLE NO-UNDO.
/* In a trigger */
RUN secondWindow.w PERSISTENT SET ghSecondWindow.
/* Whenever you want to shift focus */
RUN setFocus IN ghSecondWindow.
In "SecondWindow":
PROCEDURE setFocus:
/* Replace FILL-IN-1 with any widget that can gain focus */
APPLY "ENTRY" TO FILL-IN-1 IN FRAME {&FRAME-NAME}.
END PROCEDURE.
If however you are not running persistent windows you can still achieve this by walking the widget trees, first of the current window and then of the second window (once you've localized it).
Quick and ugly code to put in the calling window wherever you want the focus to shift. This might not suit your needs exactly so it might require some rewriting. Also error checking is pretty much not here and dealing with possible eternal loops without error checking is not really best practice:
DEFINE VARIABLE hWin AS HANDLE NO-UNDO.
DEFINE VARIABLE hWidget AS HANDLE NO-UNDO.
/* Get the first child (widget) of the session */
ASSIGN
hWin = SESSION:FIRST-CHILD.
/* Loop through all widgets in the session */
loop:
DO WHILE VALID-HANDLE(hWin):
/* We've identified the correct Window! */
IF hWin:TYPE = "WINDOW" AND hWin:TITLE = "Secondary Window" THEN DO:
/* ** Very Ugly** this could use better error checking etc! */
/* Get the second field-group of the window */
/* This will depend on your layout with different frames etc */
/* What we really have is WINDOW:DEFAULT-FRAME:FIELD-GROUP:FIELD-GROUP */
/* Field groups are really only present in the widget tree - they lack visual */
/* representation */
/* Read about field-groups in the online help! */
ASSIGN
hWidget = hWin:FIRST-CHILD:FIRST-CHILD:FIRST-CHILD.
/* Loop through all widgets of the field-group */
DO WHILE VALID-HANDLE(hWidget).
/* We've found the correct fill-in, give it focus */
IF hWidget:TYPE = "FILL-IN" AND hWidget:LABEL = "Fill 1" THEN DO:
APPLY "ENTRY" TO hWidget.
LEAVE loop.
END.
/* Next window of the correct window */
hWidget = hWidget:NEXT-SIBLING.
END.
END.
/* Next widget of the session */
hWin = hWin:NEXT-SIBLING.
END.
You could also do the "widget tree walk" recursively if you feel like it!