- UID
- 240679
- 帖子
- 286
- 主題
- 57
- 精華
- 0
- 積分
- 252
- 楓幣
- 284
- 威望
- 250
- 存款
- 382
- 贊助金額
- 0
- 推廣
- 0
- GP
- 72
- 閱讀權限
- 30
- 在線時間
- 47 小時
- 註冊時間
- 2018-7-14
- 最後登入
- 2023-9-8
|
本帖最後由 Beebong 於 2019-11-12 00:45 編輯
小弟獻醜,大佬見笑了。
需要物件:PictureBox(Iamge記得放圖) *1 、Label *1
方案專案->專案->Resources 記得放.ico
Module:
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Integer, ByVal yPoint As Integer) As IntPtr
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As UInteger, ByRef lpdwProcessId As IntPtr) As IntPtr
Dim PhandleA As IntPtr
Public Structure POSSITION
Dim X As Single
Dim Y As Single
End Structure
Public Function WindowPointXY(ByVal xPoint As UInteger, ByVal yPoint As UInteger) As UInteger
Dim hwnd As UInteger
Dim PidPoint As UInteger
hwnd = WindowFromPoint(xPoint, yPoint)
GetWindowThreadProcessId(hwnd, PidPoint)
Return PidPoint
End Function
Form:
Private Sub PictureBox1_MouseDown(sender As Object, e As System.windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
PictureBox1.Cursor = New Cursor(New Bitmap(My.Resources.Bee).GetHicon())
PictureBox1.Image = Nothing
End Sub
Private Sub PictureBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Phandle = WindowPointXY((Windows.Forms.Cursor.Position.X), (Windows.Forms.Cursor.Position.Y))
PictureBox1.Image = My.Resources.Bee
PictureBox1.Cursor = Cursors.Arrow
Label1.Text = "讀取到的進程名稱:" & Process.GetProcessById(Phandle).ProcessName
End Sub
如果執行上有問題請回覆告知,我是直接把以前寫的專案片段Code貼上來
|
|