473,725 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SendKeys, timer, fail usually.

Hi All,

I am trying to create a auto login program.

Below is the part of code, my issue is - the target form ( handle /
window ) usually didn't perform the key I sent from my C# program
correctly.

I think it should be timing issue, I add a delay there, but it seems
incorrect.
Could you please advice ?

Thanks a lot!

/* CODE BEGIN */

SetForegroundWi ndow(ieHandle);

SendKeys.Send(" %d");

SendKeys.Send(" http://www.Yahoo_some_ where_.com~");

// System.Threadin g.Thread.Sleep( 2000);

SendKeys.Send(" {TAB}");
SendKeys.Send(" {TAB}");
SendKeys.Send(" {TAB}");
SendKeys.Send(" ms21.hinet.net~ ");
/* CODE END */

Best regards,
Boki.

Jun 29 '07 #1
1 3235
It's the question if the right control has the focus at the time you send the
key!

All the best,

Martin

"Boki" wrote:
Hi All,

I am trying to create a auto login program.

Below is the part of code, my issue is - the target form ( handle /
window ) usually didn't perform the key I sent from my C# program
correctly.

I think it should be timing issue, I add a delay there, but it seems
incorrect.
Could you please advice ?

Thanks a lot!

/* CODE BEGIN */

SetForegroundWi ndow(ieHandle);

SendKeys.Send(" %d");

SendKeys.Send(" http://www.Yahoo_some_ where_.com~");

// System.Threadin g.Thread.Sleep( 2000);

SendKeys.Send(" {TAB}");
SendKeys.Send(" {TAB}");
SendKeys.Send(" {TAB}");
SendKeys.Send(" ms21.hinet.net~ ");
/* CODE END */

Best regards,
Boki.

Jun 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5695
by: RBohannon | last post by:
I need to create a report in MS Word populated with data from A2K. I have been asked to create the report in Word so that parts of it can be edited as necessary later. The data in the report are in a table with headings for each column, so converting an Access report to a Word doc in RTF doesn't work because only the text is converted, not the table. What I have tried so far, with some success, is to write the report directly in Word....
1
7720
by: Bryan | last post by:
I am writing a C# Windows App that updates out Excel reports' modules. The app is complete, but has a problem. The only way MS allows you to unprotect the VBA code in Excel is to do it by hand or sendkeys. I hate using SendKeys, but I am forced to use them. Anyway, I have written a function that will unprotect the VBA code in the current work book. It works about 60% of the time. For some reason it gets out of sync and the SendKeys don't...
6
31098
by: Gary | last post by:
Hi, I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)") This is not working ..what could be the reason..?
7
2148
by: Grahmmer | last post by:
I have a few timers that are added to a form at runtime. I can handle the event fine, but I cannot identify which timer fired. Is there a way to do this? Timer Creation: ------------- ....some code... Dim usersTimers(4) As System.Windows.Forms.Timer For i = 0 To 4
4
3264
by: Turtle | last post by:
I've been using SendKeys to automate a small utility which doesn't expose an automation interface, but ran into a problem, for which I found the suggestion that I use the WinAPI SendInput call instead. In trying to implement this, most of the sample code I've found has been in VB6, so I'm trying to deal with that, too. The code requires a call to CopyMemory to pack information into the right structures for the SendInput call, and that's...
11
1836
by: Kevin Antel | last post by:
We have written a service that uses a timer control to check for a process every 60 seconds. This is installed on a Windows 2003 Server w/SP1. The problem we are running into is that the service doesn't stop, but it seems the timer process stops. Has anyone else run into this? What have been solutions?
0
2765
by: dtshedd | last post by:
I have a database with hundreds of embedded photos (Microsoft Photo 3.0) Many are larger than 1 MB. I tried Stephen Lebans macro but it did not work probably for the aforementioned reasons Now I am trying to use the copy portion of Stephens macro and then open MS Paint using Sendkeys to Paste and save. The Sendkeys method is opening the Paint app but not executing the paste command. Wondering what I am doing wrong. I have only ever...
2
1895
by: Maxisking | last post by:
I have this Code: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick On Error Resume Next If GetAsyncKeyState(System.Windows.Forms.Keys.F3) Then SendKeys.Send(TextBox1.Text) SendKeys.Send("{Enter}") End If End Sub
4
3794
by: Silgd1 | last post by:
Hi All.... I am using python 2.4. I have a python script on an xp machine. This machine is on a network, and is dedicated to running python scripts. I use remote desktop to access the machine thru the network. I have a script on this machine which uses Cpamie and SendKeys to navigate a website. I use "from SendKeys import *" Here is the problem. I have the script automated to run, using windows' "scheduled task". When I log into the...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.