Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2004.07.11;
Скачать: [xml.tar.bz2];

Вниз

ПОдсажите,как управлять мышкой с клавиатуры??   Найти похожие ветки 

 
^G^   (2004-05-12 14:32) [0]

Подскажите!Мне нужно эмитировать как бы работу мышки с клавиатуры.Т.е. движение курсора стрелками,нажатие правой левой кнопки мыши задать с помощью кнопок клавы.
Но пожалуйста объясняйтесь пожалуйста понятней т.к. я в этом деле пока не разобралась.


 
Polevi ©   (2004-05-12 14:40) [1]

специальные возможности установи


 
wal ©   (2004-05-12 16:53) [2]

Нажми NumLock и держи 5 сек. нажатым.


 
^G^   (2004-05-12 21:23) [3]

Ну вы даете.Это форум по делфи api .Я спрашиваю как на делфи это с помощью винапи написать.


 
Gallant   (2004-05-12 21:52) [4]

по моему mouse_event  подоидет


 
^G^   (2004-05-12 23:39) [5]

"Но пожалуйста объясняйтесь пожалуйста понятней т.к. я в этом деле пока не разобралась."
Спасибо, но к моему сожалению мне это ничего не говорит.Помоему если уж взялся что-то подсказать значит хочется помоч ,чтоб был результат, так надо выразить так чтоб хоть немного было понятно,я же написала что чайник.
Извените уж.


 
Игорь Шевченко ©   (2004-05-13 13:20) [6]


> я же написала что чайник.


Книжки - рулез фарева


 
Klev   (2004-05-14 00:14) [7]

1) Надо отлавливать нажатия клавиш (стрелок) с помощью хуков(WH_KEYBOARD)см. FAQ. Перемещение указателя мыши осуществляется с помощью mouse_event(MOUSEEVENTF_MOVE , x, y,0,0); x,y - координаты куда надо сдвинуть курсор.
А вот выдержка из W32 programmer"s reference:
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.



Return Values

This function has no return value.

Remarks

If the mouse has moved, indicated by MOUSEEVENTF_MOVE being set, dx and dy hold information about that motion. The information is given as absolute or relative integer values.
If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner.

If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify relative motions from when the last mouse event was generated (the last reported position). Positive values mean the mouse moved right (or down); negative values mean the mouse moved left (or up).
Relative mouse motion is subject to the effects of the mouse speed and the two mouse threshold values. In Windows NT, an end user sets these three values with the Mouse Tracking Speed slider of Control Panel"s Mouse option; in Windows 95, an end user sets them with the Pointer Speed slider of the Control Panel"s Mouse property sheet. An application obtains and sets these values with the SystemParametersInfo function.

The operating system applies two tests to the specified relative mouse motion. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse speed is not zero, the operating system doubles the distance. If the specified distance along either the x or y axis is greater than the second mouse threshold value, and the mouse speed is equal to two, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply relatively-specified mouse motion along the x or y axis by up to four times.

The mouse_event function is used to synthesize mouse events by applications that need to do so. It is also used by applications that need to obtain more information from the mouse than its position and button state. For example, if a tablet manufacturer wants to pass pen-based information to its own applications, it can write a dynamic-link library (DLL) that communicates directly to the tablet hardware, obtains the extra information, and saves it in a queue. The DLL then calls mouse_event with the standard button and x/y position data, along with, in the dwExtraInfo parameter, some pointer or index to the queued extra information. When the application needs the extra information, it calls the DLL with the pointer or index stored in dwExtraInfo, and the DLL returns the extra information.

See Also

GetMessageExtraInfo, SystemParametersInfo


 
имя   (2004-05-14 00:28) [8]

Удалено модератором


 
^G^   (2004-05-15 14:18) [9]

