SetCursorPos(xr,yr)
遂寧ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!
sleep (1000) '移動鼠標后加個延時 先加大一點的沒關系 ?測試有效后再縮短延時時間
其他行的sleep 也如此 再者你的leftdown 和 up 常量有先賦值吧
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Dim postion1 As New Point
mouse_event(H1 Or H8000, postion1.X * 65535 / 1366, postion1.Y * 65535 / 768, 0, 0)
'按絕對位置移動鼠標
'在鼠標坐標系統(tǒng)中,屏幕在水平和垂直方向上均勻分割成65535×65535個單元,
'當前所用顯示屏分辨率為1366*768
'所以要進行如上轉換
mouse_event(H2, 0, 0, 0, 0) '鼠標左鍵按下
mouse_event(H4, 0, 0, 0, 0) '鼠標左鍵彈起
msdn上有 mouse_event 的詳解,大致使用如上
調用api
在Visual Baisc.net中的聲明:
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = H2 '模擬鼠標左鍵按下
Public Const MOUSEEVENTF_LEFTUP = H4 ’模擬鼠標左鍵釋放
Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模擬鼠標中間鍵按下
Public Const MOUSEEVENTF_MIDDLEUP = H40 '模擬鼠標中間鍵釋放
Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模擬鼠標右鍵按下
Public Const MOUSEEVENTF_RIGHTUP = H10 '模擬鼠標右鍵釋放
Public Const MOUSEEVENTF_MOVE = H1 '模擬鼠標指針移動
例:
mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0
'在(10,10)模擬鼠標左鍵按下
1.在mouse事件中實現(xiàn)
2.調用windows API
實現(xiàn)方式為:
1.在mouse事件中實現(xiàn)
[csharp] view plain copy
Point mouseOff;//鼠標移動位置變量
bool leftFlag;//標簽是否為左鍵
private void groupControl1_MouseUp(object sender, MouseEventArgs e)
{
if (leftFlag)
{
leftFlag = false;//釋放鼠標后標注為false;
}
}
private void groupControl1_MouseMove(object sender, MouseEventArgs e)
{
if (leftFlag)
{
Point mouseSet = Control.MousePosition;
mouseSet.Offset(mouseOff.X, mouseOff.Y); //設置移動后的位置
Location = mouseSet;
}
}
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到變量的值
leftFlag = true; //點擊左鍵按下時標注為true;
}
}
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到變量的值
leftFlag = true; //點擊左鍵按下時標注為true;
}
}
2.調用windows API
調用前需要添加using System.Runtime.InteropServices;
[csharp] view plain copy
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture(); //釋放鼠標捕捉
//發(fā)送左鍵點擊的消息至該窗體(標題欄)
SendMessage(Handle, 0xA1, 0x02, 0);
}
}
當前標題:vb.net中mouse vb和vb net
網(wǎng)頁鏈接:http://vcdvsql.cn/article32/hehcpc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供服務器托管、、虛擬主機、云服務器、網(wǎng)站收錄、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)