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

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.

Related

Tab key does not work in windows control added (.Net extension) in saleslogix windows

I have added a .Net windows form inside a saleslogix windows plugin, every thing is working fine but on pressing the "Tab" key inside this control, instead of going on the next textbox the control goes to next plugin.
I have searched it a lot and can not find a work around for this, when I added a browser control in another saleslogix windows plugin, the page inside this textbox has multiple text boxes in it. To my surprise on pressing the tab key it worked perfectly and control goes to the next text box.
Any help is much appreciated.
That's an entirely normal mishap when you use Winforms (and many other UI class libraries) in a host application. Navigation keys, like Tab and the cursor keys as well as shortcut keystroke keys, need to be recognized regardless which control has the focus. One way to do so would be to implement the KeyDown event handler on every single control. That's excessively painful of course.
So it doesn't work that way, the keystroke is recognized when it is received by the message loop, before it is dispatched to the control with the focus. Overriding the ProcessCmdKey() method is the general way to do this. The base method takes care of navigation and recognizing menu and button mnemonics.
Problem is, it isn't the .NET message loop that is receiving and dispatching messages. It is the host application that has the loop. And it doesn't know beans about ProcessCmdKey(). So it doesn't get called and navigation doesn't work.
It tends to work in a WebBrowser because it is an ActiveX control. Which is designed to interact with its host. In particular it negotiates to decide which one gets to process the key. The IOleInPlaceActiveObject::TranslateAccelerator() method does this. Not the kind of plumbing available in .NET and host apps are rarely written to provide an alternative.
You could consider the "excessively painful" solution but pretty unlikely you like the sound of it. There's only one other decent way to fix this, you must call ShowDialog() to display your form. Now it is the .NET loop that dispatches and the Tab and cursor keys work fine. That tends to be unwelcome advice, dialogs can be pretty awkward. If you are lucky and know what you're doing and the host can deal with it (usually not) then using a thread can take the sting out of the modality. Asking the vendor for advice, particularly the threading aspect, would be wise.

Copy current selection on hotkey

I want to copy the current selection, even if it's in another application like Mail, when the user hits a specified hotkey like Cultured Code does it in Things when you create a new task. I got the hotkey working and I know how to place and get stuff on and from the pasteboard. But I have no idea how to get a current selection.
Anyone? Thanks!
You do this with a Service Provider. See the Service Implementation Guide. For what you're talking about, it should work very well. You don't need to do your own hotkey code; it'll do that for you. You don't even have to be running; it'll launch you.
To #Josh Caswell's point about OmniFocus, they're doing stuff fancier than just "the current selected text." They also copy the message itself into the inbox item as an attachment. That's what the plugin is assisting with.
This is a job for AppleScript, which is why applications that do clipping like this only support certain other applications to clip from -- those other applications have to support AS.
You'll have to take a look at the Mail AS dictionary and figure out how to get the selected text, and I believe that unfortunately you'll have to do the same with each application from which you want to clip.
Another possibility: it sounds like OmniFocus uses a Mail plugin for this functionality -- from http://forums.omnigroup.com/showthread.php?t=13906:
Starting in 10.6, Mail.app will refuse to use plugins... install the Clip-o-tron from that updated release... "OmniMailMessageEnabler...".

General Question about a GUI to execute a batch file

I'm new to programming and have taken some classes in it so I'm not sure if this is possible. I want to use a COTS software called 010 Hex Editor and write a script for the program to automate a couple tasks. These tasks can be run from a batch file according to their documentation.
Then I want to instruct the user to eject the device and reinsert it to clear the cache. (This I want done just with a simple pop-up window.
Then I also want to format the device which I assume can be done in a batch file as it can be done through dos on Windows.
My question is, with these 3 steps, can I build a simple GUI that has a button that says, "Start" or something like that, then the pop up window comes up to eject and reinsert, and then another button to format, and another button to exit. I'm not really familiar with what language this could be done in, and how to do this as the C++/Java classes I've taken have been more about syntax and OOP. Thanks!
You can use the windows messenger service to put up an alert - but on newer windows (vista/7) it's a pain to set all the permissions to allow this.
There are lots of free utilities that will popup a dialog from the command line, with a given message and wait for a response.
They are generally called messagebox or msgbox - sorry can't recommend any in particular

Taking notes to a background text editor without switching windows

I am looking for a solution to a specific use case:
When I read something on my browser or pdf reader, I want to take notes without switching windows. I want to type right on my browser or pdf reader, but the typed text should go to the background text editor like notepad.
Is this possible?
Do you know any existing automation script that handles this use case?
You should create an application that uses some keylogger-like techniques (e.g. global hooks) to monitor the keypresses and, depending on some condition (a setting you may have set, the currenctly active window, ...), it may pass them normally to the application or suppress them to store them in a buffer. Such buffer, then, would be shown to the user as needed.
Still, in my opinion a much more convenient way to perform a similar task would be to create an application consisting of a semitransparent edit box, that could be shown and hide simply with a hotkey. This would avoid all the hooks stuff and the potential problems that may arise from them.
you might try using autohotkey scripting language... I can write a little script that would do exactly what you need and afaik in this particular case it wouldnt need keyboard hooks.
--EDIT--
Autohotkey is VERY simple to use/learn so even if you want to do the script yourself you can do it in a very short time even if you dont have any knowledge of ahk. Then again, I can help you with it.

Is there a simple way to change the text of the 'Open' button on the windows file dialog to 'Select'?

We're using the file picker dialog to allow users to add documents into our application. The word 'Open' doesn't make a lot of sense in this case.
Thanks.
I would browse the code found here, which shows how someone extended the OpenFileDialog. Admittedly, this is overkill for you. But I think there is code within to change the button label.
Not really no.
Given the standardization of this dialog it's extremely likely that your users will have used it many times in the past to "add" files to applications. The chances are they will be quite familiar with the implications of the word, changing it may be more confusing to them.
The standardness of the dialog is why it's called a "Common File Dialog". If you want to change it for your app, you'll have to write your own dialog.
Having said that, there are apps out there that can pull a form out of a DLL, modify it, and stick it back in. However, this is a per-machine hack and downright bad form.

Resources