Hello All ..
I'm Trying to Click a Button In Another Application With Process Name "CenterBot"
I have got ListView1 , Button1 , Button2
Here's my code - Imports System.Runtime.InteropServices
-
Public Class Form1
-
-
Private Const BM_CLICK = &HF5
-
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As IntPtr, ByVal wMsg As UInteger, ByVal wParam As UInteger, ByVal lParam As UInteger) As UInteger
-
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Integer, ByVal lpWindowName As String) As Int32
-
-
Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
-
ByVal hWndParent As IntPtr, _
-
ByVal hWndChildAfter As IntPtr, _
-
<MarshalAs(UnmanagedType.LPTStr), [In]()> ByVal lpszClass As String, _
-
<MarshalAs(UnmanagedType.LPTStr), [In]()> ByVal lpszWindow As String _
-
) As IntPtr
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
ListView1.Items.Clear()
-
For Each x As Process In Process.GetProcessesByName("CenterBot")
-
-
Dim A = ListView1.Items.Add(x.ProcessName)
-
A.SubItems.Add(x.MainWindowTitle)
-
A.SubItems.Add(x.Id)
-
End If
-
Next
-
End Sub
-
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
On Error Resume Next
-
If ListView1.SelectedItems.Count = 0 Then
-
MessageBox.Show("Choose Your Process For the list", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
-
Else
-
Dim HWND As Integer = FindWindow(0, ListView1.SelectedItems.Item(0).SubItems(1).Text)
-
If HWND = 0 Then
-
MessageBox.Show("Choose Your Process For the list", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
-
Exit Sub
-
Else
-
Dim ChildWndHandle As IntPtr
-
-
-
ChildWndHandle = FindWindowEx(HWND, IntPtr.Zero, "WindowsForms10.BUTTON.app.0.2bf8098_r13_ad1", "Button Text")
-
MsgBox(ChildWndHandle)
-
SendMessage(ChildWndHandle, BM_CLICK, 1, 0)
-
End If
-
End If
-
End Sub
-
End Class
-
This Code is working well if the button on the form
but the button in a groupbox
also the groupbox in a TabControl !!
Hope i get helped here ;)
0 1221 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: [Yosi] |
last post by:
I search solution for a little bit strange problem , I working on an
application which includes a button.
Click on this button will create number of threads each one execute deferent
executable...
|
by: Steve |
last post by:
Hi,
Is it possible to make hitting the enter key in an ASP
textbox run the code behind an ASP button on a form?
I have a search page which users tend to type in the
query then just hit enter...
|
by: Agnes |
last post by:
In myForm, i need to let user just click one button and then Start another
application .
Does anyone know how to do ??
Thanks a lot.
|
by: Linda |
last post by:
If I wanted a VB application to find the edit box of another, external
application, and enter text into this edit box, how would I go about
doing this?
How do I get the handle for a specific...
|
by: DBC User |
last post by:
Hello,
I would like to know how can I start another application that is
installed in the PC from another running application? Both the
applications are installed through click once so I can not...
| |
by: Terry Olsen |
last post by:
Is there any way for my app to capture a keypress or a button click from
another app? I need my app to be able to catch the click before the
other app and process the click or keypress instead.
...
|
by: rayne |
last post by:
hi pls help me on how to open another application by clicking a button. What I want to do is when I click a button, another application will open. thanks
|
by: eddie69 |
last post by:
Hi,
Newbie question here:
I am creating an application in VB Studio 2005 which reads the status of an USB PIR Motion sensor.
So far, I have managed to get the application to read the motion...
|
by: Thammarat charoenchai. |
last post by:
Hi, I'm try to learn vb.net.
in delphi have .click method for click button by coding.
Can I do that with vb.net
Thank you very much.
|
by: Paulers |
last post by:
Hello,
I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |