Posts: 13
Score: 0
Joined: 6/23/2005
From: USA
Status: offline
I need to send the key combo CTRL+I in an application,
dim Pb1 set Pb1 = CreateObject("WScript.Shell") Pb1.run "ARUser" , 1 WScript.sleep 1000 Pb1.sendkeys "pb{tab}pb{tab}~" WScript.sleep 5000 Pb1.sendkeys "(^I)"
that's my application so far, but when it should do the CTRL+I nothing happens, I've tried like "^(I)" among many other things but none have worked, can anyone tell me how to send CTRL+I?
_____________________________
TV may make you feel ignorant, but nothing rubs it in quite like a computer.
If that doesn't work, try "{^I}". I'm nearly certain that using parentheses is incorrect which are used for sending repeating keys and cannot be used with "combo" keys like ctrl, shift, & alt.
Posts: 13
Score: 0
Joined: 6/23/2005
From: USA
Status: offline
sigh, ya "^I" was my first guess, then "(^I)" "^(I)" and so on and so forth, but none of those works, nor does "{^I}" <--that one gives a runtime error while all others simply have no effect at all
I believe the correct syntax is "^(i)"...sendkeys uses a literal translation, so it will interpret "I" as a capital I. So it will send nothing meaningful, since you don't include the "+" operator to send a shift. That would be my guess, I hate using sendkeys since it can get so complicated, especially if you have to send a lot of keystrokes.
Marcus, you're right about about sendkeys seeming to be complicated... flakey is how I'd describe it. BTW, it works for me without the parentheses also... just "^i". I'm still not getting "{INS}" to be recognized however and I've never discovered how to send other "special" keys such as the large plus key on the numeric keypad... my text editor uses it for special purposes.
Posts: 13
Score: 0
Joined: 6/23/2005
From: USA
Status: offline
I have heard there's a way to use the keyboard map (where it tells u a number for every key) and sendkeys to cooperate in what you are trying to accomplish Xandros, but I do not know the specifics, I also am interested to figure that out, if I find the answer I'll post it for you
I discovered a few minutes ago that using {INSERT} works where {INS} did not... go figure! Also, just found out (google search) that SendKeys in .net is doumented as supporting the +, -, *, and / keys on the numeric keypad... but using {ADD}, which is defined to be the large PLUS key, doesn't work in VBScript
sendkeys is like macros...its like a robot typing out the keys instead of you, thats the way I think of it. So case has to be factored in (since when I type I have to press the shift key to send a capital letter), and oddities such as using +, ^, %, etc. as operators AND needing to use their literal keystroke representation have to be accounted for when writing a script. If you read the following, it seems as if even the microsoft engineers who do these writeups seem befuddled by some of the rules. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthsendkeys.asp