api函数SetCursorPos可以设置光标的坐标,从而实现移动光标到指定的屏幕坐标上。
它的语法如下
1 2 3 4 |
BOOL WINAPI SetCursorPos( _In_ int X, _In_ int Y ); |
其中X、Y参数分别是光标的新的X、Y屏幕坐标。
如下代码可以把光标移动到指定的屏幕坐标上。
1 2 3 4 5 6 7 8 |
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub QQ1722187970() Sleep 1000 x = Sheet1.Range("A1") y = Sheet1.Range("b1") SetCursorPos x, y End Sub |
发表评论