I have been trying to replace Sendkeys with Sendmessage but I am having a few problems.
Example of old sendkeys code :
This code seems to work (sometimes)PHP Code:
App.Activate "Title of other application"
Sendkeys "^o" & "~", TRUE
Sendkeys "filename" & "~", TRUE
DoEvents
The Sendmessage code I am using is as follows :
My problem is that using the sendmessage changes the window caption/title of the other application instead of pass in the keystrokes.PHP Code:
Public Const WM_SETTEXT = &HC
Private Declare Function GetForegroundWindow _
Lib "user32" () As Long
Public Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
SetForegroundWindow otherapp.hWnd
SendMessage otherapp.hWnd, WM_SETTEXT, 0, By Val "^o"
SendMessage GetForegroundWindow, WM_SETTEXT, 0, By Val "filename"
What am I doing wrong or should I give up on sendmessage and stick to sendkeys?




Reply With Quote