AHK copy browser text without activating window - web-scraping

So one way I can do this is for example.
MouseMove, %xpos%, %ypox% (inside browser)
MouseClick, %xpos%, %ypox%
Send ^a
Send ^c
text := Clipboard
msgbox %text%
But I want to get the text without clicking at all! Like UrlDownloadToVar but instead of returning the html I want the text. It has to return the text because the website I am working on is protected and in java and doesn't return proper information by copying the source-code.

Related

itextsharp Callback pdf document while click on print button on generated pdf

Is there any possibility or any builtin function on iTextsharp that while click on print button on pdf generated file the function call from server side? Basically I want to change the status for this file that it is printed or not.
I don't have the reputation to add a comment but:
basically printing is organized from your pdf-browser. So If you hit the print button, itextsharp is not able to detect. A possible Workaround is to trigger the printing process with a button from your document. Combined with a JavaScript you could write a global variable that marked the printing process for this document.
If you want to keep your document sate, you have to safe it after executing the js-script.
Hope it helps.
Since the screenshot you attached is the pdf viewer of the browser, which runs on the client, you have no interaction any more with the server. So, at this point, you can't control what's happening with the pdf. What you can do, it to tell the browser not to open the pdf file, but to print it.
Here are some tutorials: https://www.google.com/search?q=asp.net+print+directly+to+default+printer

Print Friendly Page

So I would like to be able to have a print button for entries in our database so users can print an entry via a print friendly "form".
My thought was to create a separate page, add labels and have those labels pull the relevant information.
I know I can add the open widget information via this code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showPage(app.pages.TestPrint);
But I'm running into a few problems:
I can't get the page to open in a new window. Is this possible?
window.open(app.pages.TestPrint);
Just gives me a blank page. Does the browser lose the widget source once the new window opens?
I can't get the print option (either onClick or onDataLoad) to print JUST the image (or widget). I run
window.print();
And it includes headers + scroll bars. Do I need to be running a client side script instead?
Any help would be appreciated. Thank you!
To get exactly what you'd want you'd have to do a lot of work.
Here is my suggested, simpler answer:
Don't open up a new tab. If you use showPage like you mention, and provide a "back" button on the page to go back to where you were, you'll get pretty much everything you need. If you don't want the back to show up when you print, then you can setVisibility(false) on the button before you print, then print, then setVisibility(true).
I'll give a quick summary of how you could do this with a new tab, but it's pretty involved so I can't go into details without trying it myself. The basic idea, is you want to open the page with a full URL, just like a user was navigating to it.
You can use #TestPrint to indicate which page you want to load. You also need the URL of your application, which as far as I can remember is only available in a server-side script using the Apps Script method: ScriptApp.getService().getUrl(). On top of this, you'll probably need to pass in the key so that your page knows what data to load.
So given this, you need to assemble a url by calling a server script, then appending the key property to it. In the end you want a url something like:
https://www.script.google.com/yourappaddress#TestPage?key=keyOfYourModel.
Then on TestPage you need to read the key, and load data for that key. (You can read the key using google.script.url).
Alternatively, I think there are some tricks you can play by opening a blank window and then writing directly to its DOM, but I've never tried that, and since Apps Script runs inside an iframe I'm not sure if it's possible. If I get a chance I'll play with it and update this answer, but for your own reference you could look here: create html page and print to new tab in javascript
I'm imagining something like that, except that your page an write it's html content. Something like:
var winPrint = window.open('', '_blank', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0');
winPrint.document.write(app.pages.TestPage.getElement().innerHTML);
winPrint.document.close();
winPrint.focus();
winPrint.print();
winPrint.close();
Hope one of those three options helps :)
So here is what I ended up doing. It isn't elegant, but it works.
I added a Print Button to a Page Fragment that pops up when a user edits a database entry.
Database Edit Button code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showDialog(app.pageFragments.FragmentName);
That Print Button goes to a different (full) Page and closes the Fragment.
Print Button Code:
app.datasources.ModelName.selectKey(widget.datasource.item._key);
app.showPage(app.pages.ModelName_Print);
app.closeDialog();
I made sure to make the new Print Page was small enough so that Chrome fits it properly into a 8.5 x 11" page (728x975).
I then created a Panel that fills the page and populated the page with Labels
#datasource.item.FieldName
I then put the following into the onDataLoad for the Panel
window.print();
So now when the user presses the Print Button in the Fragment they are taken to this new page and after the data loads they automatically get a print dialog.
The only downside is that after printing the user has to use a back button I added to return to the database page.
1.
As far as I know, you cannot combine window.open with app.pages.*, because
window.open would require url parameter at least, while app.pages.* is essentially an internal routing mechanism provided by App Maker, and it returns page object back, suitable for for switching between pages, or opening dialogs.
2.
You would probably need to style your page first, so like it includes things you would like to have printed out. To do so please use #media print
ex: We have a button on the page and would like to hide it from print page
#media print {
.app-NewPage-Button1 {
display : none;
}
}
Hope it helps.
1. Here is how it is done, in a pop up window, without messing up the current page (client script):
function print(widget, title){
var content=widget.getElement().innerHTML;
var win = window.open('', 'printWindow', 'height=600,width=800');
win.document.write('<head><title>'+title+'/title></head>');
win.document.write('<body>'+content+'</body>');
win.document.close();
win.focus();
win.print();
win.close();
}
and the onclick handler for the button is:
print(widget.root.descendants.PageFragment1, 'test');
In this example, PageFragment1 is a page fragment on the current page, hidden by adding a style with namehidden with definition .hidden{display:none;} (this is different than visible which in App Maker seems to remove the item from the DOM). Works perfectly...
2. You cannot open pages from the app in another tab. In principle something like this would do it:
var w=window.parent.parent;
w.open(w.location.protocol+'//'+w.location.host+w.location.pathname+'#PrintPage', '_blank');
But since the app is running in frame nested two deep from the launching page, and with a different origin, you will not be able to access the url that you need (the above code results in a cross origin frame access error). So you would have to hard code the URL, which changes at deployment, so it gets ugly very fast. Not that you want to anyway, the load time of an app should discourage you from wanting to do that anyway.

