Bill Hayes

I am trying to use VB 2005 SendKeys.send to fill in fields in a pdf form in a browser (at an online website).
The code below works correctly sending keys to Notepad or WordPad, but when I use it to send keys
to pages in IE7 or Firefox or even ActiveState Komodo editor I get more than one character and the number
of repeats is variable. For example, if I send "ABC" to a Google page I get AAAAAAAAAAAAAABBBBC.
I have the same problem if I send "^v" to paste from the clipboard - I get multiple pastes.

I set my keyboard repeat function to a long delay which did not affect the results.

This is the button code:
Label1.Text = "Paste"
Label1.Refresh()
System.Threading.Thread.Sleep(4000) 'delay to let me put the cursor in the browser
SendKeys.SendWait("ABC")

I click the button in the VB form, then click my cursor in the an applications window.

(BTW, for html forms online I successfully used automation and IE7's exposed methods to insert into named
input fields, but that doesn't work for an application like Acrobat which is running in a browser window.)

Thanks in advance for any comments and suggestions.



Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

ahmedilyas

try giving it the code to send it once....it can help

SendKeys.SendWait("{A 1}") 'send "A" once.

SendKeys.SendWait("{B 1}")

SendKeys.SendWait("{C 1}")

does this help






Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

Bill Hayes

No, I still get multple characters, anywhere from 3 to 12.

I don't know if VB can send WM_KEYDOWN and WM_KEYUP commands to Windows; I thought
that's what SendKey did.

Thanks for the suggetions.





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

JohnWein

I had the same problem with the .Net SendKeys. I use Windows Script Host SendKeys with no problem.





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

Bill Hayes

Thanks for the suggestion John!
Once I figured out how to do that it does work correctly.
I'll look for a way to internalize it into the VB form code (maybe with an MS Script Control )
but for anyone else with this or a similar problem, it takes two steps:

1. Create a vbscript (e.g. "test3.vbs") with the following text:
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 4000
WshShell.SendKeys "12345"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "more text"

2. Create this line in VB code (e.g. a button's code) which calls your vb script
System.Diagnostics.Process.Start("C:\VB\test3.vbs")

The second line of the script gives the user time to click the cursor in the field
of the application where the text is to be inserted.




Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

JohnWein

Just reference Windows Script Host on the References Com tab. Then import IWshRuntimeLibrary. Then declare:

Code Block

Private WSH As New WshShell 'Couldn't get VB SendKeys to work!

For an example download "Log In Assistant" from here. It's source code so you can see the references and imports. After you download it, change the extension from zipped to zip and unzip it. Then load the solution into VS.





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

MariuszR

Is there any fix for it. I don't think using shell script is the answer to the problem. I would rather use .NET back to back.

Thank You.





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

MariuszR

Bill Hayes wrote:
I am trying to use VB 2005 SendKeys.send to fill in fields in a pdf form in a browser (at an online website).
The code below works correctly sending keys to Notepad or WordPad, but when I use it to send keys
to pages in IE7 or Firefox or even ActiveState Komodo editor I get more than one character and the number
of repeats is variable. For example, if I send "ABC" to a Google page I get AAAAAAAAAAAAAABBBBC.
I have the same problem if I send "^v" to paste from the clipboard - I get multiple pastes.

I set my keyboard repeat function to a long delay which did not affect the results.

This is the button code:

Label1.Text = "Paste"
Label1.Refresh()
System.Threading.Thread.Sleep(4000) 'delay to let me put the cursor in the browser
SendKeys.SendWait("ABC")

I click the button in the VB form, then click my cursor in the an applications window.

(BTW, for html forms online I successfully used automation and IE7's exposed methods to insert into named
input fields, but that doesn't work for an application like Acrobat which is running in a browser window.)

Thanks in advance for any comments and suggestions.

Can you tell me on what hardware did you run this





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

Bill Hayes

MariuszR,
PC with an Asus A8N-SLI motherboard and AMD dual core Athlon 4800, 2GB DRAM, with Windows XP Pro (SP2 I believe).
I set the Affinity on the Visual Studio process ("...vshost.exe") to a single cpu which did not help.

/bill




Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

JohnWein

I have a Asus A8N-VM CSM motherboard, AMD 3800 X2 and XP Pro X64 SP2. I tried updating the BIOS today but It didn't change the SendKeys results. I also have a problem with the StopWatch occasionally returning negative times. Anyone else have similar problems with a correction





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

MariuszR

My problem happens only on Dell D620 laptops. The same utility runs on every other machine just fine, except D620 laptops. I get exact same problem.




Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

JohnWein

"I have a Asus A8N-VM CSM motherboard, AMD 3800 X2 and XP Pro X64 SP2. I also have a problem with the StopWatch occasionally returning negative times. Anyone else have similar problems with a correction "

Are we the only ones having problems with .Net and AMD X2 and XP Pro X64




Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

MariuszR

We have problem with D620 laptops. It works everytime when you RDP to machine which indicates somethign with the drivers itself.
If your machine works when using RDP then its drivers. We have case open with MS to find exactly what is wrong but this is not easy problem to track.




Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

JohnWein

What CPU and OS do the D620 laptops use





Re: Visual Basic Language .NET Sendkeys sends multiple times to browser window

siulm

Bill,

You said: "for html forms online I successfully used automation and IE7's exposed methods..."

Can you expand on it a bit more Where can I get the information on exposed methods

Thanks