SEND clip as keystrokes - vbscript

I am just wondering if there is any way in manner of PSH or VBS to paste/SEND the text from clipboard as separate keystrokes rather then string????
It is VERY important, since I have to do some automatic search in web UI drop down lists and passing text by CTRL+V simply does not work. So I need to send each letter as unique keystrokes.
Tried to find some way and searched over the Internet but no luck.
Thank you in advance

There are a few ways to interact with the clipboard in VBScript. Here's one way to read clipboard text:
strText = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
Once you have the text, you could simply send each letter in sequence:
For i = 1 To Len(strText)
SendKeys Mid(strText, i, 1)
Next

Related

How to Move the mouse using VBScript

I am trying to move the mouse using VBScript. I tried to use Sendkeys "{CLICK LEFT , x , y}" and Sendkeys "{MOVETO, 10 , 20}" but it isn't working i also tried to use MouseKeys, so i could move it with the keyboard and therefore use Sendkeys to activate it but it also did not work (the mousekeys numpad is not moving the mouse). I've tried everything I know and what i could research elsewhere, so now I hope one of you can answer this for me. thxs
One possible way to move the mouse is:
Dim Excel: Set Excel = WScript.CreateObject("Excel.Application")
Excel.ExecuteExcel4Macro "CALL(""user32"",""SetCursorPos"",""JJJ"",""xxx"",""yyy"")"
-->xxx = X Position
| yyy = y Position
The only disadvantage is that you need Microsoft Excel to run this script...
Hope I could help you
VBScript can't do this natively. You'd have to do some calls to the Windows API or some other library that can do this for you.
As an alternative, you may want to consider a different scripting language, like AutoHotKey which can do this in one simple line of code for you.

SAP Script: Set focus on Input Field in order to SendKeys

in my SAP VBS Script, I want to paste the Clipboard to an Input Field. I use
WshShell.SendKeys "^V", but it does not do anything and I suspect this because the Input Field has no focus.
So far my best guess was to "write" empty text into the field and then set the caret position to 0 and hope that this shifts focus to the field, but it does not help:
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = ""
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 0
I have not found any methods for the session object, I hoped to find anything like session.setFocus or similar.
Is there a way to set focus on an Input Field?
Thanks
How about, for example, with
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").setfocus
Regards,
ScriptMan

Type a pre defined text when a shortcut key is pressed in Windows 7

I work on mainframes and don't have much knowledge about windows other than playing warcraft :-) hence pardon me if I ask something nooby/silly.
I have a requirement to enter a particular long-text in the current position of a cursor whenever a shortcut key is pressed.
I am thinking of creating a bat file and assigning a windows keyboard shortcut to the bat file and whenever I have requirement to enter the long text, I press the windows shortcut key
and the long text gets typed in the current position of the cursor.
The current position of the cursor can be in any application, like Excel, Word or notepad or Windows dialog prompts.
Could you please let me know if this is possible and point me where I could get some information about this "technique".
Thanks & Regards,
Vasanth.S
To make a single key combo do what you are asking, you may need another program. You can make a link to a batch file, hook up a shortcut and then use the clip command to copy text from a file onto the clipboard. That would require the shortcut and then a Ctrl+V to paste. The batch file would look like this:
clip < c:\SomeDir\sometext.txt
You might like to look at using a clipboard manager - which saves a history of clipboard entries, can search for an entry, and paste it at the cursor.
Ditto and CLCL are both useful and free - which one you use depends on your windows version.
They are hotkey driven for ease of use, but mouse can be used.

TextMate - Find & Replace Selected Text

In TextMate, does anyone know how you find & replace selected text?
Is this what you're looking for? http://manual.macromates.com/en/working_with_text
4.5.2 Find Clipboard
Two useful key equivalents are ⌘E and
⌘G. The first copies the selection to
the shared find clipboard. This works
in the majority of applications and
allows you to find the next occurrence
of that string by then pressing ⌘G.
The find clipboard works across
applications so whether in Safari,
TextEdit, Mail, TextMate, Terminal,
Console, or similar, one can copy the
selected text to the find clipboard,
switch application and use ⌘G to find
that string.
In addition TextMate offers ⇧⌘E to
copy the selection to the replace
clipboard. This is often useful to
save a trip to the find dialog, for
example if you want to replace
newlines with the pipe character (|)
for a list of items, select a newline,
press ⌘E to use that as the find
string. Now type a |, select it and
press ⇧⌘E so that it is copied to the
replace clipboard.
The next step is then to either press
⌃⌘F to perform the replacement in the
entire document, or select the range
in which you want the replacement to
occur and use ⌃⇧⌘F instead.

How to hijack the Caps Lock key for Cut, Copy, Paste keyboard operations

Here is what I am trying to accomplish:
To Copy, press and release Caps Lock ONCE
To Paste, press and release Caps Lock TWICE, quickly
To Cut, press Ctrl+Caps Lock
The reason I want to do this is often times i find my self looking down to press the correct X/C/V key, since they're all next to each other (atleast on a QWERTY keyboard).
How can I do this on a standard keyboard (using Windows), so that it applies to the entire system and is transparent to all applications, including to Windows Explorer? If not possible with a standard keyboard, can any of the "programmable numeric keypads" do this you think?
In the above, by "transparent" I mean "the application should never know that this keystroke was translated. It only gets the regular Ctrl+X/C/V code, so it behaves without any problems".
Ps. Not sure of all the tags that are appropriate for this question, so feel free to add more tags.
SOLVED. UPDATE:
Thank you to #Jonno_FTW for introducing me to AutoHotKey.
I managed all three requirements by adding the following AHK script in the default AutoHotKey.ahk file in My Documents folder:
Ctrl & CapsLock::
Send ^x
Return
CapsLock::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 1000)
Send ^v
Else
Send ^c
Return
That was easy!
NOT COMPLETELY SOLVED. UPDATE:
The above works in Notepad, but NOT in Explorer (copying files for example) or MS Office (even text copying does not work). So, I need to dig around a bit more into AutoHotKey or other solutions. Will post a solution here when I find one.
In the meantime, if someone can make AutoHotKey work for everything I need, please reply!
ALL SOLVED. UPDATE:
All I had to do was to change the capital "C"/X/Z to lowercase "c"/x/z. So Send ^C became Send ^c. It now works in ALL programs inlcuding Windows Explorer! Fixed code above to reflect this change.
I believe the program you are looking for is AutoHotkey.
You need a Global Keyboard Hook.
Very nice! Been looking for something like this for a while.
My script is slightly different, making use of shift or control combinations for cut/copy, then CapsLock on its own is always paste.
Ctrl & CapsLock::
Send ^x
Return
Shift & CapsLock::
Send ^c
Return
CapsLock::
Send ^v
Return
If you wanted to retain the option of retaining the Caps Lock function, I presume you could always remap e.g. Alt-CapsLock for this. I couldn't get it to toggle correctly when I tried it though.

Resources