Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Excel VBA Send Keys


How can I send text to another application through an Excel VBA sub routine, particularly Internet Explorer?

For example... press a button in excel to open internet explorer (new window) and goto www.google.com and type in "test" in the search field.

I was able to open the webpage with Shell ("iexplorer location" "website") but when i try using Sendkeys "text", it doesnt seem to work.

I also cant seem to figure out how to activate a specific IE window... if I have 2 IE windows open one is at google and the other is at yahoo... im not sure how to use an appactivate (or similar) to distinguish the two...




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Send Keys In Excel
I need to be able to either ignore/circumvent message boxes in excel I am thingking sendkeys. Is this possible

I need one for Click the "Ok" button on a message box and Clicking a Yes to overwrite button on a file save.


not sure if this is a good Idea, nor how to do it.

thank you

Susan

Send Keys
Can anyone send me the Send Keys code for the Down Arrow?

Send Keys
I need the program to automatically do a tab followed by ctrl Y.
I think it can be done by sendkeys. but wats the actual code. can someone reply me?

Send Keys
I am importing data into an Accounts program called Sage, from Access 2000 The code works except for the three lines hat simulate three down arrow keypresses. Key Presses work but the simulation does not but then works again for the rest of the procedure. Any ideas welcomed.

Regards

Private Sub Command0_Click()

Shell ("C:sfwsfw.exe"), vbMaximizedFocus

DoEvents

SendKeys "%F", False ' Send ALT+F to open &File Menu

DoEvents


SendKeys "I", True ' Send I to select 'Import Data'


DoEvents 'Let Windows have a turn & Give SFW.exe a chance to catch up.

SendKeys "{DOWN)" 'Move down one

DoEvents

SendKeys vbKeyDown 'Move down another

DoEvents

SendKeys vbKeyDown 'Move down another

DoEvents

SendKeys "%R" 'When Focus has noved down 3 check boxes then use Alt + R to Run it, this works OK

' SendKeys "(C:sfwBarry.csv)"



'MsgBox " Faulty"
Exit Sub



End Sub

Send Keys
hi all, in my program i have a webbrowser control, and what i want to do is send keys to the webbrowser control every 3 mins, what i want for it is every 3 minutes it sends the left arrow key waits 1 second sends the right arrow key then waits another 3 minutes, how can i do this

Send Keys
once again im imitating a windows program - dont worry its ot mine sweeper this time - its the onscreen keyboard that microsoft has in the accessability utilities.

The problem im having is this:

e.g When i want to rename a document i can click on it, click the "F2" key on the onscreen keyboard ,and then type what i want on the onscreen keyboard - though when i tried doing the same with my vb program - when i clicked the command button it doesnt work.

im think this is because the onsceen keyboard somehow gives focus back to the last thing clicked/highlighted etc - before sending the key - though i dont kow i would go about doing this???? - any ideas???

another feature i would like to know how to do - though i think will be alot harder is - the keboard detects all the key that i type e.g as im typing this if i press shift 5 times it tells me about the Strict key function - though how does it do this cause the onscreen keyboard doesnt even have focus so how does it know ive pressed shift 5 times i a row???????
is this using the keyhook.dll or something???

thanks alot - any help on either of these questions is greatly appreciated

**** Send Keys ****
hi sorry i dont mean to be a nuisance its just i posted a thread about sned keys and it never got answered - i thought this was prob just cause alot of toher threads were shortly creatred after and it was neer answered. here it is again - sorry if its a case no one knows but i though a repost was worth a try:

once again im imitating a windows program - dont worry its ot mine sweeper this time - its the onscreen keyboard that microsoft has in the accessability utilities.

The problem im having is this:

e.g When i want to rename a document i can click on it, click the "F2" key on the onscreen keyboard ,and then type what i want on the onscreen keyboard - though when i tried doing the same with my vb program - when i clicked the command button it doesnt work.



im think this is because the onsceen keyboard somehow gives focus back to the last thing clicked/highlighted etc - before sending the key - though i dont kow i would go about doing this???? - any ideas???

