چگونه می توان موس را با کد حرکت داد??
مثلا در موقع لود برنامه، موس از یک سمت به سمت دیگر مانیتور برود (بدون حرکت دادن آن)
Printable View
چگونه می توان موس را با کد حرکت داد??
مثلا در موقع لود برنامه، موس از یک سمت به سمت دیگر مانیتور برود (بدون حرکت دادن آن)
تابع SetCursorPos برای اینکار بکار میره! به MSDN رجوع کن اطلاعاتی خوبی بدست میاری!
من که چنین تابعی در Vb6 پیدا نکردم
میشه یه مثال بزنید
سلام.
api هست نه تابع ویبی.
کد:'This project needs 2 Buttons
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Dim P As POINTAPI
Private Sub Form_Load()
'KPD-Team 1998
'URL:'E-Mail: [ برای مشاهده لینک ، با نام کاربری خود وارد شوید یا ثبت نام کنید ]
کد:
http://www.allapi.net/
Command1.Caption = "Screen Middle"
Command2.Caption = "Form Middle"
'API uses pixels
Me.ScaleMode = vbPixels
End Sub
Private Sub Command1_Click()
'Get information about the screen's width
P.x = GetDeviceCaps(Form1.hdc, 8) / 2
'Get information about the screen's height
P.y = GetDeviceCaps(Form1.hdc, 10) / 2
'Set the mouse cursor to the middle of the screen
ret& = SetCursorPos(P.x, P.y)
End Sub
Private Sub Command2_Click()
P.x = 0
P.y = 0
'Get information about the form's left and top
ret& = ClientToScreen&(Form1.hwnd, P)
P.x = P.x + Me.ScaleWidth / 2
P.y = P.y + Me.ScaleHeight / 2
'Set the cursor to the middle of the form
ret& = SetCursorPos&(P.x, P.y)
End Sub
Private Declare Sub SetCursorPos Lib "User32" (ByVal X As Integer, _
ByVal Y As Integer)
Private Sub Command1_GotFocus()
X = (Form1.Left + Command1.Left + Command1.Width / 2 + 60) / Screen.TwipsPerPixelX
Y = (Form1.Top + Command1.Top + Command1.Height / 2 + 360) / Screen.TwipsPerPixelY
SetCursorPos X, Y
End Sub
خوبه قبل از پست دادن یک سرچ بزنی
براتون پول نمیندازه
خدا از دهنت بشنوهنقل قول:
چشم از این به بعد توی سایت سرچ می کنم اما...
(خدائیش سرچ سایت خیلی قوی نیست و معمولا به نتیجه مورد نظر نمی رسم)
مشکل از سرچ سایت نیست
مشکل اینه که معمولا کسی بلد نیست از سرچ استفاده کنه اما نمیدونم چرا من همیشه به نتیجه مورد نظر میرسم