-1

我想找到我的应用程序的中心。请在说 Me.Width / 2 之前阅读。

我正在加载一个网页,其中包含一个基于 Java 的应用程序,并且希望在页面加载后自动单击“登录”按钮。VB 应用程序是固定大小的,但不会最大化,允许用户在屏幕上移动应用程序。我在想的是做类似的事情..

SetCursorPos({CenterOfApp.Width} + 20, {CenterOfApp.Height})

..然后模拟鼠标点击。

帮助将不胜感激,谢谢!

编辑 1 - 我相信答案可能在下面,我只是不确定所需的公式。我再说一遍,这是一个固定大小的 VB.net 应用程序,加载一个固定大小的 Java 应用程序会抛出 VB.net 浏览器控件。该按钮将始终位于 VB.net 应用程序的同一位置,但 VB.net 应用程序不会始终位于计算机屏幕的同一位置。意思是,我需要根据 VB.net 应用程序在计算机屏幕上的位置找到它的中心。

Dim ScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim ScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim ClientLeft As Integer = Me.Location.X
Dim LeftOfScreenToApp As Integer ' This is to be the distance from the left side of the screen to the left side of the VB app.
LeftOfScreenToApp = ...
SetCursorPos(LeftOfScreenToApp + (Me.Width / 2) + 20, Me.Height / 2)
4

1 回答 1

0

碰巧我只是忽略了 Me.Location.X 是从屏幕左侧到 VB.net 应用程序左侧的偏移量,所以..

Dim LeftOfScreenToLeftOfApp As Integer = Me.Location.X
Dim MiddleOfApp As Integer = LeftOfScreenToLeftOfApp + Me.Width / 2

..获取应用程序的中心,无论它位于屏幕上的哪个位置。

于 2013-03-02T00:17:10.010 回答