VB.Net Mouse (Fare) tıklandığında ki Koordinatları Alma ?

Katılım
2 Mart 2018
Mesajlar
101
Excel Vers. ve Dili
excel 2016
Altın Üyelik Bitiş Tarihi
31-01-2024
Kolay gelsin herkese, basit bir tekrarlayıcı exe yapıyorum kendime ancak mouse (fare) nin windows ekranında tıklandığında ki koordinatlarını almam gerekiyor. Form içerisinde ki tıklamalarda ki koordinatları alabiliyorum ancak windows ekranında ki tıklamaların koordinatlarını alamıyorum malesef bir türlü beceremedim. Yardımcı olablirmisiniz lütfen şimdiden teşekkürler
 
Katılım
20 Şubat 2012
Mesajlar
242
Excel Vers. ve Dili
office2007 Türkçe
Bakınız


Belki bu....



Kod:
 ' Access the GetCursorPos function in user32.dll
Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
' Access the GetCursorPos function in user32.dll
Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long

' GetCursorPos requires a variable declared as a custom data type
' that will hold two integers, one for x value and one for y value
Type POINTAPI
    X_Pos As Long
    Y_Pos As Long
End Type

' Main routine to dimension variables, retrieve cursor position,
' and display coordinates - ctrl and q is shortcut
Sub Get_Cursor_Pos()
   
     ' Dimension the variable that will hold the x and y cursor positions
    Dim Hold As POINTAPI
   
     ' Place the cursor positions in variable Hold
    GetCursorPos Hold
   
     ' Display the cursor position coordinates
    MsgBox "X Position is : " & Hold.X_Pos & Chr(10) & _
    "Y Position is : " & Hold.Y_Pos
End Sub
 
Katılım
2 Mart 2018
Mesajlar
101
Excel Vers. ve Dili
excel 2016
Altın Üyelik Bitiş Tarihi
31-01-2024
Bakınız


Belki bu....



Kod:
 ' Access the GetCursorPos function in user32.dll
Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
' Access the GetCursorPos function in user32.dll
Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long

' GetCursorPos requires a variable declared as a custom data type
' that will hold two integers, one for x value and one for y value
Type POINTAPI
    X_Pos As Long
    Y_Pos As Long
End Type

' Main routine to dimension variables, retrieve cursor position,
' and display coordinates - ctrl and q is shortcut
Sub Get_Cursor_Pos()
 
     ' Dimension the variable that will hold the x and y cursor positions
    Dim Hold As POINTAPI
 
     ' Place the cursor positions in variable Hold
    GetCursorPos Hold
 
     ' Display the cursor position coordinates
    MsgBox "X Position is : " & Hold.X_Pos & Chr(10) & _
    "Y Position is : " & Hold.Y_Pos
End Sub
Hocam malesef olmadı. Declare'lerde hata veriyor eklediğimde ve Type Poınyapı'da aynı şekilde hata veriyor.

Kod:
Private Sub Form3_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick

        TextBox2.Text = e.Location.ToString()
        End Sub
bu kod ile form içerisinde iken tıklama yaptığımda koordinatları alabiliyorum ancak form içerisini veriyor sadece. Bana herhangi bir yerin tıklamasında ki kodlar lazım.

Kod:
If System.Windows.Forms.MouseButtons.Left Then
TextBox2.Text = MousePosition.ToString
End If
bu kod ile istediğim koordinatı almayı başardım teşekkür ederim tekrardan paylaştığın kod için .
 
Son düzenleme:
Üst