Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C++ Builder > имитация клика мыши


Автор: ano360 1.2.2007, 19:46
как сообщить компу, что якобы была нажата клавиша мыши.

sandmasage(а тут что?);

Автор: _hunter 1.2.2007, 20:47
смотри mouse_event/SendInput

Автор: Romikgy 1.2.2007, 20:49
Цитата

WM_LBUTTONUP  
fwKeys = wParam;        // key flags 
xPos = LOWORD(lParam);  // horizontal position of cursor 
yPos = HIWORD(lParam);  // vertical position of cursor 
WM_CAPTURECHANGED
WM_LBUTTONDBLCLK
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_MBUTTONDBLCLK
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MOUSEACTIVATE
WM_MOUSEMOVE
WM_MOUSEWHEEL
WM_NCHITTEST
WM_NCLBUTTONDBLCLK
WM_NCLBUTTONDOWN
WM_NCLBUTTONUP
WM_NCMBUTTONDBLCLK
WM_NCMBUTTONDOWN
WM_NCMBUTTONUP
WM_NCMOUSEMOVE
WM_NCRBUTTONDBLCLK
WM_NCRBUTTONDOWN
WM_NCRBUTTONUP
WM_RBUTTONDBLCLK
WM_RBUTTONDOWN
WM_RBUTTONUP 

+
mouse_event

Автор: ano360 1.2.2007, 20:52
А можно пример.
Что конкретно надо набрать.

Автор: Romikgy 1.2.2007, 21:04
Код

mouse_event(MOUSEEVENTF_LEFTDOWN/*+MOUSEEVENTF_ABSOLUTE*/, x,y,0,0);
mouse_event(MOUSEEVENTF_LEFTUP    /*+MOUSEEVENTF_ABSOLUTE*/, x,y,0,0);

должно работать , но писал здесь

Автор: ano360 1.2.2007, 21:14
а что значит /*+MOUSEEVENTF_ABSOLUTE*/?

Автор: Romikgy 1.2.2007, 21:17
у тя МСДН есть? посмотри
ну или на сайт мсдн залезь
Цитата

The mouse_event function synthesizes mouse motion and button clicks. 

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
   );    
 

Parameters

dwFlags

A set of flag bits that specify various aspects of mouse motion and button clicking. The bits in this parameter can be any reasonable combination of the following values: 

Value    Meaning
MOUSEEVENTF_ABSOLUTE    Specifies that the dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
MOUSEEVENTF_MOVE    Specifies that movement occurred.
MOUSEEVENTF_LEFTDOWN    Specifies that the left button changed to down.
MOUSEEVENTF_LEFTUP    Specifies that the left button changed to up.
MOUSEEVENTF_RIGHTDOWN    Specifies that the right button changed to down.
MOUSEEVENTF_RIGHTUP    Specifies that the right button changed to up.
MOUSEEVENTF_MIDDLEDOWN    Specifies that the middle button changed to down.
MOUSEEVENTF_MIDDLEUP    Specifies that the middle button changed to up.
MOUSEEVENTF_WHEEL    Windows NT only: Specifies that the wheel has been moved, if the mouse has a wheel. The amount of movement is given in dwData
 

The flag bits that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released. 

dx

Specifies the mouse's absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse's actual x-coordinate; relative data is given as the number of mickeys moved. 

dy

Specifies the mouse's absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse's actual y-coordinate; relative data is given as the number of mickeys moved. 

dwData

If dwFlags is MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
If dwFlags is not MOUSEEVENTF_WHEEL, then dwData should be zero.

dwExtraInfo

Specifies an additional 32-bit value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information. 

Автор: ano360 1.2.2007, 21:18
[C++ Error] Unit1.cpp(38): E2451 Undefined symbol 'x'
[C++ Error] Unit1.cpp(38): E2451 Undefined symbol 'y'

Автор: Romikgy 1.2.2007, 21:20
Цитата(ano360 @  1.2.2007,  20:18 Найти цитируемый пост)
[C++ Error] Unit1.cpp(38): E2451 Undefined symbol 'x'
[C++ Error] Unit1.cpp(38): E2451 Undefined symbol 'y'

вау smile
это переменные куда кликнуть надо , я же уже привел полный хелп по этой ф_ции

Автор: ano360 1.2.2007, 21:20
как получить кординаты положения  курсора в данный момент времяни?

Автор: Romikgy 1.2.2007, 21:24
ano360, залезь в мсдн
а?
Цитата

The GetCursorPos function retrieves the cursor's position, in screen coordinates. 

BOOL GetCursorPos(

    LPPOINT lpPoint  // address of structure for cursor position  
   );    
 

Parameters

lpPoint

Points to a POINT structure that receives the screen coordinates of the cursor. 

 

Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The cursor position is always given in screen coordinates and is not affected by the mapping mode of the window that contains the cursor. 
The calling process must have WINSTA_READATTRIBUTES access to the window station. 

Автор: ano360 1.2.2007, 21:35
что такое мсдн?
какой у него сайт?

спасибо!!!!

посмотрите пож. ещё и эту тему:
http://forum.vingrad.ru/topic-34677.html

Автор: Romikgy 1.2.2007, 21:45
http://www.google.com.ua/search?q=MSDN+&ie=utf-8&oe=utf-8&rls=org.mozilla:ru:official&client=firefox-a

Автор: W4FhLF 2.2.2007, 19:49
передавай ноль в x,y, если не хочешь менять положение курсора и сделай паузу между вызовами этих функций.

Автор: HappyLife 9.2.2007, 13:03
[deleted]

Автор: stmamont 9.2.2007, 17:33
Такой вопрос: как узнать координаты курсора в абсолютных координатах?


Приходилось двигать используя TMouse::CursorPos (потому что он использует пиксельные коородинаты) и кликать используя mouse_event

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)