another feature i would like to know how to do - though i think will be alot harder is - the keboard detects all the key that i type e.g as im typing this if i press shift 5 times it tells me about the Strict key function - though how does it do this cause the onscreen keyboard doesnt even have focus so how does it know ive pressed shift 5 times i a row???????
is this using the keyhook.dll or something???

thanks alot - any help on either of these questions is greatly appreciated

Send Keys
How exactly does the SendKeys function work? Im making a module supporting MSN Messenger stuff, and im trying to figure out how to send a certain letter to access a selection on a menu, so umm how could i possibly send the letter F after i find this certin menu?

Send Keys
how could you send these two keys to the desktop:
control and printscreen
i tried
sendkeys "{CTRL},{PRNTSCRN}"
i don;t know if that would work

<font color=white>Scooby </font color=white> <font color=yellow>-Doo </font color=yellow><font color=blue> Where are you? </font color=blue>

Send Keys
I am trying to get the same thing to work as another thread (basically), but I am not receiving a responce to my specific question. It says it can not find 'findWindow'. Also, if you could check out my other code that would be great. Thanks.


Code:
Private Sub Command1_Click()
'SendKeys (vbTab)
THWnd = FindWindow("Outlook")
SendMessage THWnd, WM_Press, "%t"
End Sub

Send Keys
Hello,wonderin if any one can show me an example/code to get a list of current windows what are open,like ie window/msn convo etc,into a list box when i click one of those names in the list box it will open that window thanks

Send Keys
I am using VB6 and have made a program which cannot be closed unless the user enters the correct pass and then presses command button

This is the code i have for the command button


VB Code:
Private Sub Command1_Click()If txtpassword = "password" thenendelsemsgbox ("Wrong Password") Vbinformation, "Wrong Password"end ifend sub


Now somewhere in my form's code i want to have a line of code which will allow the user to press the return key instead of clicking the command button

i.e. www.hotmail.com

You enter your username and password and you can click sign in or hit return well i want to be able to hit return as well.

Thanks

Send Keys
oHow do i send ctrl p using send keys.

I am in an access application and when a report is open I tried to do:

SendKeys "{^P)"

But this did not bring up the print dialog.

Thanks,
JOn

Send Keys? Or Something Else
I need to kill a program if it is running, this is what I try to use but I get errors.


VB Code:
AppActivatestrProgramSendKeys "%+{F4}", True


Sometimes this work, sometimes I get a Run Time Error 5 message.

Is there a better way to do this?

Thanks

Send Keys To Ie
oi! im making a ie thingy and i want to know how to send keys to ie. someone please tell me! thanking you in advance

Send Keys
Can I use SENDKEYS to type in any app that is open??

Say for instance notepad?

Do I need to know the Title of the Application???


Regards


Matt

Send Keys
hi all,
i want to ask how to send keyboard code like enter to a control which have focus, with vb code ?

Send Keys
How do you send keys to another program outside your vb program?
Also how can you have your program wait for the task to
complete before you send the next task. I want to send the
key "S" then wait until the program is finished then sen the key "X".

Send Keys
<script launange="javascript">
alert("Please Help")
</script>
how can you send the ctrl alt and del keys in order to pop up task manager<br>

Instead Of Send Keys
Such as:

AppActivate ("Telnet - yo.mama.etc.fl.us")
SendKeys "{ENTER}"
SendKeys "{ENTER}"
SendKeys "{ENTER}"
SendKeys ("2")
SendKeys "{ENTER}"
SendKeys ("Di")

Is there any other way, with API, etc to do this exact process? If there is let me know! Thanks..

Send Keys
It brings up the window, but its not typing anything in it.

AppActivate ("EM320W [ ccla.lib.fl.us - 1 ]")
SendKeys "{ENTER}"
SendKeys "{ENTER}"
SendKeys "{ENTER}"
SendKeys ("1")
SendKeys "{ENTER}"

it doesn't type the 1...why?

Send Keys
hi,

i was wondering weather there is a way to send multiple keys

i want a program that when someone preses a command button it brings up the ctrl - alt- del dialog box, pref using sed keys


please include code

Send Keys
How to send keys without DDE? SendKeys doesn't work because it uses DDE.

AG

