Hej
jeg ønsker at lave en appikation, der gør at musen flytter sig og klikker på nogen faste X og Y kordinater. (skal kunne ske hurtigt) Men jeg er lidt i tivl om hvordan jeg kommer "ind" og tager "fat" i den del, der flytter musen?
Her har Windows et API kald:
BOOL SetCursorPos(
int X, // horizontal position
int Y // vertical position
);
Eller VB deklerationen:
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Dette skal blot kaldes med x,y koordinaterne.
Hvis du stadig mangler at klikke musen:
VOID mouse_event(
DWORD dwFlags, // flags specifying various motion/click variants
DWORD dx, // horizontal mouse position or position change
DWORD dy, // vertical mouse position or position change
DWORD dwData, // amount of wheel movement
DWORD dwExtraInfo // 32 bits of application-defined information
);
VB:
Public 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)
Du får lige et læs konstanter med:
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
Og for at klikke(venstre):
Sub LeftClick()
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) 'Sænker knappen
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 'Løfter knappen
End Sub
Hvis du vil dobbeltklikke skal du så kalde Sub'en 2 gange inden for "GetDoubleClickTime()" ms
Mvh,
Thomas