How to set own clipboard data style and get other program's clipboard style? - clipboard

For example, google docs can remebering the color, style, size and so on. Also, EXCEL can copy and paste data on diffierent charts. However, when you try to paste these into a txt, it failed and it seemed that there is nothing on the clipboard.
It shows that we can create our own style on clipboard. I wondering how it works and how could I set my own clipboard style and how to paste it(How to add a response event). Is there any API to achieve this?
Besides that, >>>>how could we get other program's data on the clipboard<<<<? I woundering this becuase I want to make a software that can help me remembering some special data forms(Sometimes I may forget and just press down Ctrl+C so I lose my data, and I have to get them again)
I have already serch the internet but there is no useful data.
Thank you.

Related

Multiple Cursors in Autohotkey

Is there any way in Autohotkey to mimic multiple cursors like in sublime. I need a hotkey that sends and couple of text lines and leaves me with multiple cursors so I don't have to type the same text over and over. Like in the gif below.
Thanks xD.
I need a hotkey that sends and couple of text lines and leaves me with multiple cursors so I don't have to type the same text over and over.
Just to open Sublime Text and type the text you need to.
and leaves me with multiple cursors
You cannot just put several cursors/carets on any application. The application must to provide support for multiple cursors creation. AutoHotKey is not a magic application which becomes everything possible, it is an automation application to automate boring or repeated tasks. Nevertheless, maybe you can search if there are some application, which can hijack other applications to compel them to use multiple cursors/carets.
However, if you are interested in make the AutoHotKey application to create several cursors on Sublime Text, you can write an AHK script to automate the cursors creation on Sublime Text using the Sublime Text keyboard shortcuts. The default Sublime Text API for Multiple cursors/carets is not very rich by keyboard, but there are Packages/Plugins as Power Cursors and Column-Select you can install on Sublime Text to improve it.
Personally I think you are better off writing a Sublime Text Package/Plugin with the Sublime Text API to create the multiple cursors/carets you want to, instead of externally to perform it with an AHK script by keyboard shortcuts.
Ultimately you can write a AHK script which asks a text and type it for you on several lines. For example:
If you enter Type This,5
The script could type on the current window caret/cursor position
To go back with the caret 9 positions.
To go one line down by pressing the down key.
To type again the same text.
Repeate this process until 5 times.
However with this we may easily see down sides as when there are empty lines as on your screen animation. So you would be better off just using Sublime Text, which is in my Opinion the best software that exists from the all as Notepad++, Atom, etc. Sadly it is closed source, so you cannot improve it by yourself or know why it is crashing certain times, which makes me wonder to write a new one open source, compatible with the current plugins and settings for it.
As others have mentioned, you cannot use true multiple cursors unless the program your're using supports it - however, you could attempt to emulate multiple cursors in the following way:
Build a defined list of cursor positions relative to the user's cursor (e.g. 2 lines down, 3 chars across, etc.). Must be relative! How you build this list is up to you.
Wait for the user to press a key
Once input is complete, move the physical cursor to the relative positions in sequence and repeat the keypress from step 2. This should be fast so the user doesn't notice the cursor jumping around.
Move the cursor back to where the user had it and go to step 2.
This is essentially how Sublime Text implements multiple cursors, but it has much better support (and speed) because it is software-level. This solution is input-level and will probably be unable to display where the multicursors actually are, will be slow, etc. Also, because it requires a fair bit of positional calculation, the implementation may complex and prone to bugs.
Sorry - this is the best I've got, it's definitely a hack - probably better (simpler) to just automate a copy and paste :P

Remove spaces from a string of text in clipboard

