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