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

Вниз

SetCursorPos(x, y); не работает в игре   Найти похожие ветки 

 
InfectedM   (2007-12-24 13:01) [0]

SetCursorPos(x, y); перемещает курсор на заданную точку,

Почему в Windows Работает а в играх нет?


 
palva ©   (2007-12-24 13:14) [1]

Надо сначала загрузить Windows и только после этого запускать игру.


 
homm ©   (2007-12-24 13:45) [2]

> [0] InfectedM   (24.12.07 13:01)

Какие именно игры?


 
InfectedM   (2007-12-24 14:33) [3]

Игра Lineage
"Надо сначала загрузить Windows и только после этого запускать игру."
->Вот это не совсем понял))

вот код моей программы,сначало она запоминает координаты,потом тыкает в них...
Тестировал в pain(ВСе работает,курсор двигает и рисует кистоцкой по моим координатам)
А вот в играх не передвигаеться курсор,(Протестирвал на игре Lineage)
procedure PMouseDown(x,y: integer);
var
OldCursorPos: TPoint;
begin
//направляем мышкой и тыкаем кнопку
GetCursorPos(OldCursorPos);
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN,x,y,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,x,y,0,0);
SetCursorPos(OldCursorPos.X, OldCursorPos.Y);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
OldCursorPos: TPoint;
begin
//сохраняем позиции
if (GetAsyncKeyState(VK_LBUTTON) <> 0) and (GetAsyncKeyState(vk_Shift) <> 0) then begin
GetCursorPos(OldCursorPos);
memo1.lines.add(inttostr(OldCursorPos.X)+":"+inttostr(OldCursorPos.y));
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
i,ckl2,pos1,pos2: integer;
h: HWND;
begin
//начать кликать
for ckl2:= 1 to strtoint(edit2.text)do begin
h:=FindWindow(nil,pchar(form1.edit1.text));
if h <> 0 then begin
//ShowWindow(h, SW_MAXIMIZE);

SetForegroundWindow(h);
  for i:= 0 to memo1.lines.Count-1 do begin

      If Pos("stop", memo1.lines[i]) <> 0 then begin
      pos1:=pos("(",memo1.Lines[i]);
      pos2:=pos(")",memo1.Lines[i]);
      sleep(strtoint(copy(memo1.Lines[i],pos1+1,pos2-pos1-1)));

      end
      else
      begin
      pos1:=pos(":",memo1.Lines[i]);
      PMouseDown(strtoint(copy(memo1.Lines[i],1,pos1-1)),strtoint(copy(memo1.Lines[i],pos1+1,length(memo1.Lines[i])-pos1)));
      end;
  end;
   end;


 
homm ©   (2007-12-24 14:37) [4]

> [3] InfectedM   (24.12.07 14:33)
> Игра Lineage

Ни разщу не видел, ничего не могу сказать.
Если бы был шутер, то в них всегда курсор на каждом кадре ставится в центр, иначе бы мы, вертя «головой» рано или поздно уперлись бы в стенку, т.е. в край экрана.


 
DiamondShark ©   (2007-12-24 14:53) [5]

Значит игра использует DirectInput. Ему пофиг координаты виндового курсора. У него вообще нет понятия "курсора".

The data returned for the x-axis and y-axis of a mouse indicates the movement of the mouse itself, not the cursor. The units of measurement are based on the values returned by the mouse hardware and have nothing to do with pixels or any other form of screen measurement.

Axis data returned from the mouse can be either relative or absolute. (See Relative and Absolute Axis Coordinates.) Because a mouse is a relative device—unlike a joystick, it does not have a home position—relative data is returned by default.

When the axis mode for the mouse is set to relative, the axis coordinate represents the number of units that the device has been moved along the axis since the last value was returned. A negative value indicates that the mouse was moved to the left for the x-axis, or away from the user for the y-axis, or that the z-axis (the wheel) was rotated toward the user. Positive values indicate movement in the opposite direction.

When the axis mode is set to absolute, the coordinates are a running total of all relative motions received by DirectInput. The axis coordinates are not initialized to any particular value when the device is acquired, so your application should treat absolute values as relative to an unknown origin. You can record the current absolute position whenever the device is acquired and save it as the virtual origin. This virtual origin can then be subtracted from subsequent absolute coordinates retrieved from the device to compute the relative distance that the mouse has moved from the point of acquisition.


 
InfectedM   (2007-12-24 14:54) [6]

ну та игра типа РПГ)
там курсор не ставиться в центер.
Уже почти на всех форумах спросил - никто не знает)


 
DiamondShark ©   (2007-12-24 14:59) [7]


> ну та игра типа РПГ)
> там курсор не ставиться в центер

Ну, типа, пофиг, какого жанра игра. У DirectInput нет курсора.


 
@!!ex ©   (2007-12-24 14:59) [8]

> [6] InfectedM   (24.12.07 14:54)

Читай [5]


 
InfectedM   (2007-12-24 15:00) [9]

незаметил сообщения)
вот что я нарыл,это то что надо?
http://www.tiflocomp.ru/games/design/index.php


 
DiamondShark ©   (2007-12-24 15:07) [10]

Если б ты писал игру, это было б то что надо.
А для бота, который в игре должен чем-то подёргать -- это не совсем то что надо.

Я вообще не уверен, что DirectInput можно подсунуть симулированный ввод так же легко, как программам на Windows-сообщениях.


 
Dimaxx ©   (2007-12-24 16:43) [11]


> вот код моей программы,сначало она запоминает координаты,
> потом тыкает в них...

Все уже написано до нас! Полно программ для автоматического кликания (а также записи "мышиных" макросов) мышкой в играх.


 
InfectedM   (2007-12-25 15:11) [12]

вот я нашел
http://www.gamedev.ru/articles/?id=70105
но там непонятно на си...

как я понял надо просто отправлять
sendmessage(h,WM_MOUSEMOVE,вот тут чтописать?)
или что?нефига не понял там)там много лишнего,си не знаю,подскажите плз



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

Форум: "Основная";
Текущий архив: 2008.09.21;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.012 c
2-1218291171
REX
2008-08-09 18:12
2008.09.21
Файлы


15-1217196828
DesWind
2008-07-28 02:13
2008.09.21
Поздравляю наш доблесный военно-морской Российский Флот!!!


15-1217065057
Andy BitOff
2008-07-26 13:37
2008.09.21
покупателю вернули деньги за Windows Vista


15-1217231937
Knight
2008-07-28 11:58
2008.09.21
Есть какой-то аналог TortoiseSVN для локальных папок?


2-1218506684
Abcdef123
2008-08-12 06:04
2008.09.21
Проблемы перевода проекта с Delphi6 на Delphi 2007





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский