|
-
Dec 22nd, 2008, 06:51 PM
#1
Thread Starter
Lively Member
[2008] Api Wm_settext
Code:
Public Class Form1
Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As String) As Int32
Public Const WM_SETTEXT As Int32 = &HC
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSEND.Click
Dim hWnd As Int32 = FindWindow("#32770", vbNullString)
If hWnd > 0 Then
Dim hWndChild As Int32 = FindWindowEx(hWnd, 0, "ATL:00B4C870", vbNullString)
If hWndChild > 0 Then
MsgBox("Found!") ' Check to see if it is working
Dim strText As String = textbox1.Text
SendMessage(hWndChild, WM_SETTEXT, 0, strText)
End If
End If
End Sub
End Class
This is working fine for, however my question is now... how do I make it press a button.
http://img399.imageshack.us/my.php?image=btnqa6.jpg
Above is the properties of the button.
Thanks guys!!
-
Dec 22nd, 2008, 11:42 PM
#2
Re: [2008] Api Wm_settext
I assume your question is how do i click a button using sendMessage
there are two ways,
1. Sending WM_LBUTTON Down
2. Sending a BM_CLICK
Code:
SendMessage(buttonHnd, BM_CLICK, 0,0)
-
Dec 22nd, 2008, 11:43 PM
#3
Thread Starter
Lively Member
Re: [2008] Api Wm_settext
What if I want to click a popup menu and select something on it... what would that use?
-
Dec 27th, 2008, 06:23 PM
#4
Re: [2008] Api Wm_settext
 Originally Posted by Fazi
I assume your question is how do i click a button using sendMessage
there are two ways,
1. Sending WM_LBUTTON Down
2. Sending a BM_CLICK
Code:
SendMessage(buttonHnd, BM_CLICK, 0,0)
Fazi, if the Button you want to click is already selected (the default) that code alone won't actually click the button but will only highlight it.
To test, lets say one VB program launches this,
rsp = MsgBox("Copy all files?", vbYesNo + vbDefaultButton1, "Copy All?")
Now in the other VB program tell it to click the "Yes" button (which is the selected/default) , notice the button will only get highlighted and not clicked!
Here's the fix,
Code:
SendMessage buttonHnd, WM_ACTIVATE, WA_ACTIVE, 0
SendMessage buttonHnd, BM_CLICK, 0, 0
hope that helps someone, it drove me nuts for a long time.
-
Dec 28th, 2008, 01:44 AM
#5
Re: [2008] Api Wm_settext
Thanks Edgemel for the useful tips,
i got very useful informations from your last few post in various threads. but i cold not rate you coz "Spread some points to some one else before give it to edgemel" it says.
Need to find a JS code to unlock this limitation
-
Jan 2nd, 2009, 08:47 AM
#6
New Member
Re: [2008] Api Wm_settext
RedGunner, thanks for your post, helped me a bit.
Are there any wMsg parameters for appending text to the hWnd?
-
Jan 3rd, 2009, 07:14 AM
#7
Re: [2008] Api Wm_settext
 Originally Posted by forcumang
RedGunner, thanks for your post, helped me a bit.
Are there any wMsg parameters for appending text to the hWnd?
forcumang, it would be better if you will start a thread of yours so the responses would be directed to you. I am not sure about appending but I using WM_GETTEXT to get the current text should be one option, after you have received the current text then you could just append a text to it then use WM_SETTEXT.
-
Jan 3rd, 2009, 07:19 AM
#8
New Member
Re: [2008] Api Wm_settext
 Originally Posted by dee-u
forcumang, it would be better if you will start a thread of yours so the responses would be directed to you. I am not sure about appending but I using WM_GETTEXT to get the current text should be one option, after you have received the current text then you could just append a text to it then use WM_SETTEXT.
perfect, thanks
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
|