Writing a c# or c++ application which can detect if browser is going to download a file - events

I am going to write an application which runs in the background on windows platform. If user is working on any browser (IE, Firefox, Chrome, etc) and any of the user action results in downloading activity, the background program should take control. The background program pop-ups a window asking user, if they want to download. If user proceeds with OK, then background program sends signal to browser to stop its download process and the background program will do download. If user rejects download by the background program, then default download of browser can go on.
For this please suggest if any working model is there in c#/VB.NET/C++ or how to achieve this activity.
Will very much appreciate your kind help.
Thanking you very much in advance.

I don't think you understand the whole notion of downloading. Any resource you get from the Internet is downloaded. Hence, anything would trigger your application. You can, however, try to "parse" URL to see the extension but this does not have to mean nothing, since you can give any file an arbitrary extension (well not exactly arbitrary, but you know.. ). Another option is detecting FTP downloads ( i assume this might be of more interest ). This way you'd "only" have to check for a specific protocol. The reason i quoted only in the last sentence is that none of these tasks is a simple one.
You basically want to write a Proxy, or use an existing one.
You might wanna take a look at WinPcap
Finally, none of this options really give you the infromation whether user is going to download a file. But if you write a proxy, you could stop the endpoint application of obtaining that file once you download it.

Related

Alternative to Windows Alternate Data Streams

I have the following need to implement on Windows: file with files.
Originally I was thinking to use directory with extension. Something like "folderA.myappext", so when user clicks on it in Explorer, my app is launched instead of folder being opened. Unfortunately, I was unable to find a way to do that. Then I tried to use Alternate Data Streams. This works just fine, but several problems with it:
It works only in NTFS, so no way to send it via email or FTP as is;
Only WinRAR can properly archive it, and you still have to do extra clicks in the UI for that;
The real file size (with all streams in it) is not shown in Explorer and does not participate in showing free/used space, which can very quickly lead to big problems for the user.
No, I can't use zip or any other way to combine files into one - this is high-performance app that also requires write streaming (i.e. it changes data all the time).
Any idea how else to achieve my need on Windows? I know on MacOS you can use 'package', but there is nothing like that on Windows. Any idea?
Something like "folderA.myappext", so when user clicks on it in Explorer, my app is launched instead of folder being opened.
You can't do it based on the extension because folders don't have extensions but you can do it with desktop.ini. Windows 7 and later supports custom verbs on folders.
A working example can be found here.

Opening webpage, look for content and give notification once found it

I want to be open up chrome, go to a webpage, and the check that a specific content ie, title, subtitle... is there, and then give me a notification if the content is present, ideally on a loop until it has found it. What is the best way to do that?
I have done a fair amount of this a few years ago, but now I have completely forgotten it all, and I just need help starting up again.
I don't have any software install, (in pretty sure with how basic this is I wont need any).
I have saved a bash file on notepad which I wrote " start www.bbc.com ". This will open up the bbc website, but I don't know how to check for example the title says "Welcome to the BBC". This is just an example, I want to try it on different website, but if I know how to do this then I can change the rest myself. I know how to use inspect element, I just don't know how to implement it in a script.
If there is another software/language thats easier than bash im happy to change over.
I know this sound very trivial and easy, I just want to start off and any help is much appreciated.
Thank you very much

What's the proper way to call VBScript from Firefox?

I'd like to be able to call a vbscript from Firefox that resides on network share. Thus it is visible to all my team members at work. Using:
<a href='file://///server/path/to/file.vbs'>run me</a>
What this script does is it grabs server side information through Samba from the client-side, and uses that information to bring up a MS Outlook new e-mail window with the HTML formatted server side (a Linux system) information filled in. I do not send the e-mail yet because I want to allow the teammate to make sure what they are about to send is correct. And we have to use Outlook. Unfortunately mailto: does not appear to allow any kind of HTML formatting, which is why I've turned to VBScript.
Seems to work in IE, although you get prompted before it allows you to run it. I guess that's OK for now. It's a little annoying having to make sure you're in IE to run it, especially for those of us who prefer not to use IE.
Right now all Firefox does is display the code contents in the browser.
I'm not even sure if I'm going about all this the right way, but from where I stand, I guess I'd like to be able to run it from Firefox. If not, I'll survive. Thanks
I don't think this is possible. Even if it is, it's probably a security risk.
To launch the script, you'll have to run "wscript.exe file.vbs", but that's not allowed otherwise Viruses can exploit this easily.
Therefore, unless you want to use some browser exploit, this will not be possible.

