|
-
Apr 3rd, 2009, 07:37 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] External App Not Accepting SendKeys
Hi guys,
It's been a while since i touch VB6. Been trying to work on some sendkeys but i am stumped on this one.
I am trying to send a text to a textbox. However, the app im trying to send keystrokes exits the moment i send the keys to its textbox. I am thinking it's detecting automated keystrokes and then exits. I tried to put delays and also resort to add the text to a clipboard and send keys ctrl+v but failed.
Is there some sort of code wherein the app will detect the send keys as normal stroke just like typing using the keyboard?
-
Apr 3rd, 2009, 07:40 AM
#2
Re: External App Not Accepting SendKeys
Are you by any chance using Vista/7? Those two have problems with SendKeys().
-
Apr 3rd, 2009, 07:51 AM
#3
Thread Starter
Frenzied Member
Re: External App Not Accepting SendKeys
No gavio. I am using Windows XP Pro SP3. The app im trying to connect is using Cisco VPN then connect to a secure site using Internet Explorer. Then upon opening one app, i want to send a username and password then click ok button.
The sendkeys just wont work on that window. It will exit automatically.
Here is a sample:
vb Code:
'enter username
SendKeys "username", True
Sleep 1000
SendKeys "{TAB}", True
Sleep 1000
'enter password
SendKeys "password", True
Sleep 1000
I tested it on different app and it worked but not on the app im talking about.
Also tried this but failed.
vb Code:
Sleep 3000
Clipboard.Clear
Clipboard.SetText "username"
SendKeys "^{V}", True
-
Apr 3rd, 2009, 08:04 AM
#4
Re: External App Not Accepting SendKeys
-
Apr 3rd, 2009, 08:09 AM
#5
Re: External App Not Accepting SendKeys
or,
an inet solution to access dynamic pages. you no lady, sendkeys are not reliable.
Code:
Private Sub Command1_Click()
Inet1.Protocol = icHTTPS
Inet1.Execute "https://xxxx/index.php", "POST", "username=xxx&password=xxxx", "Content-Type: application/x-www-form-urlencoded"
While Inet1.StillExecuting
DoEvents
Wend
Dim s$, ret$
s = Inet1.GetChunk(1024)
Do Until s = ""
ret = ret & s
s = Inet1.GetChunk(1024)
Loop
Me.TextBox1.Text = ret
End Sub
-
Apr 3rd, 2009, 08:33 AM
#6
Thread Starter
Frenzied Member
Re: External App Not Accepting SendKeys
@Fazi
I know sendkeys are not reliable but the app is not a totally a web based app. Ir actually runs an application with GUI. I also tried using Winspector ++ to get the handle of the app but the textbox has no handle. Winspector ++ detected the whole window as one so there's no way i can SETTEXT to it.
-
Apr 3rd, 2009, 08:36 AM
#7
Thread Starter
Frenzied Member
Re: External App Not Accepting SendKeys
How can i send text equivalent to a keyboard level?
-
Apr 3rd, 2009, 09:02 AM
#8
Re: External App Not Accepting SendKeys
 Originally Posted by zynder
How can i send text equivalent to a keyboard level?
yah, keybd_event 
The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver’s interrupt handler calls the keybd_event function.
Code:
Const VK_H = 72
Const VK_E = 69
Const VK_L = 76
Const VK_O = 79
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Form_KeyPress(KeyAscii As Integer)
'Print the key on the form
Me.Print Chr$(KeyAscii);
End Sub
Private Sub Form_Paint()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Clear the form
Me.Cls
keybd_event VK_H, 0, 0, 0 ' press H
keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0 ' release H
keybd_event VK_E, 0, 0, 0 ' press E
keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0 ' release E
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_O, 0, 0, 0 ' press O
keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0 ' release O
End Sub
-
Apr 3rd, 2009, 09:04 AM
#9
Re: External App Not Accepting SendKeys
 Originally Posted by zynder
@Fazi
I know sendkeys are not reliable but the app is not a totally a web based app. Ir actually runs an application with GUI. I also tried using Winspector ++ to get the handle of the app but the textbox has no handle. Winspector ++ detected the whole window as one so there's no way i can SETTEXT to it.
is this a webpased app? still i did not get the idea. phaps a screen shot of that would be
-
Apr 3rd, 2009, 09:33 AM
#10
Thread Starter
Frenzied Member
Re: External App Not Accepting SendKeys
Thanks. I'll give this a shot. I will keep you posted.
-
Apr 3rd, 2009, 09:58 AM
#11
Thread Starter
Frenzied Member
Re: External App Not Accepting SendKeys
@Fazi
Very nice the keyboard event seems to do the job. At any rate, do you have the list of CONST for numbers 0-9?
-
Apr 3rd, 2009, 12:56 PM
#12
Re: [RESOLVED] External App Not Accepting SendKeys
-
Apr 3rd, 2009, 12:59 PM
#13
Thread Starter
Frenzied Member
Re: [RESOLVED] External App Not Accepting SendKeys
Yeah thanks for that I got the 0-9 and letters part but the TAB part isn't working. I guess i ran out of options.
I tried the TAB keyboard event to notepad and the TAB was a success however not on the app i am having problems with. The letters and numbers did fine but not TAB.
-
Apr 3rd, 2009, 03:04 PM
#14
Re: [RESOLVED] External App Not Accepting SendKeys
 Originally Posted by zynder
Yeah thanks for that I got the 0-9 and letters part but the TAB part isn't working. I guess i ran out of options.
I tried the TAB keyboard event to notepad and the TAB was a success however not on the app i am having problems with. The letters and numbers did fine but not TAB.
oh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|