How not to save passwords and sensitive data in Quicksilver/Alfred clipboard history plugin? - clipboard

I'm using the Quicksilver clipboard history plugin to record the last 15 items.
The problem is i sometimes need to copy/paste passwords or other sensitive data (from 1Password for example) and i was wondering if there was a way to not log this type of data.
Thanks for your help

Quicksilver and/or Alfred would need to be aware of where those clips came from, i.e. from 1Password, etc, in order to exclude them.
1Password itself has an option to remove the clipboard data after a certain period of time (90 seconds by default, I believe).
I don't think there's an easy automated way to do what you want though.

There is a voluntary methodology for password programs to notify clipboard monitors to NOT capture the data. If your clipboard monitor and the password program both implemented it, then you would not have passwords being captured. I suspect that one or both of them do not use this system, which is described here:
http://www.clipboardextender.com/developing-clipboard-aware-programs-for-windows/ignoring-clipboard-updates-with-the-cf_clipboard_viewer_ignore-clipboard-format
Basically, the password program adds a private clipboard format called CF_CLIPBOARD_VIEWER_IGNORE, and the clipboard monitoring program looks for that and treats it as a "do not capture this sensitive stuff" flag. It works, but only if both parties use it.
I wrote the article above over 10 years ago, hoping that it would be in widespread use by now. Alas, it has not, but it HAS been implemented by several password managers, and several leading clipboard managers besides my own.

In Quicksilver's preferences for the Clipboard plugin, you can specify a list of applications to ignore.

Related

Is it possible to disable OTHER programs that have hooked the Windows Clipboard with ChangeClipboardChain

I have an application that inserts lots of text in Word documents using the clipboard as the intermediary. I either do that with the usual Paste command in VSTO, or various other API calls that indirectly do the same thing. I do not control everything being inserted, so I cannot just use Range.InsertFragment or another alternative.
On some machines, users have applications that hook the clipboard to do other cool things, such as saving a clipboard stack, etc. For example, I use and love ArsClip to give me access to the last 50 things I put in the clipboard, and it exhibits the problem. There are lots of other similar utilities.
Most of the time, I believe thse programs use ChangeClipboardChain to hook the clipboard, but I'm not certain if there are other ways to do it.
I have always had some problem if certain other programs are running, and the problem became much more acute with Office 2016.
For earlier versions of Office, the symptom would be that the .Paste operation would fail after a fairly length timeout, and it happened but sporadically enough to mostly ignore.
For Office 2016, you get the same long delay, and then an error that says "The action was blocked by organization policy", and the frequency increased by an order of magnitude.
I usually have to mitigate this by searching for the offending program and killing it, but that's obviously a losing long-term strategy.
So does anyone know of a way to temporarily disable the clipboard chain so the clipboard monitoring is disabled, and then restore it to just the way it was.
As an alternative, is there a way to at least walk the stack of viewers and see if there are any known problem children, and shut them down automatically.

Is it possible to find out what application inserted the text into the clipboard?

Is it possible to find out what application inserted the text into the clipboard?
My guess is no but I'm no windows API expert.
There is no API for that purpose. You would have to write a DLL that globally hooks the SetClipboardData() and OleSetClipboard() functions in every running process so it can keep track of clipboard assignments and convey that information back to your app when needed.

windows api - detect when file of certain type is opened

Is it possible to have certain code executed whenever a file of a certain type is opened? In my case, I want to "listen" for when video files (".avi, mp4, etc.") are opened (either via the windows file explorer shell, or maybe directly from a video player?), so that I can store a history of played videos.
An hour's worth of googling turned up nothing, so I turn to you stackoverflow. Please point me in the right direction.
Thanks.
The best (and only reasonable way) to capture file system events (open/read/write) from arbitrary processes is by writing a File System MiniFilter
If you're developing a commercial product, please refrain from "hooking" Usermode APIs like CreateFile. Doing so requires numerous, platform-specific hacks, and is a compatibility nightmare.
I wouldn't hook CreateFile for this job. Windows has mechanisms built-in to handle jobs like this much more cleanly.
The easy way to handle this would be with ReadDirectoryChangesW with the FILE_NOTIFY_CHANGE_LAST_ACCESS flag. Any time a file is opened, its last-access time will be updated, so this tells you any time the file was opened.
Although it's pretty rare, that can "miss" changes under rare circumstances1. If you must have 100% accuracy (instead of, say, 99.9%), you can read change journals instead, but it's a fair amount of extra work for an advantage you may not care about.
1. There is one circumstance that isn't (necessarily) rare that you might care about though: ReadDirectoryChangesW will only work when/if your program is running. Change journals will let you know about things that happened even when your code isn't running at all.

How to record Mail GUI actions on Mac using AppleScript Editor

