- This topic has 4 replies, 2 voices, and was last updated 10 years ago by Chike.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
April 24, 2014 at 2:03 pm #186506AdminAdministrator
How to click on an external app button 🙂 Just working on something and needed to save this code lol
DelarePrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Const WM_COMMAND As Integer = &H111S Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As Integer, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr Private Const BM_CLICK = &HF5
Call it with
x = FindWindow("#32770", vbNullString) button = FindWindowEx(x, 0&, "button", vbNullString) button = FindWindowEx(x, button, "button", vbNullString) SendMessage(button, BM_CLICK, 1, 0)
April 24, 2014 at 2:22 pm #186510ChikeMemberWhat external app window exactly?
Serching the button by it’s control id would probably be better  and send the main window WM_COMMAND instead the BM_CLICK to the button.
Are you on Windows 7 or XP? I think there may be some hidden #32770 class windows
April 24, 2014 at 6:27 pm #186509AdminAdministratorApril 24, 2014 at 8:20 pm #186508ChikeMemberWell boith are controls with unique ID so easy to find with the same methid we use to find room controls.
Make sure you get the right controls by checking their text.
Then you can try to enable them and do whatever.
April 25, 2014 at 1:36 am #186507AdminAdministratorYea, I’m going to check it in the future when i go back to the project. Thanks
-
AuthorPosts
Related
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.