This is maybe a weird request but hear me out:
I have a huge database at my shop containing product codes, like 87 445 G 6 which I need to check for availability on a supplier's website. The problem is, the supplier's website consists of a web form in which I have to enter the code without spaces, so imagine that I have to manually delete spaces every time I paste a code or write it manually without.
I can't edit the database from which I copy the codes.
I wonder if some sort of plugin, script, or trick can be used directly in browser on the supplier's web form, or some software to modify how the windows clipboard works, maybe some option to copy text without spaces. Using Windows XP.
The OP has probably moved on, but for anyone else looking here, my approach was to tackle this from the windows clipboard side.
For background: I keep a list of my credit card info in Keepass. Sometimes (poorly coded) shopping cart checkout forms don't like spaces in between card numbers. I like storing them with spaces since it's easier to read off that way.
There's various Windows clipboard utilites out there, but it took me a while to find one that could do some processing on the clipboard contents and pasting it out - Clipboard Help and Spell
The program has a way to "save" a bunch of text transformations, and even assign the action to a hotkey.
For reference, my "Find and Replace" action is to find "\s" (without quotes) and leave the Replace textbox empty. "\s" will match whitespace character.
Use the javascript console
You could use the javascript console for your browser to edit the textarea after you paste.
Using Google Chrome (or Firefox)
Paste your text in the text area.
Right click the text area and click Inspect Element
Look at the id for the element
Now switch to the console view
then run these lines (making sure to replace with 'the-id' with your id)
var my_text_area = document.getElementById('the-id'); // Put your id in here
my_text_area.value = my_text_area.value.replace(/ /g,"") // Deletes just spaces
It's even simpler if you have access to jQuery:
$('#the-id').val($('#the-id').val().replace(/ /g, ""))
The replace function is simply using regular expressions to convert spaces to nothing. If you want to replace all whitespace (including newlines) you would use .replace(/\s/g,"").
For firefox, the names are the same but the UI is a little bit different.
Use greasemonkey
You can either write a greasemonkey plugin or try to find one that fits your needs.

How can you modify clipboard text?

Selecting and copying text off the page on the link below seems to lead to some text being automatically added. When this is pasted there is an extra line which starts off with "Read more:". How is this done?
Article at Dailymail.co.uk
They've got a lot of Javascript on that page. I assume that they're intercepting the copy, and fiddling with it somehow.

How do I edit a text buffer (or selected text) with the Visual Studio 2010 SDK

I want to create a simple extension which modifies text buffers based on a command. No sample, documentation or template that I've found so far explains anything about working with text buffers. Anyone got a clue how to do this?
What I want to end up with is a format selection/document extension for text files, that wrap content around 72 characters per line.
I found this extension together with sample very helpful, and now I have something which works. Though it was very counter intuitive at first, I was trying to get the at the code window while this example instead uses a command filter to fiddle with the text view by extending the editor.
The ITextView interface provides access to the text in the editor, you can access the Buffer through that and make changes that way.
Link
http://github.com/noahric/alignassignments

Reuse Edit Control as Command Window

This is a GUI application (actually MFC). I need a command window with the ability to display a prompt like such:
Name of favorite porn star:
The user should be able to enter text after the prompt like such:
Name of favorite porn star: Raven Riley
But I need to prevent the user from moving the cursor into the prompt area. Users should also be prevented from backspacing into the prompt in order to prevent the following:
Rrraven Rrrileeey Ruuuulez!!! Name of favorite porn star:
Also need to control text selection and so on. And finally, I should have no problem retrieving only the text the user entered (minus prompt text).
Will it be better to create my own window class from scratch (i.e inherit from CWnd) or should I reuse the Windows EDIT control (i.e. inherit from CEdit)?
A similar command window can be seen in AutoCAD and Visual Studio (in debug mode).
I think you'd be better off creating a subclass of CEdit and limiting filtering key-presses. I suppose the hard part is not letting the user move the caret to the prompt area, but you can probably write some code to make sure the caret always get sent back to where it belongs (the input part).
Anyway, if you really, really want to implement your own control (it's not that difficult after all) I recommend you read Jacob Navia's "technical documentation" on how he built the LCC compiler and environment. Actually, it seems the docs are not online anymore, but I'm sure you can get them through his e-mail (jacob#jacob.remcomp.fr).
Edit: I liked your previous example better. Keep it classy, LOL :)
I had a very similar requirement and did exactly what davidg suggested; subclassed a edit control and filtered key presses. This was actually using Qt not MFC but the principle will be exactly the same.
You need to remember to filter keys such as home as well as left and backspace. I just checked to see if the move would move the caret into the prompt and if it did ignored the keypress.
Another thing to watch for is pasting multiline text, you will have to choose whether to just paste the first line or all lines, adding the prompt on all lines after the first. When subclassing the control you get lots of behaviour which won't work exactly as you want it.

Resources