Community discussion forum
SendKeys Command
-
This thread is for discussions of SendKeys Command.
-
Nice Example. This code can be quickly adepted to make a nice keylogger.
-
nice job, but how do i get it to send the keys to the window thats got the focus when i press a certain button,
e.g. send the text to internet explorer when i press F3 or something like that ? -
What's happen if I use the sendkeys in a script, and the computer was locked before the script starts ? (I use events scheduler to start the script !) thanks
-
i want to save an opened notepad file. how can i do sendkeys for this. please send me code. This file will be opened manually by user. I just want to save this
-
I have a question to ask you, I noticed that you had looked at the senkeys method on developer fusion and it seemed like you probably had yours working. I'm working in Access 2000, and I am trying to open a program called Macro Angel and send the key combination of Shift+Q over to it, I cannot get it to work. Here is some code that I have tried to use, maybe you could help me out here. If you could email me back at rwjeske@hotmail.com it would be greatly appreciated.
stAppName = "C:\Program Files\Demirhan\Macro Angel\MacroAngel.exe"
Call Shell(stAppName, 1)
SendKeys ("+q")
Shell "c:\Program Files\Demirhan\Macro Angel\MacroAngel.exe", vbMinimizedFocus
SendKeys "+q"
Regards,
Ryan -
I am curious as to why the code on this webpage does not work in NotePad.
-
It does for me. Is Notepad opening minimized? It won't work then. You should be able to figure it out from the compiler, I think it's 'shell "notepad" as vbMaximizedFocus".
-
Well, if you know the following will be true:
-The file will be changed
-There won't be a file with the same name
You can do this:
SendKeys "%{F4}{ENTER}file1.txt{TAB}{TAB}{ENTER}
This will close the program, it'll ask if you want to save, OK will be chosen, a filename entered and OK chosen again. This is a very unreliable method and will only work on WinXP (small adjustments are required for others due to less listboxes), but it should do for simple stuff. file1.txt is the filename, which will be entered right where it should be. If the file already exists the user will have to manually choose whether to overwrite, and if it's unchanged Notepad will close and everything after Alt+F4 will be sent to the next program which could be a problem, so consider typing and deleting something to avoid this.
[edit] Oh yeah, and on XP you can use Ctrl+S to save - the filename dialog will only appear on an unsaved file! -
You mean the classic "This computer has been locked, only XXX or an administrator can unlock" message? I doubt it would let your program run. However if it did, it would merely send the keys to the dialog, which shouldn't be a problem but will (probably, unless you get lucky
) generate an Invalid Password when you hit Enter and make a lot of noise when you exceed the maximum text length. -
I appreciate finding a more complete listing of Sendkeys. Unfortuantely, the one I need is the only one not listed. I need the one for the SPACEBAR. I need to a SendKey command that holds down the Ctrl+Alt+Spacebar so the field will update a default in the field. So far I have SendKeys "(^% )" (With the one for spacebar missing. I'm using this in an Access 2000 database. My thanks to anyone who may be able to help. Sue
-
I´m using VBScript and it works if I put something like:
AppActivate "Bloc de notas" ' I´ve win2000 in Spanish
sendKeys ("keys to send"), true
But I´m using Citrix and execute remote applications. Then I open a remote Notepad and write:
AppActivate "Bloc de notas - \Remote" ' win2000 in Spanish
sendKeys ("keys to send"), true
The first line works ok, the remote application activates, but the sendKeys doesn´t work.
Please, ¿can anyone tell me if there is any way to send key to remote applications?
Thanks -
I believe the sendkeys command for the spacebar is { } (make sure you put a space between).
-
I am trying to copy a field and paste it into another field.
-
I think what happened was the SendKeys ("{TAB 9}"), True can't be interpreted as tab for 9 times. Hence the SendKey "^C" statement was ignored. Why I don't know.
Solution: I use For statement to loop 9 times.
For I = 1 to 9
SendKeys ("{TAB}"), True
Next I
SendKeys "^C"
This then works.
... -
You're opening Notepad on another PC? It won't work then. It only simulates keypresses on your keyboard. You'd have to get it to run an app/script that sends the keys on the other PC.
-
Good Afternoon - I have a VB program that launch the C shell (services for UNIX). I will like to print some commands at the prompt using the SendKeys but it won't work. Below is my code:
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'Public customReportName As String, customReportName2 As String
Private Const WM_CLOSE = &H10
Private openCShellExe As Long
'EXECUTE THE EXECUTABLE FILE ASSOICATED WITH THE MEDTOX REPORTS
Public Sub cmdOpenCShell()
frmPrinter.WindowState = 1
If frmPrinter.cmdPrint.Value = True Then
Call Shell("C:\WINDOWS\SYSTEM32\POSIX.EXE /u /c /bin/csh -l", vbNormalFocus)
'Call Shell("cmd.exe", vbNormalFocus)
DoEvents
openCShellExe = GetForegroundWindow
SendKeys "cd .." ', True
SendKeys ("{Enter}")
SendKeys "ls"
Else
Exit Sub
End If
End Sub -
How can I simulate Ctrl+Alt+Del on WinXP? I tried it and although it sends the keys (and my sort-of-keylogger verified it), Windows ignores it.
-
Hi
I am trying to simulate data entry in SAP screen from VB. The Ctrl+tab and Shift+tab are not working.
I used "^{tab}" , "^(vbtab)" , "^((vbtab))", "^({tab})" but nothing worked.
Please do clarify -
Hey All,
I'm having the same problem with sendkeys "^{TAB}". My application treats this command as a TAB - "{TAB}", but I need a CTRL+TAB to skip through a text box. Does anyone have any suggestions? Thanks,
Steve -
I dont know if it will help
The same case happen when I use ComponentOne Flexgrid, I use to simulate left key to do the shift tab
' Left or Shift Tab (65536 + 9)
If lastkey = 37 Or lastkeydata = 65545 Then
System.Windows.Forms.SendKeys.Send("+{TAB}")
Else
System.Windows.Forms.SendKeys.Send("{TAB}")
End If
I just curious if it work in your case -
I dont know if it will help
The same case happen when I use ComponentOne Flexgrid, I use to simulate left key to do the shift tab
' Left or Shift Tab (65536 + 9)
If lastkey = 37 Or lastkeydata = 65545 Then
System.Windows.Forms.SendKeys.Send("+{TAB}")
Else
System.Windows.Forms.SendKeys.Send("{TAB}")
End If
for a ctrl, try 131072 + 9 instead of 65536 + 9
I just curious if it work in your case -
If you need to use sendkeys to send a combination of keys for example CTRL+C (for copy) you need to use brackets. Sendkeys "^C" sends CTRL and C separately. Use something like Sendkeys "(^C)"
-
5 years agoby
Nimpo
Mitch Dusina
Littleton (Denver), Colorado, USA, United StatesJoined 5 years agoI'm not sure if this can be accomplished with the send keys but how can you simulate a left or right mouse click? -
Hi,
I've read your post about sendkeys and I have the same issue.
In a script I want to copy the text selected and it works well on my computer with this code :
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.SendKeys "^{c}"
But I installed the program on other computers and there, the script doesn't copy anything !!
Do you know how can this happen ?
Are there rights that I need to configure on other computers so that sendkeys can be called ?
Thanks,
Jerome -
Thank you.
-
in vb how do I send Ctrl + Alt + Del followed by an Enter key in VB Code
this is to lock the system.
thanks
/Sunil -
Awesoem!, but u kno how when useing command prompt, u can hit alt+enter to make it go full screen, how would i get it to do tht, its not working i have this so far -
Shell "C:\WINDOWS\system32\cmd.exe", vbNormalFocus
SendKeys ("%~")
SendKeys "@echo off~"
SendKeys "cd\~"
SendKeys "cd windows~"
but i cant get the %~ command to work???? can neone help??? -
Hi,
You can lock a windows nt based computer (2000,Xp,2003 etc) by the following shell command:
shell "rundll32.exe user32.dll,LockWorkStation",vbhide -
HI,
Thanks for replyng.
Can you explain in detail how this can be done,
coz im new to all this stuff.
thanks
Sunil -
Thanks,
It is working.
Sunil R -
Hello, I was wondering if there is a way to send keystrokes to a window that isn't active, such as a minimized application.
-
Use the Windows API.
-
I have a similar issue. If any one has any idea how to send key strokes to a citrix client plz reply
[quote user="torcaz99"]I´m using VBScript and it works if I put something like:
AppActivate "Bloc de notas" ' I´ve win2000 in Spanish
sendKeys ("keys to send"), true
But I´m using Citrix and execute remote applications. Then I open a remote Notepad and write:
AppActivate "Bloc de notas - \\Remote" ' win2000 in Spanish
sendKeys ("keys to send"), true
The first line works ok, the remote application activates, but the sendKeys doesn´t work.
Please, ¿can anyone tell me if there is any way to send key to remote applications?
Thanks
[/quote] -
I think the following example will solve all of your problem SendKeys("+52222222+6+6?ABCD~") This will send the following text %2222222^^?ABCD followed by Enter key as shown above + means Shift key so +5 means Shift and 5 that is % so +6 means Shift and 6 that is ^ ~ means Enter key Hope this will helpfull. Regards Akhtar Tehnical Lead
-
Sometimes, I've found, if you change the 'true' to 'false,' in the SendKeys statement, the SendKeys statement will work. I use the default 'false' most of the time. And/or, you might have to put a pause in your code between the AppActivate and SendKeys statements to prevent the keys being sent before the object is ready to receive them. The AppActivate/SendKeys method is unreliable, so you have to tweak things sometimes to get it to work.
!--removed tag-->
Post a reply
Related discussion
-
Bin Packing
by rocky777 (22 replies)
-
Compact & repair MS Access database
by daspeac (7 replies)
-
How to Export Datagridview contents to Excel
by BarbaMariolino (8 replies)
-
Speech Recognition
by jitvinder (153 replies)
-
Socket Programming in C# - Part 1
by lespero (24 replies)
Related articles
Quick links
Recent activity
- convertertool convertertool replied to Full Reviews: All Popular i...
- convertertool convertertool replied to Full Reviews: All Popular i...
- great007 great007 replied to Full Reviews: All Popular i...
- great007 great007 replied to London Focus Groups - earn £80
- great007 great007 replied to Full Reviews: All Popular i...
- karez bartolo replied to integrating barcode reader ...
Enter your message below
Sign in or Join us (it's free).