Send Keys ?
How to send some keys like ctrl Alt Delete (Not together)
I write this code:
sendkeys "{ctrl}" then it gives error why ?

 

Edited by - Evil Nemesis on 5/18/2004 10:17:06 PM

Send Keys
can anyone tell me about send keys.....if possible attach a small code also

Send Keys
Hi all,

Shell "cmd", vbNormalFocus
SendKeys "A"

The above fail to sendkeys "A" to a command prompt. How can i do it?

Thanks

Send Keys
Hi Codegurus,

I have a little Problem:

I'm trying to write a program, that, when lying in the background, waits until a special key is pressed (for example Str & R or else) and then sends certain Keyboard-Commands to the system.

I want this for an auto fill in another program. There you have to enter a User name and password.
I need to login several times a day, and the program does not save the last inputs, so I had to type it in every time I use this program.
I want to write a program, that runs as Symbol, and when I start it, it asks me after my username and password.
Then, when I started the other program (where I have to login) I enter the first text box and press Str+R (for example).
Now my Background-Program captures this and fills the fields for me and executes.
So I have to send to the system normal characters, the TAB key, Shift+TAB and ENTER.
Plus, I must capture all keys the user presses.
And extra plus, can I somehow identfy the current active window, so that the background program only reacts on this special login mask?

So, my questions:
1) How can I capture with a background program, which keys are pressed in windows?
2) How can I send keys (commands) to the system?
3) How can I identify the active window (the program name or else)?

Many thx in advance, if you can help me with any of this questions,
Greetings from Germany (so excuse my bad english please)
Tom

Send Keys
Can someone please give me an example of how i could make my program press "ctrl" and "O".When i click a button. Thankz alot

I Need Help With Send Keys
I'am able to open my Excel file with code VB but when I wont to start the macro in Excel am not able may be because my Excel Windows is not active?
I think I have problem with AppActivate

Do you know why am not able to use Send Keys !

This is the code I use.

private Sub ExecuteLink(byval sLinkTo as string) ' Execute the passed Link'

'on error resume next
Dim lRet as Long
Dim lOldCursor as Long
lOldCursor = Screen.MousePointer
Screen.MousePointer = vbHourglass
lRet = ShellExecute(0, "open", sLinkTo, "", vbNull, SW_SHOWNORMAL)
'MyAppID = Shell(sLinkTo, 1)
'ReturnValue = Shell("c:Program FilesMicrosoft OfficeOfficeExcel.exe", 1)
'AppActivate "Microsoft Excel"
SendKeys "^+G"
If lRet &gt;= 0 And lRet &lt;= 0 then
Screen.MousePointer = vbDefault
MsgBox "Erreur d'ouverture avec le fichier " & sLinkTo & vbCrLf & _
vbCrLf & Err.LastDllError, , "ExecuteLink"
End If
Screen.MousePointer = vbDefault

End Sub




Thanks Redg

How Can I Send Keys
how can i send keys from my application to any other programe that i make active by mouse clicking. or i have to use the z-order method to find second active programe?

Send Keys
can someone tell me about send keys. I've had a look at other posts but I'd really like an example of some code and ANY information.

Many thanks

Phil

Send Keys To DirectInput
Hi, i was wondering how realvnc or macro apps manage to send the key input from a recording or remote computer to a certain selected application.

I've tried postmessage, sendmessage, send keys and keybd_event but they all dont work.

For example i have a program that relies on DirectInput (well thats what i think) , so even copy and pasting the text doesn't work. It acts like a regular textbox, but it isn't.

How can i perfectly simulate keyboard strokes ? Sending wm messages don't work, copy pasting doesn't work, send keys doesn't work, keybd_event also doesn't work. Yet when i type in the textbox it works.

Another note: when i typed text in the particular textbox, and try to get the getwindowtext from it, i get an empty string. So my thought is that it prints the text typed in the textbox, rather than containing it.

Any thoughts or help on this is greatly appreciated,

Thanks in advance.

Send Keys Problem
Hi

I'm trying to use sendkeys function to open a text file using textpad and then do some manipulation with regular expressions. The code works fine when i open ONE textpad file. However when i loop to open multiple files everything gets in a mess and the wrong keys are sent -
Here is the code i'm using:

