Send Enter Press to Web Page using API (1 Viewer)

coops1106

New member
Local time
Today, 23:32
Joined
Aug 13, 2008
Messages
7
Hello all,

Hope you can help with my problem.

This is my first post on a forum, so please forgive me if I've put this in the wrong place.

At my place of work there are many different systems and places where information is stored and part of my job is to collate that info into one place, so that the managers have one place they go to for reports on how the department is running etc etc.

The only tool we have at our disposal to undertake this task is MS Access, so over the years we've become fairly proficient with VBA.

However our phone system recently changed and I have come across a new problem that has me vexed. In order to get stats out of the new system I have to open a webpage, select all departments, enter yesterdays date, hit download, save a S/S then import it to a table :(

All terribly manual and time consuming.

I was recently made aware of API and have tried to incorporate this into a form.

So far when I click the command button, it opens the webpage, next I need to send an enter key press in order to login, but it doesn't work.

This is what I have in code

Private Sub Command4_Click()

Dim x, result

x = FindWindow(vbNullString, "Active Portal - [Login Screen]")

Call SendMessageLong(x, WM_CHAR, 13, 0&)
Call PostMessage(x, WM_KEYDOWN, VK_RETURN, 0&)


End Sub

And in a module

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long

Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long


Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const BM_CLICK = &HF5
Public Const BM_SETSTATE = &HF3
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const VK_RETURN As Long = &HD


 
Local time
Today, 17:32
Joined
Mar 4, 2008
Messages
3,856
This doesn't seem like the right approach. But to answer your question, why not use Appactivate() and Sendkeys()?

You might also want to look at IE automation. I have written entire applications to totally drain many online databases of their hidden treasures (it has been a while). As I recall, my method included "re-writing" the inner html to "POST" what I wanted posted. I'm pretty sure I picked that method up through a search on the inter-web thingy.
 

coops1106

New member
Local time
Today, 23:32
Joined
Aug 13, 2008
Messages
7
Thanks for the reply George

I tried using a button that opens said webpage and used a sendkeys command, but got nothing.

I think maybe the enter command is being sent before the webpage has a chance to load.

If you had any example code i'd be grateful
 
Local time
Today, 17:32
Joined
Mar 4, 2008
Messages
3,856
If you had any example code i'd be grateful

If you're in a hurry, no, I don't. If you can wait until I can dig it out from some computer I may have used over the last 10 years, located who knows where, I might be able to help.

Either way, I'd suggest it would just be faster to use google to find out how to "POST" using VB and the IE OLE automation object.
 

Users who are viewing this thread

Top Bottom