StringReplace unable to identify and replace string copied into clipboard from web pages? - string

What I am trying to do is very simple: copying selected text into clipboard and replacing every occurrence of some words with others.
StringReplace replaces the specified substring with a new string, so it would be what I am actually looking for.
This small script should copy the text highlighted by user into clipboard, look for every occurrence of the strings <name>, <class> and <race> and replace them with strings Aerien, Paladin and Human:
^q::
{
Send, ^c
ClipWait
StringReplace, clipboard, clipboard, <name>, Aerien, All
StringReplace, clipboard, clipboard, <class>, Paladin, All
StringReplace, clipboard, clipboard, <race>, human, All
Sleep, 250
Send, ^v
}
Return
At the end, it pastes the new content.
Well, said that... try to use it on the contents of this web page as instance, especially where it's written:
I hope you strapped your belt on tight, young <class>, because
there is work to do here in Northshire.
Aforementioned script returns me always <class> instead of replacing that string with Paladin. Using the same script within Notepad instead of within that web page sometimes work but more often not.
I am guessing some issues with < and > symbols.

Always use AutoHotkey from http://ahkscript.org/ (current version, new official website)! AutoHotkey from autohotkey.com is outdated and you may have some problems running scripts with it!
Your script works as intended. When you press CTRL+q script copies to clipboard selected text (so you have to select text before pressing CTRL+q), then in a text that is in clipboard it searches for <name>, <class>, <race> and replaces them respectively to Aerien, Paladin, Human. After it pastes the content of clipboard to the current active window.
1. If you need to paste the content of clipboard in specific input field of current active window, then in my opinion the best way to do that is to use ImageSearch command to get coordinates of that input field, after make click in theses coordinates and after paste the content of clipboard. But also keep in mind that there can be other solutions to do the some.
2. If you need to paste content of clipboard in some other window, activate that window with WinActivate command and then paste the content of clipboard.

Related

Copy formatted cell contents from Excel to Word without clipboard

I would like to know if it is possible to transfer the contents of a formatted Excel cell to Word without the use of the clip board.
Using a macro to copy and paste works great - but it interferes with the users clipboard, rendering their PC / Workstation a bit useless.
I have done some background research into a property called WordOpenXML
https://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.wordopenxml%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396
My thought process would be to spawn an Excel copy and open the spreadsheet access the inner xml of the Excel cell (or the Open XML) and just set the Property in Word.
That way I know it has transferred like for like - with no use of the clipboard.
Maybe there is another approach - I wondered about spawning a separate clipboard object.
You could try to store what's inside the clipboard in a variable at the beginning of the macro. At the end after your copy/paste action you could restore the clipboard to it's original state.

Plain text editor (or plugin) with ability to copy line into clipboard in just one mouse click

I'm looking for plain text editor (or plugin) with ability to stay on top and copy entire single line into clipboard by just clicking somewhere within this line. Without need to make a selection or press any key(s) first, just click and get line copied into clipboard. Next click inside editor's window gets another line from opened file copied into clipboard, and so on. Thanks.
I don't think such app exists. Coz single click always changes caret position only.
In SynWrite editor u can click line, AND press Ctrl+C. (First set option "Copy current line if no selection made" on).

increment pasted number keyboard

Probably this question is absurd for you and i don't know if there is solution.
What i would like to do is increment the number that i have copied with control-c after each control-v that i do..
For example if i copy with control-c the number 10 from a site, then when i paste with control-v in another program the number pasted should be 11 etc..
Is there a way to do this???
Because i have to insert about 2000 number in a program and in this specific case is not possible to do script in order to automate the work..
I hope in some answer
Thanks
I can't think of a great way to do it.
What comes immediate to mind is you can open Excel and have two cells, let's call them incoming and outgoing. You paste into incoming, and outgoing is setup to be incoming + 1, which you can copy and paste into your program. So you double the number of copies and pastes you have to make but it won't be the end of the world. It sure beats manually typing.
It's possible, using a small (custom written) program that would run in the background. It would have to look at the contents of the clipboard, test if it's numeric, and if so, increment the value, if it's not already been incremented. Shouldn't be all that hard for a windows programmer worth their salt to cook up.
I did this in excel when i needed it multiple views. row() function enters current row number. Copy this cell for as many times as you want one below other and then copy paste in android studio.
=CONCATENATE("dateBoxView"|ROW()|" = fragmentView.findViewById(R.id.dateBox"|ROW()|");")
You can do this using something like Pulover's Macro Creator. You press a hotkey to copy a number. Everytime you press ctrl-v a the copied number gets +1 and that new number copied to clipboard for the next paste. When you want to stop doing this just stop the macro.

Why can't I copy paste this text in Vim?

When even i try to copy paste this text in vim it put half of it in the command line and half in text editor main window
This is the text
sub(/;;/," ",$0)
How can i copy paste that
When you paste in console Vim (not GVIM), Vim cannot detect whether what you've pasted is typed by you or an actual paste. Therefore, any (insert mode) mappings will apply. You probably have a mapping (maybe ;;?) that leaves insert mode, and that is triggered during the paste, wreaking havoc.
There are two ways to prevent that:
Either paste in normal mode via "*p (active selection) or "+p (system clipboard), provided that Vim is able to interact with them.
Or, set the 'pastetoggle' option, e.g.
:set pastetoggle=<F2>
and then press F2 (in insert mode) before pasting (note how the mode changes to -- INSERT (paste) --, and again after it. This way, you explicitly tell Vim "the next characters aren't typed by me, treat them literally".
If this manual management is too much of a hassle for you, you can alternatively use graphical GVIM.
I'm not sure which way you're copying and pasting (i.e. from an Xorg window (like gnome-terminal) to vim or vice-versa). Let's assume you want to copy and paste from an Xorg window into your vim window. There are a few ways to do it:
Select the text to copy using the mouse, put vim into insert mode, then press the middle mouse button.
If you are using vim with X support in a console (often started by typeing vimx) then you can select the text to copy using the mouse, then in the vimx window press "*p. The text selected by the mouse is placed in the * register.
If you are using vim with X support in a console (started by typing vimx) then you can select the text to copy using the mouse, right click the mouse, choose menu item Copy and then in the vimx window hit "+p to paste. In this case, because you used the right click menu item to copy, the text was placed in the in the + register.
Items 2 and 3 above also work when using gvim.
What you can do is make sure you're in insert mode and copy the code snippet with ctrl+v on the keyboard and then left click to the vim window to put it back in focus, then tap right click once and your text should paste in. I just tested this to make sure and it worked on CentOS 6.3 at least.
In vim you have modes, to enter text you have to be in insert mode. Press i (before current char) or a (after current char) before pasting your text.
If you don't go into insert mode, the first char s will erase the current char and enter insert mode putting ub(/;;/," ",$0) on your file.
Press ESC to leave the insert mode.
Also if you happen to have a shared clipboard with your GUI pressing p will paste.
To have a shared clipboard on OSX insert set clipboard=unnamed in your ~/.vimrc file.

Yank part of multiple lines and paste

Is there a way I can select a portion of multiple lines in vim and then paste them at the end of another block of lines. For instance if I want everything after the equal sign from:
qw=12345
er=23435
and pasted into:
ty=
ui=
What would I have to do?
This seems real simple, but for some reason, I am completely stuck.
You are looking for block selection mode.
Please note the different keybinding for Windows platforms.

Resources