Private Sub cmdFormatWordFiles_Click()

Dim FileSpec As String
Dim FileRead As String
Dim NewFileSpec As String
Dim i As Integer
Dim intCount As Integer

'CopyFiles

FileSpec = OriginalFilePath

Set fs = New FileSystemObject
Set folder = fs.GetFolder(FileSpec)
Set Wd = New Word.Application


For Each file In folder.Files
FName = file.Name
FileRead = FileSpec & FName


'FilePos = InStr(1, FileRead, ".", vbTextCompare)
'NewFileSpec = Left(FileRead, FilePos - 1) & "1.csv"


Wd.Documents.Open (FileRead)
OldFile = InStr(1, FName, ".", vbTextCompare) - 1
NewFile = Mid(FName, 1, OldFile)
Wd.ActiveDocument.SaveAs NewFilePath & NewFile & ".txt", FileFormat:=wdFormatText
Wd.ActiveDocument.Close

taskId = Shell("C:Program FilesTextPad 4TextPad.exe", vbMinimizedNoFocus)
AppActivate taskId
SendKeys "^O"
SendKeys NewFilePath & NewFile & ".txt"
SendKeys "{ENTER}"
SendKeys "{F8}"
SendKeys "
[: :]"
SendKeys "+="
SendKeys "Claim Desc:"

SendKeys "{TAB}"
SendKeys " "

intCount = 8
For i = 1 To intCount
SendKeys "{TAB}"
Next
SendKeys "{ENTER}"
SendKeys "{F8}"
SendKeys "

[: :]"
SendKeys "+="
SendKeys "Claimant :"
SendKeys "{TAB}"
SendKeys " "
For i = 1 To intCount
SendKeys "{TAB}"
Next
SendKeys "{ENTER}"
SendKeys "{F8}"
SendKeys "+6
"
SendKeys "{TAB}"
SendKeys "{DELETE}"
For i = 1 To intCount
SendKeys "{TAB}"
Next
SendKeys "{ENTER}"
SendKeys "{TAB}"
SendKeys "{ENTER}"
SendKeys "^S"
SendKeys "%{F4}"
'DeleteOldFiles FileRead
'RenameFiles NewFileSpec
Next
taskId = 0
Set Wd = Nothing

Unload Me
End Sub

&gt;&gt; Send Keys Command &lt;&lt;
Iam using the 'sendkey' command ...
I wonder what the code for sending 'space' is ...
Can anyone help me??

I tryed this ...

Quote:




SendKeys "{Space}"





------------------------------------------------------

Jonathan

How To Send Keys To Windows With Vb
Hi to all! I tried SendKeys function but it only sends hotkeys to my application and not to windows. is there a method to send some keys to windows? for example CTRL+ALT+DEL to make taskmgr appear? or something else like WINKEY+F for Find...

Thanks
simons

Send Keys And &lt;alt&gt; Codes
Anyone know how to use Send Keys to send character codes such as <alt> + A?

Send Keys To Other Applications
Hello,

I am beginning to write a program that sends keys based on what you put into a text box. What it will be used for is room-wide announcements - instead of one long message, it sends it in more than one message, which makes for a better format (IMO of course).

I have two problems:
1) I need a function that will send keys to applications outside of the one I'm writing (SendKeys sends keys to the application which calls it, I was aiming more toward sending keys to Windows (I guess) )
2) I can't think of a good way to send the keys where you want. I was thinking maybe a timer or something that, when it hits zero, it sends the text to the active text box (in the other window), or maybe you click where you want it to send the keys.

I'm not exactly good at explaining things, so this may confuse some of you. What I need is a function for #1, and an idea for #2 if anyone could be of assistance :-)

VB Send Keys API Replacement
All,
Im in a bit of a problem here. I have recently lost faith in the SendKeys function. Now I'm looking for an API function that will do the same thing.
Im new to API, so some basic instructions would make my day.
Any help would be appreciated
alt_255

Send Keys Issue
i have a prog that i want to automate but has no access to it via code. so i need to use a vb prog to find the window, set the focus, Ctrl - O to open a file, insert the file name, then enter, and then 'click' on a big fat button right in the middle of the form called 'Calculate' and then Ctrl-S as a csv file

here is what i have so far, but the sendkeys ^O thing (for Ctrl-O to open a file) isnt working


Code:
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3

Private Sub Command1_Click()
Dim lhWnd As Long
Do
lhWnd = FindWindowEx(0&, lhWnd, "TForm1", vbNullString)
If lhWnd Then ShowWindow lhWnd, SW_SHOWMAXIMIZED
Loop While lhWnd
SendKeys "{^O}"
End Sub

Send Unicode Keys?
How can I use sendkeys to send the unicode character 0394? If I run notepad and do Alt+916, the character is displayed (Delta character), but I don't know how to send alt+916 with VB.

How Can I Send Keys To Putty?
Is there a way to send keys to a puTTy session like for the login and password? I am trying to automate the opening of a putty session with a click of a button and at the same time, without the user still manually typing the login and password...

I already have a code for opening a puTTy session with a specified IP address, the only problem is I can't send its keys for login and password... I don't know, the 'sendkeys' command doesn't seem to work for puTTy...

Hoping for a positive response from the masters... thanks in advance....

Send Keys Problem
hi,
i am trying to send both text and keys to programs using SendKeys but theres a problem. it always send to the top most form which means you cant type at the same time. is there a way out there to select the form to send keys to
thanks for any help

Send Keys To Other Apps
Suppose I had a program running in the background that would respond to a hotkey such as Ctrl F5. How would I go about making this program send a string of keys to the program in the foreground. I already know how to make it respond to the hotkeys. If you need details, I want to make a program that will send
"Ctrl X"
then
"weaknesspays" and "Shift Enter"
over and over for about 20 times. Those of you familiar with Sim City 4 know why

Yea... I'm a cheater...

How To Send Keys Like A User?
hello,

how can I send keys to my form as if a user has pressed on these keys?
I want to simulate a typing by the user...

thanks

Send Keys To Winamp 5.0
Hi,

I'm trying to send keys to Winamp version 5.0.

I've looked through the forums and the posts I've found regarding sending keys to applications all use the FindWindow function.

I've tried to use the FindWindow function with Winamp 5.0, but no luck.

Has anyone managed to do this with Winamp 5.0, and if so how?

Could anyone else advise me or point me in the right direction in getting the true window name.

I've run some code found that returns the names of all the running application windows, but Winamp comes up as Winamp. When I try to send a key press to it, it does nothing, not even getting the handle of the window?

Anyone?

Send Keys Without SendKeys
Hello.
I have two active forms in my app, the Main one and another one. I would like to have the program transmit the keypresses from the other form to the Main one when it (the other form) is active.
Say, in the Main form, F3 triggers a specific event. I would like to have the Main form know that F3 has been pressed when it has no focus (when focus is on the other form).
Sendkeys COULD work, but for special keys (such as Enter) there would be trouble... (have to associate for example 13 to {ENTER})

Send Keys &amp; Progess Bar
My app is a sort of interface between a bunch of other apps--gets data here, sends it there, has this app do this or that, etc. It does this through APIs or send keys. All works fairly OK, except that when it needs to send keys to an app it gets a bit mucked up if the user hammers on the mouse buttons.

What I want to do is temporarily freeze the mouse and put a form with a progress bar on top of the screen. That way the user can't muck up the focus for send keys, but they know processing is taking place.

But I need different apps in focus in order to send keys to them, but still want my progress bar form to stay on top. Any idea how to do this?

Send Keys To Program...
I have a program running on my computer that we use at work to data entry information in. Well I am looking to eliminate the data entry part by automatically clicking and selecting stuff. However, for some reason this program will not accept the keys I send using VBA.SendKeys but if I flip to MS Word it works. The program doesn't show up in the Task Manager under Applications.

Any help would be appreciated

Send Keys To Outlook From VB
Anyone know how to send Ctl + G to Outlook from a vb project?
I really dont want to be using VBA or the SendKeys function.



Thanks in advance.

Copyright 2005-08 www.BigResource.com, All rights reserved