Спасибо будем пытаться разобраться в написанном.(:(::(:(:))


 
Diamond Cat ©   (2004-05-17 01:37) [10]

перемещать курсор setcursorpos
нажатие кнопок мыши
sendmessage(windowfrompoint...wm_l/r/m/и т.д. buttondown
или
sendinput


 
Rouse_ ©   (2004-05-17 01:43) [11]

> buttondown
Угу, главное buttonup не забыть - это если "нажатие кнопок" ;)


 
^G^   (2004-05-20 22:18) [12]

Спасибо вам большое за помощь. а можно для начала,вот как вообще что нужно чтоб прога работала в самом винд ,т.е. обычно унас открывается какое-то окно проги а тут ведь его не должно быть.Мне сложно понять то что вы написали,я не знаю с чего начать как применить написанное вами.
Я не знаю английского, :%(:(:(:(::(


 
LMD ©   (2004-05-21 01:14) [13]


> а можно для начала,вот как вообще что нужно чтоб прога работала
> в самом винд ,т.е. обычно унас открывается какое-то окно
> проги а тут ведь его не должно быть.Мне сложно понять то
> что вы написали,я не знаю с чего начать как применить написанное
> вами.


Тогда может быть рано исходную задачу решать ?


 
^GENTLY^   (2004-05-21 19:03) [14]

Я не знаю с чего мне начать.
С предыдущими задачами я тоже справлялась на примере лаб ,вернее лабы и были задачами но на их основании я и разбиралась.
А тут прям тупик, читая про Апи я не могу решить эту задачу.


 
LMD ©   (2004-05-21 21:25) [15]

Вот пример на VCL, если поймешь суть, можно и на API переписать:
(Только перемещение курсора)


unit main;

interface
uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms;

type
 TForm1 = class(TForm)
   procedure FormKeyDown(Sender: TObject; var Key: Word;
     Shift: TShiftState);
   procedure FormCreate(Sender: TObject);
 private
   FCursorPos: TPoint;
   procedure ChangeCursorPos;
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
 Shift: TShiftState);
begin
 case Key of
 VK_LEFT:
   Dec(FCursorPos.X);
 VK_RIGHT:
   Inc(FCursorPos.X);
 VK_UP:
   Dec(FCursorPos.Y);
 VK_DOWN:
   Inc(FCursorPos.Y);
 else
   Exit;
 end;
 Key := 0;
 ChangeCursorPos;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 FCursorPos := ClientToScreen(Point(ClientWidth div 2, ClientHeight div 2));
 ChangeCursorPos;
end;

procedure TForm1.ChangeCursorPos;
begin
 SetCursorPos(FCursorPos.X, FCursorPos.Y);
end;

end.


Свойство KeyPreview у форму установлено в True.

Удачи!


 
^GENTLY^   (2004-05-24 17:16) [16]

Спасибо большое.
Попробовала работает только на форме.Чтоб без активной формы работало надо для этого ВинАпи да?НУжно хуки ставить говорят, только как?никак не разбирусь.


 
Игорь Шевченко ©   (2004-05-24 17:45) [17]

^GENTLY^   (24.05.04 17:16)

А в чем, собственно, состоит задача ? Чтобы во всей системе перемещение курсора выполнялось с клавиатуры, а не мышью ?


 
^GENTLY^   (2004-05-24 17:59) [18]

Да и не только перемещение курсора,но и теже действия, что происходят по нажатию на правую и левую кнопку мышки должны происходить по нажатию на опр.кнопку на клавиатуре.Напр. правая + левая - лево право вверх вниз -курсоры.


 
Игорь Шевченко ©   (2004-05-24 18:19) [19]

^GENTLY^   (24.05.04 17:59)

Не вижу смысла изобретать Accessability, это не такая простая задача, и непонятно, какой смысл в этом. На всякий случай - взаимодействие с Accessability происходит через функцию SetWinEventHook


 
^GENTLY^   (2004-05-24 18:56) [20]

Accessability хм,а что это?
Может вы знаете сайт где можно найти информацию о хуке,что это и как пользоваться.Ведь стправка на английском.


 
Игорь Шевченко ©   (2004-05-24 19:05) [21]


> Accessability хм,а что это?


В русской версии Windows "Специальные возможности".

Я бы хотел узнать ответ на вопрос "зачем это нужно?"


 
^GENTLY^   (2004-05-24 20:21) [22]

Я студентка, и это лабораторная по Api ,нужно сделать такую прогу.
Скажите ,а если делать перемещение курсора  не во всей системе,а только в опр.программе там используются Api ф-и, а если во всей системе ,то WinApi? Если так должно быть мне надо реализовать только в опр .проге.А значит наверно не надо хук ставить и напимер перемещение курсора можно сделать с помощью  SetCursorPos(FCursorPos.X, FCursorPos.Y) ведь это Ари ф-я??Но как тогда эмитировать нажатие пр лв кнопок.???


 
^GENTLY^   (2004-05-24 20:25) [23]

Удалено модератором
Примечание: Дубль


 
^GENTLY^   (2004-05-30 23:57) [24]

Help!!!


 
Iraizor ©   (2004-05-31 11:07) [25]

^GENTLY^
вообще-то эмулировать нажатие кнопки в пределах формы можно оч просто :
допустим юзер нажал на кнопку vk_F1  тогда проверяются текущие координаты курсора и если они совпадают с координатоми какой либо-кнопки х+_ длина у+_ширина ,то можно просто вызывать процедуру обработки нажатия кнопы +) примитивно и не эффективно , когда на форме 10^2 кнопок ++) ,но в принципе при инициализации проги мона заносить в массивы координаты кнопки , и прочую ерунду, а потом брать оттуда.
РS
WinApi - Windows Application Program Interface , вроде


 
^GENTLY^   (2004-05-31 18:13) [26]

Ой а какой функцией сделать чтоб отображалось такоеже меню как при нажатии правой кнопки мышки.


 
IraiZor ©   (2004-05-31 19:19) [27]

то же что из кнопкой ,тока не нужна проверка на координаты.



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2004.07.11;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.52 MB
Время: 0.031 c
9-1079371772
Юрий Ж.
2004-03-15 20:29
2004.07.11
Что лучше DirectX или OpenGL?


1-1087971630
BorisMor
2004-06-23 10:20
2004.07.11
XML парсер


1-1088368968
juiceman
2004-06-28 00:42
2004.07.11
Delphi Script


3-1087287584
Паниковский
2004-06-15 12:19
2004.07.11
Insert


14-1087986481
Tornado
2004-06-23 14:28
2004.07.11
Программы не запускаются....что за глюк???





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский