How to get currently selected text from within electron desktop application? - node.js

I am building a desktop application with electron. As a part of its functionality I want to get text that is currently selected, when a particular event fires. This text can be any where - webpage, pdf, sublime etc.
Is there any way I can do this?

For text in the DOM,
you can use:
selectedText = window.getSelection().toString()

Related

How to access the Text-Layer over the canvas in Pdftron

I am working on an application where I am using a third-party PDF viewer PDFtron. I can select the text over the canvas, but once I inspect it, I can't see the text overlay. Only the annotations are there. You can check the demo here.
If I can select the text on this, but it's not actually 'HTML' then how it's rendered on the canvas.
Simply, I am looking for the HTML overlay, which I can access through DOM APIs.
I am wondering if I can somehow enable it?
Texts are rendered on the canvas, so that's why when you inspect you can not see them.
If you want the texts added to the DOM, you can try turn on the Accessibility mode - https://www.pdftron.com/documentation/web/samples/advanced/#accessibility.
And you can also try extract the text - https://www.pdftron.com/documentation/web/guides/extraction/text-extract/. Or get the information on the selected text using events - https://www.pdftron.com/documentation/web/guides/extraction/selected-text/.

Acumatica: Report Design Different When Printed

I noticed that the report's designs preview and printed are different.
I found it that all of the reports are the same.
So I tried to create new test report and notice that background colors are not rendered on print.
How too keep the design when printing?
Design:
+++
Printed:
By default Reports are rendered in HTML mode. As is often the case with HTML, the report as seen in the browser uses a different CSS style then the one sent to the browser print dialog. I'm pretty sure the reason for this is to accommodate printer technology. Printing solid dark backgrounds uses up a lot of ink and text is more legible when it's black text over a white background.
With HTML rendering, browser view and print preview differ to accommodate printer limitations:
HTML was never meant for accurate rendering anyway so I think the CSS change is for the better but if you want exact result just switch to PDF mode which is meant to provide accurate rendering. Print preview should match very closely the PDF rendering in browser when the report is displayed in PDF mode:
It can get tiring to manually switch to PDF each time by clicking the rendering mode button so you can change the default mode in the report configuration:
It is also possible to edit your custom reports or the standard ones so they default to PDF rendering in the browser instead of the current HTML default:
To edit report you will need to install Acumatica Report Designer (it is in Acumatica ERP Windows Installer) and use the EDIT REPORT button and then use Save to Server file menu item in the report designer to save the report modifications:
Have you checked the Background Graphics checkbox in the printing dialog of your printing preview program? It's primarily in the More Settings section.
Please find below example for Google Chrome's dialog:

Capture screenshot of a specific window (macOS)

Is there a way using NodeJS to capture a screenshot of a specific window?
Let's say I have my Chrome app open, and I want the screenshot of just this window, or a screenshot of the desktop (even if there are other windows covering it).
I was looking for some solution but the packages I found (e.g. screenshot-desktop) capture the whole screen, so if a specific window is hidden, there is no way for me to capture it.

Save text from specified tags into text file?

I want to copy text from a particular div class, and save it externally, and then click a button, before repeating the process, to copy the content from an online quiz.
Only, the URL does not change, and the content is updated dynamically. I tried an iFrame so I could simulate button presses with jQuery but the content wouldn't load over it, and I'm not sure I could do so with node.JS because the URL is static.
Any suggestions as to how I could do it, whether it be a Chrome extension or just a program?
Thanks

Program that knows what elements you click on website

I'm trying to create a program where i can select the input boxes on website and list them into a listbox. i can use the C and delphi language but neither of them i can do this. I'm not trying to make a whole new browser, but just want to be able to do this. In a way it is like, when google chrome puts an orange box around the input boxes. it recognizes that it is a box you can type in. How do i recognize with a program what text box i have selected with my mouse? thx :)
You should look into GreaseMonkey for firefox. It allows you to run custom javascript on web sites, allowing you to transform pretty much whatever you want on the page.
https://addons.mozilla.org/en-US/firefox/addon/748/

Resources