Help with looping macro.

WIN10 LO6.4 HSQL2.51

Hi all,

I would like to automate a series of screen dumps using a tool like Gadwin Print Screen which allows silent image capture with auto save in a predetermined folder as a workaround for subreports.

In order to achieve that looking at the attached image I think I need to do the following in pseudo-code:

get/select the first Itinerary Item, then
fake the press of the print screen button
wait a little(couple of seconds maybe for the dump to occur)
move to the next Itinerary Item
and loop in this fashion to the end of the record set
and perhaps conclude with a message…Ticket Itinerary Dump Complete

So the questions are how do I loop through a secondary table control and how to I fake the key press or are there other ways to accomplish this ?

Thanks for your thoughts.


It appears to me you are outside of LibreOffice with this. You are talking of the Print Screen button witch is based upon the operating system in use.

Possible code in Python. See this post for a small glimpse into the task → Area selection and capture of the screen with Python on Windows

Here is another → Automatically Save Screenshots in Windows With a Python Script

It is certain there are more but this will give you some idea of the task.

@Ratslinger, thanks you for the links, will check them out.

@ Ratslinger - On second thoughts the code found in
Create a macro that press "Enter" automatic once executes the carriage return ASCII(13) which appears to be identical for Windows and Ubuntu.

So I am somehow inclined to think that other ASCII codes should work in the same fashion, but I may be wrong because…

Alas you may be right the Print Screen button being a different animal as I dont seem to be able to find a corresponding code in any of the ASCII listings searched so far.

So if there is an ASCII for PrintScreen and that being a big IF the screen capture prog would accept ASCII, then it would just be a matter of looping and calling the fake key press macro recursively as the generation of the image and saving is handled by the external prog returning control to the macro on termination.

Anyway, the feature is not that important, .the same being accomplished via pressing Printscreen and down arrow in succession.


The link you provided is for elements within LO. Have used that many times. What you are asking for is to deal with elements outside of LO. You need to interact with the OS to deal with another piece of software.

The looping is no problem but the the main portion is outside this site.

@Ratsinger, thanks, will put this on the backburner for now as it is not practical to introduce another dependency.