Creating quick GUI front ends

I wanted to have a GUI front-end for a script that accepts numerous command-line options, most of them are UNIX paths. So I thought rather than typing them in (even with auto-completion) every time, I'd create a GUI front end which contains text boxes with buttons beside them, which when clicked will invoke the file browser dialogue. Later, I thought I'd extend this to other scripts which would sure require a different set of GUI elements. This made me think if there's any existing app that would let me create a GUI dialog, after parsing some kind of description of the items that I want that window should contain.
I know of programs like Zenity, but I think it's doesn't give me what I want. For example, if I were to use it for the first script, it'll end up flashing sequence of windows in succession rather than getting everything done from a single window.
So, basically I'm looking at some corss-platform program that lets me create a window from a text description, probably XML or the like. Please suggest.
Thanks
Jeenu
Mozilla's XUL is a cross platform application framework - . You could write an app as a Firefox plugin or a standalone XUL application.
mono and monodevelop could work for this. Or even something super simple like shoes.

Can an app use the clipboard for its own purposes? (read: who owns the clipboard?)

In PowerBuilder's IDE, the code autocomplete feature uses the clipboard to communicate the completed text to the code window. By doing so, it overrides whatever was stored on the clipboard before. So, if you had the winning numbers of the next lottary stored on your clipboard, and you used the autocomplete to turn m_goodfor into m_goodfornothing, you've just lost your only chance of ever getting rich, and you're left with nothing on your clipboard.
Features like that are the reason I hate software. It looks like it was implemented by some intern that noone was looking after. However, there's also a chance I got all worked up for nothing, and making such use of the clipboard is absolutely legit. So, can an app use the clipboard for its own purposes? Who is considered the owner of the clipboard?
(Bonus votes to whoever puts himself in place of the feature's programmer, and provides some reasoning for this being done on purpose, assuming the users would actually benefite from it)
You are probably right on the intern reasoning. There is absolutely no reason why an application would use the clipboard to communicate information other than pure laziness. Even between processes, there are other, better ways of communicating information.
Other then letting the user paste information in another application, there is no reason to use the clipboard.
The programmer did it because it was easy, and put his needs above those of the end user. There are many programs that do this, particularly add-ins to outlook, VB, etc., which copy/paste their buttons onto the toolbar. Any user that runs a clipboard extender (like my own ClipMate) will absolutely hate this behavior (and you'll be "busted" right away).
Here is my favorite quote on the subject:
“Programs should not transfer data into our out of the clipboard without an explicit instruction from the user.”
— Charles Petzold, Programming Windows 3.1, Microsoft Press, 1992
An app should never change anything on the clipboard without the user initiating that action. My .02 anyway.
Bonus votes to whoever puts himself in place of the feature's programmer, and provides some reasoning for this being done on purpose
Using clipboard for application communication
They are always a better way to do it. The programmer might have done it this way because it was faster to implement OR because he really wanted to have this value in the clipboard after the action. At least, if he didn't wanted to have it in the clipboard he could have get the value from the clipboard, store its value then replace the old content of the clipboard inside the clipboard and everything would have be more "transparent" ans less frustrating for the end-user.
I have built a piece of functionality into an App that uses the clipboard. Business was requesting a way for users to seamlessly capture a screen shot and upload it.
I worked with the business to develop it and what we came up with was a user simply hit the print screen key and clicked "upload" in my app.
The Java Applet running in the background pulled the image off the clipboard and displayed a formatted preview to the user, The user then added in a file name and description and clicked save.
Using the clipboard this way saved the user the time of having to capture the screen shot save it somewhere then find it through an upload interface. Even if we did go that route by the user hitting print screen to capture the image in the first place they are already overwriting whatever was on the clipboard in the first place.
Using the clipboard isn't all bad but I certainly agree using it in an IDE is a def no no.

Resources