Hello everybody!
I would like to click a button or menu from my application (like a BuzOf). I have only handle (by FindWindowEx). How to do it?
-----------
Thanks,
Johnny (753187 sec. to 15th birthday:D!)
Printable View
Hello everybody!
I would like to click a button or menu from my application (like a BuzOf). I have only handle (by FindWindowEx). How to do it?
-----------
Thanks,
Johnny (753187 sec. to 15th birthday:D!)
You can use the SendMessag API but I can't tell you how unless I know exactly what you're trying to do.
If you post more Details I'll see if I can Help.
OK. I would like to monitore the window and press any button in it, when it shows.
For example:
I will be looking by FindWindow to 'Security warning' window (showed by IE when recieving a cookie). When I found it, I would like to press a 'More Details' button (by my application, of course).
Who is friendly with BuzOf (www.basta.com) knows what I want.
Or:
I would like to change a 'Show images' option in IE accesing the registry. Then, if an instance of IE is running, press the View/Refresh menu. Please do not help me with such things like SendKeys "{F5}". I need to run any of menu items in various applications.
If it is clear, now, please help me...
----------------
Thanks,
Johnny (677428 sec. to 15th birhtday:D!)
Well, assuming you have got the windowhandle (lets call it hWind), you can send the WM_LBUTTONDOWN message followed by a WM_LBUTTONUP message
Edited by Frans C on 03-17-2000 at 02:51 PMCode:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Sub Command1_Click()
Dim retVal as long
retVal = SendMessage(hWind, WM_LBUTTONDOWN, 0&, &H10001) ' we click at an offset of 1 pixel by 1
retVal = SendMessage(hWind, WM_LBUTTONUP, 0&, &H10001)
End Sub
This works well, but only if the window is enabled. I need to call its click subroutine, even it is disabled.
?
----------
Thanks,
John (406655 sec. to 15th birthday:D!)
Can this be used to select a menu that's in another app? I need to select the Edit menu from another app. I have the correct handle but GetLastError returns 1400 (Invalid Window Handle). Is that because it's a menu?
Thanks,
Wade
To enable item do this (change "TITLE" to app's title):
w = FindWindow(vbNullString, "TITLE")
m = GetMenu(w)
sm = GetSubMenu(m,2) 'Change 2 to &Edit's index
'first submenu is 0
'first submenu can be an icon in MDI app(!)
EnableMenuItem sm, its index, &H400 or &H0
You type select; would you like to click the whole Edit menu or run a specified item? To run item, use SendMessage.
-----------------
To my problem:
Is done :)
1. the do..loop method helped
2. as well (maybe not so) as SendMesage
I'd like to select the whole Edit menu. I can use SendMessage to select it, but I need to dropdown the menu instead. That's when it enables/disables its submenus.
Thanks,
Wade