|
-
Sep 21st, 1999, 08:11 PM
#1
Thread Starter
Lively Member
Does anyone know how to click a button using code. Probaly using the sendmessage command??
-
Sep 21st, 1999, 08:14 PM
#2
Lively Member
If it's a vb button, simply call the event procedure for that button!
For example, to click the cmdExit button on the current form use cmdExit_Click
-
Sep 22nd, 1999, 03:31 PM
#3
Thread Starter
Lively Member
It's another button in another application
-
Sep 22nd, 1999, 06:06 PM
#4
If you know the Window Handle (hWnd) for that button then you can use SendMessage API to do that:
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Public Sub ClickButton(hwnd As Long)
Call SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0)
Call SendMessage(hwnd, WM_KEYUP, VK_SPACE, 0)
End Sub
Usage: ClickButton ButtonHwnd
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
-
Jan 5th, 2000, 04:16 AM
#5
Hyperactive Member
I couldn't get Serge's code to work for a menu, though I'm using the correct menu handle (submenu actually).
Any ideas??
Thanks,
Wade
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
|