Is it possible to read data from the text browser of QT GUI

i'm trying to make a chat application in QT . Is it possible to read data from the text browser of QT GUI(which shows conversations) so that i can maintain a chat history...?plz help..Thank You
The QTextBrowser inherits QTextEdit, which works on a QTextDocument. The QTextDocument can be converted to (and saved as) HTML using QTextDocument::toHtml():
QTextDocument *doc = ui->textBrowser->document();
QString html = doc->toHtml();
I advise you to append to a log file every time a new message comes in / goes out, so update the QTextBrowser and the file "in parallel", and not saving the entire chat history everytime a new message appears.
To do so, open the log file and manually write the open <html> and <body> tags without closing them. Then append the chat log entries on the still opened file. On application exit (object destruction of the chat window or whatever), close the </body> and </html> tags and afterwards the file itself. This will result in a much better performance than saving the whole file for every change of the QTextBrowser widget.
with something like that:
QString myQString = <textBrowserObject>.toPlainText();

How to Print a Web Browser Response that's different from HTML?

Enviroment: ASP.NET Framework 2.0
Is it possible to accomplish something like this:
I have this link <a href='printBarcode.aspx?code=HF54A'>Print Bar-code</a> and I want to print the response that the server sends for that link. Is that even possible? The response is text but it's not HTML, is some text that a special printer recognizes for printing bar-codes.
The idea is this: the user clicks on the link then the browser receives the response for that link and prompts to print it's content.
I'm happy to receive all suggestions and comments if you think you know of a better way to do this.
No, a browser has no functions for printing anything other than the content of a window. You can't take a response that is returned and send directly to a printer, the closest possible is to display the response in an iframe and ask for a printout of the iframe content. If the browser doesn't know how to visualize and print the response, you can't use the printing capability in the browser to print it.
If you want to send the response directly to a printer, you would have to run a component (flash/silverlight/Java) in the browser that could access the printer directly.
You could put the text from the response into a [div id="textToPrint"] and call a javascript print(). If you can use a popup to open the link [a href='printBarcode.aspx?code=HF54A'] you can have a poopup page like:
[html]
[body onLoad="print();"]
[div id="textToPrint"] YOUR TEXT FROM RESPONSE [/div]
[/body]
[/html]
in this case the printer will print only your text...
You could return a page that is just the barcode text and auto popup the print dialog.
<script type="text/javascript">
window.print();
</script>
But I don't think this will work. I assume the browser will not send it to the printer in the correct format.
The problem is ASP.NET can't access a local printer in the server side code. To do some custom printing you would probably have to rely on Flash or Silverlight, if a plain print of the page doesn't work.

Close pop up window after binary file is sent to browser

Is there a way to close a pop up window after the page writes binary data (PDF) to the browswer?
Here are the details:
Whenever my web appilcation needs to print, it will pass some parameters over to a pop up window, which will display the print options. When the user clicks on the Print button, it will set the src of a iframe that will call the page that does the printing.
I have PDFConverter to convert URL / HTML to a pdf file. At the end of the converting, it will write the binary to the browser. Here are some code:
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition",
"inline; filename=" + fileName + ".pdf; size=" + pdfBytes.Length.ToString());
response.Flush();
response.BinaryWrite(pdfBytes);
response.Flush();
After this is done, i will need to close the pop up window. However it seems like you can't do anything after the response is flushed. Any ideas?
Thanks in advance!
Angela
Instead of creating the iframe in the popup window, you could create it in the parent window. This way once the user clicks the print button, you could safely close the popup without interupting the printing process. But instead of going through all the pain of creating new popups windows which might be blocked by some browsers, I would simply create some placeholder in the main page so that the user could choose printing options and then print the document.
Just in case anyone else is having the same problem. This is the solution that seems to work for me.
I use the jQuery Simple Modal to show my option list page. On this page, I have a window timer running every 1 second to check against the server if the print job is done. I use ajax for that. Once the job is done, I update the session variable, and the ajax call to the server will pick up the session value and close the pop up window.

Resources