منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[كود] ScreenToClient(PictureBox1 .Handle, mPos) - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [كود] ScreenToClient(PictureBox1 .Handle, mPos) (/showthread.php?tid=13801)



ScreenToClient(PictureBox1 .Handle, mPos) - أسامة - 12-11-15

استعمل SetParent لاظهار Notepad فى PictureBox1 اريد عند الضغط على ال PictureBox1 يضغط فى notepad استعمل هذا الكود

كود :
ScreenToClient(PictureBox1 .Handle, zPos)

يظهر هذا الخطاء
إقتباس :Additional information: A call to PInvoke function 'WindowsApplication1!WindowsApplication1.Form1::ScreenToClient' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

If there is a handler for this exception, the program may be safely continued.



RE: ScreenToClient(PictureBox1 .Handle, mPos) - أسامة - 13-11-15

تم الحل الحمد الله
Dim mPos As POINTAPI
Dim PosX As Long
Dim PosY As Long

' The position in picture box you want to click
PosX = 50 ' 50 pix from left
PosY = 100 ' 100 from top

' find X Y of picture box
ScreenToClient(PictureBox1.Handle.ToInt32, mPos)

' move cursor
SetCursorPos(PosX + Abs(mPos.x), PosY + Abs(mPos.y))


'Click
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)