I'm a newbie to Mac and trying to use AppleScript to ease my daily job. One of the things I want to achieve is to automatically create Smart Mailbox based on the groups in my Address Book. While I have no problem automate Address Book, there's no much article about how to automatically create Smart Mailbox. After some searches on the web I realized it can only be done through GUI scripting. But most of the answers are about how to bring up the new Smart Mailbox dialog but no further information about e.g. how to select different rules. I tried to use AppleScript Editor to record my activity so that I can learn from that but found out after recording, there's nothing get recorded! I tried with other apps like Finder the recording does work! If anyone knows how to record it, or how to get more information on this type of GUI scripting would be very appreciated!
Unfortunately Mail's Applescript support is more than a little maddening at times due to being so limited. Control of smart mailboxes is but one example. I'd hoped SL would have fixed this but Apple's thinking about Applescript can be pretty schizophrenic at times. I'm not sure they have decided what to do with it.
I'd got a Smart Mailbox creation script working but it never worked reliably so I never deployed it. If you really want it I can give you the code - although it's written in Python + Appscript rather than pure Applescript.
Were I you I'd submit this as a bug to Apple and hopefully it'll be fixed with Lion.
The problem with GUI scripting as I'm sure you discovered is that figuring out how to get the name of each particular element can be maddening. There are a few utilities out there that will help, but unless you are doing a lot of GUI scripting they probably aren't worth the cost.
Regarding Applescript recording this was a really nice feature often supported under the old MacOS. However with the switch to OSX almost no application supports it so it's basically a dead feature for all practical intents.

How do you control printer tray selection for printer in Windows

We need to be able to change the default selected print tray of a given printer. Does anyone have VC++/win32 code for doing this?
In case it matters, I believe we have to change the default setting for the printer. Our print jobs are executed by an application other than ours, so we can't make these kinds of changes in the context of a print operation originating from inside our application. Unless there is some way to modify the default print settings in a different application, I think we are stuck changing the user's defaults for the printer, initiating our print job, then setting the defaults back to the original values.
We'd really prefer to have the defaults change for the current user only, and not require any special UAC elevation, etc...
I suspect that it will use something similar to what is shown in this MSDN article, and involve setting fields in the DEVMODE structure (either dmDefaultSource or dmFormName or both).
Any takers? Or does anyone have any gotchas they'd like to share?
EDIT: Here is a link for DEVMODE documentation DEVMODE documentation
EDIT: I should also point out that we are looking for a general solution - not something specific to a particular printer (we deploy in many, many environments)
FYI - the solution we wound up using was to capture the DEVMODE structure. We have a small win32 app that presents the printer settings dialog (via DocumentProperties with fMode set to DM_IN_PROMPT). The resultant DEVMODE is then saved to disk. When we do our printing, we capture the current DEVMODE, set the stored DEVMODE, initiate the print, then restore the original DEVMODE.
This actually works quite well. Occasionally, the print drivers will update and cause the stored DEVMODE to break, but that doesn't happen very often and it's easy enough for users to fix.
As an extra bonus, this approach allows us to capture ALL of the printer settings (not just the output tray) - so we were able to support advanced settings like stapling, collating, etc...
Tip: If you try this, be sure to write to disk as a binary output stream. In my initial evaluation of this approach, I accidentally set the output stream up as a text output stream. Things would work fine for many cases, then suddenly break for some printers (that used high order bytes in their DEVMODE private data). A dumb, but easy, mistake to make - and one that took a very nice solution off the table for awhile.
Setting features like this can be tricky, especially if the driver doesn't follow Microsoft's print guidelines. That being said, we've had some success with System.Drawing.Printing.PrinterSettings. You can set PaperSource but I'm not sure you can set the defaults.
If you haven't seen this example you may want to look further at it. It describes a method to store and reload printer settings. One of my guys pointed it to me:
PrinterSettings - Changing, Storing and Loading Printer Settings
Another method, that could work but might not work for you, is to determine your the handful of setups you need. Install a printer with each of these (ie: Tray 1, Tray 2) setups. Then simply switch the default printer on print. Not what you are looking for but it may help.
What we typically do in these situations is have the 3rd party app write the data to a folder that we are monitoring, we then pick up the file and parse the Postscript or PCL ourselves and change the paper tray and then send onto the destination device. A lot simpler then it may sound.
dmDefaultSource controls the tray. Unfortunately the values you'll want to set this to differs depending on your driver as this is a bin number and not necessarily the same number as the tray# printed on your printer.
The following link provides some VB6 code for gathering information about your printers tray/bin assignments. You can use that information to programatically assign dmDefaultSource to the appropriate bin # for a tray. You basically need to use DeviceCapabilities to return information about your printers and then search for a string (like "Tray 1") to get the associated bin number.
http://support.microsoft.com/kb/194789
I had to do something very similar recently on a specific printer driver and it required a vendor specific SDK. The tray doesn't seem to appear in DEVMODE or any of the other PRINTINFO_* structures so I guess I'd drop an email to the printer vendor.
As a last resort, I can think of two possible hacks. One is to automate the driver at GUI level using a scripted tool such as AutoIT. Second is to dump the registry to file, change the driver setting, dump the registry again, and compare the differences (may or may not work).
As far as I know, printers are controlled by the printer driver by sending them SNMP or PJL commands. But not all printers implement completely these sets of commands.
For HP printers I found at: http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?lang=en&cc=us&objectID=bpl07282&jumpid=reg_R1002_USEN some PJL commands (there are some related to the tray too).
I'm not sure this help, but take it as a hint for future searches...

Resources