How can we close the opened Url through program? - qt

I am using QDesktopServices::openUrl(url); to open a url.
How can I close that through user defined code?

You are opening your URL in a browser window, on which user code doesn't have any control.
So basically you cannot close the browser.
A workaround could be that you write a script and detect if a browser is opened on the system, if yes you can close the browser by terminating that process. But I do not recommend this method as it has many security and standard compliance issues on some platforms.
EDIT:
You do not need to create your own browser, just use Qt Webkit to render the opened URL within your own window.

I'm afraid I don't believe you can close a URL via Qt code, with QDesktopServices.
The user could have configured their operating system to open URLs with any number of different browsers, and I don't see how it would be practical for Qt to be coded to know how to close every different type of browser porgramatically, on every different platform they support.
Edit
An alternative is to put a browser widget into your application. Then you'll have control over that. Qt provides some pretty powerful tools for is. See the Qt WebKit documentation.

Related

Qt: How receive keyboard events when my application doesn't have focus in Qt5 specifically?

I have the exact same problem of this post: I want to make a software which, once executed, will monitor for a specific key event (press of F12) and will do something (do repeated mouse clicks: an auto clicker). But I'ld like, if possible, to use Qt himself to do the trick instead of calling Windows's functions (especially because it may well be eventually used in Linux, so a cross-platform solution is desired)
Well my problem isn't anything new including for Qt users as the link above shows. Moreover, a decent answer was already posted in this post, but it involves the use of Qt eXTension in a Qt 4 context, and that is outdated. In fact, it's so outdated that when I tried to access the eXTension link, my Chrome browser warned me of being an insecure website! So what I would like to know specifically is if there is any Qt 5, specifically, solution to this problem, given that eXTension is out of question, or if I'll have to do a OS key hook after all. A Qt5 free library will also be acceptable.

(Client) screen capture in meteor?

Is there a way to get a screen capture (of the client screen) in meteor? I don't care whether it's available (once captured) on the client or the server - either is fine.
I saw something similar to this but it appeared to only work for a browser window. I'm looking for a screen capture of the client screen no matter what is active - even if there's no browser open - just as if the user hit the "PrntScrn" key then pasted into a jpg file and saved it somewhere.
One cannot do such things (calling unapproved OS functions) from code that runs inside of a web browser.
This is a deliberate design decision for web browsers, as one doesn't want scripts from the broader internet running arbitrary code on your computer.
Internet Explorer used to (not sure if still) provide "hooks" for Windows Update that involved an Active-X control that interacted with the OS.
They MADE the OS (Microsoft) so it was their prerogative, but it undoubtedly lead to some exploits...
You can use html2canvas for generating the screenshot. There is a meter package too for the same on atmospherejs. You can find the docs and examples here
Alternative is to use PhantomJS to do this job.

Why is my swf causing the Flash Player to crash

I've got a flex-based swf, which is loading an AS 2-based swf and then, negotiating further activity via a LocalConnection.
From time to time, the AS 2-swf can request that the flex-based swf load a movie.
I've arranged this via on(release){} functions.
The AS 2-swf, I'm making in Swish Max. In Swish, when i set the on (release) on a text field, (to invoke .send() on my localconnection), it works splendidly. However, when I attempt to perform the same calls for an on(release) attached to a movieclip, it actually causes the Flash player, and even the browser plugin to crash.
In fact, the browser (IE) crashes as well.
I checked the debug trace that ie asked me to send to microsoft at the last IE crash, and i noticed a StackOverflow exception embedded deep in the trace, but I couldn't determine its source.
Can you help me understand what's going on here?
Are you having more than one LocalConnection connect to the same channel? This will cause the browser to crash.
Are you sending lots of requests at the same time, this will make it crash, and some browsers are more sensitive for those things than other.
This earlier post might have some helpful tips for you.
That's a wrong way to debug your application. Use your Flex Builder's debugging tool instead. You tend to lay blame on LocalConnection as it is the most complex part of the operation, when it could just as easily be an infinite loop.
You don't seem to be using the right tools either. I'd trust FF's FireBug over IE's dump. Besides, we'll need to see some more code before we can accurately tell you what's wrong.
Are you sure the crash is not only in your computer? Try running the FlashUtil??.exe at \WINDOWS\system32\Macromed\Flash\ to fix/update the Flash installaction. There are some known issues that corrupt Flash installation so it become unstable when using some objects.

Web browser lock-down: How to?

I have an ASP.NET web application where a portion of it needs to run in a web browser as a public facing terminal.
Essentially it is used to capture anonymous user feedback (wizard control on a .aspx) in a commercial location such as a shop.
An administrator will login and prep the application for 'terminal' mode.
The terminal is a normal PC with keyboard and/or mouse like device.
I would like to prevent users from:
Viewing the browser menu's, pushing back button and/or entering a different URI in the URL and also disallow keyboard shortcuts from bypassing the intended looping functionality of the application that is running?
Which browser is best suited for its ability to disable functionality as mentioned? The app runs on IE/FF/Chrome/Opera/Safari.
HOW would one go about configuring the machine and/or browser so it is locked to prevent unauthorized/unintended use?
On a side note, I guess the web application session needs to have an unlimited timeout?
Thanks for your input!
EDITED: I am leaving the question as unanswered for now... I would like to see responses that highlight possible options for the other browsers as well.
You can run Internet Explorer in Kiosk mode.
Please see this MS KB article.
Simply put, start Internet Explorer with the -k argument
There seems to be some commercial products available also, like this.
Try How to use Kiosk Mode in Microsoft Internet Explorer
Also, there are many Kiosk tools to assist in locking down a machine. Example: http://www.thekioskstore.com/index.php/software/kiosk-lock-down
Firefox has at least two plugins (and possibly many more):
https://addons.mozilla.org/en-US/firefox/addon/1659
https://addons.mozilla.org/en-US/firefox/addon/509
It is also possible to lock down KDE and GNOME (GNOME at least has a built in tool), which you can also use to lock down the rest of the system. I suggest installing Ubuntu if the web app is running on another system.
If you have to use MS Windows, check out: http://www.microsoft.com/windows/products/winfamily/sharedaccess/seeit/internetcafe.mspx.
You can use an opensource Linux distribution designed for this very purpose, http://webconverger.com/

How to determine if the user's browser can view PDF files

What's the best way for determining whether the user's browser can view PDF files?
Ideally, it shouldn't matter on the browser or the operating system.
Is there a specific way of doing it in ASP.NET, or would the answer be just JavaScript?
Neither, none, don't try.
Re dawnerd: Plug-in detection is not the right answer. I do not have a PDF plugin installed in my browser (Firefox on Ubuntu), yet I am able to view PDF files using the operating system's document viewer (which is not Acrobat Reader).
Today, any operating system that can run a web browser can view PDF files out of the box.
If a specific system does not have a PDF viewer installed and the browser configured to use it, that likely means that either it's a hand-made install of Windows, a very trimmed down alternate operating system, or something really retro.
It is reasonable to assume that in any of those situation the user will know what a PDF file is and either deliberately choose not to be able to view them or know how to install the required software.
If I am deluding myself, I would love to have it explained to me in which way I am wrong.
A quick google search found this. Useful for all kinds of plugins.
There are users that choose not to open PDF's in the browser and disable the plugin (this allows the file to be opened in the native application external of the browser window). It is better to let the user know that software is required to open something (whether it be PDF or not) than try to detect whether the plugin is available.
Another problem with detection is that what you need to look for changes from version to version (for example, see: "PDF.PdfCtrl.*" vs "AcroPDF.PDF.*" for the Adobe PDF viewer) and different browser implementations (the previously mentioned strings are used in IE for example, while Firefox uses a totally different manner of detection. Then we need to think of Opera and Safari and ???). Also, there are different vendors (think Foxit and Ghostscript, though I am not sure if they supply a plugin for the browser) where there may be differences in detecting the plugin.
For a script written in 2008 and some more information about the caveats see Detecting plugins in Internet Explorer (and a few hints for all the others).
After initially ignoring the advise on this page the architect went ahead with Acrobat detection, causing an inevitable support nightmare.
As ddaa mentions not all the scenarios can be accurately captured with Plug-in detection. Some users, for example, may choose to view PDF files with FoxIt Reader rather than acrobat. Some user's browsers don't flag that they are Acrobat ready, and certainly not always in the same way.
A better solution would have been to give the user a choice on how they'd like to view the relevant document. Personally, I don't like to have any website rely on a plug-in - it spoils the beauty of the web.

Resources