3
我正在編寫一個收集信息的簡單程序。諸如鼠標xy座標,像素顏色和擊鍵數字之類的東西。我希望能夠在屏幕上的任何位置查看光標的x和y座標,而不僅僅是在窗體上,我希望以最簡單的方式執行此操作。我已經實現所希望的效果的一種方法是使用以下設置:VB.net - 在表單外部獲取鼠標座標
Picturebox2:
- 背景色=紅
- 圖像= 3×2像素的圖像(幾乎不可見,但需要所有相同)
Form1中:
- 透明度鍵=紅
這會導致在光標位於窗體邊界之外時顯示鼠標座標的顯示。然而它仍然在形式上。我使用這個特殊問題的代碼是:
Dim mouseloc As Point
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
mouseloc = Cursor.Position
lblc.Text = PointToClient(mouseloc).ToString
lbls.Text = PointToScreen(mouseloc).ToString
End Sub
Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
mouseloc = Cursor.Position
lblc.Text = PointToClient(mouseloc).ToString
lbls.Text = PointToScreen(mouseloc).ToString
End Sub
林在Windows 7 64位系統運行Visual Studio 2010索尼VAIO
如果你曾想過它,你可以發佈答案,我正在尋找同樣的東西,thx – Vahx