Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

InGame Scripts HowTo


  • Please log in to reply
56 replies to this topic
_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

DirectInput game troubles sad.png((

 

Whole day I test Send wariations Input / Play / Control Sleep but all failed even dllcall("keybd_event", ...).

Now reading about hook / detour for exampe: http://www.autohotke...ta-types/page-2

 

I suggest that way will be long and hard - probably there no ready to use (keyboard and mouse) hooks. sad.png((((

 

 

#InstallKeybdHook
#InstallMouseHook

not work In my Game :((((((


Edited by _3D, 18 May 2013 - 09:31 PM.


_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

http://msdn.microsof...8(v=vs.85).aspx

 

 

Interaction with Windows

Because DirectInput works directly with the device drivers, it either suppresses or ignores Windows mouse and keyboard messages. It also ignores mouse and keyboard settings made by the user in Control Panel. It does, however, use the calibrations set for a joystick or other game controller.

 

HID ---------------|

device <-> driver <-> directinput (game) 

--------------------| <-> windows event system <-> ahk scripts

 

in other words directinput give (game) access to basic HID actions AND may IGNOR OS events :((((

 

now we have 2 ways to inject keyboard / mouse action to (game)

1. to emulate device

2. to emulate or manipulate driver

 

I think best way is to have Virtual HID (VHID) that communicate with windows event system - that way (game) will think that it is additional keyboard / mouse (for example laptop with external kbd / mouse) and give ahk scripts access to control (game).

 

VHID -----------------|

             | <-> driver <-> directinput (game) 

----------| <-> windows event system <-> ahk scripts

 

Now need to find VHID Virtual HID (onscreen display keyboard not work if directinput).

AHK forum have some questions about VHID but actually no any answers :((((



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

Afret one week searching I dont find any project like PPjoy but for viryual keyboard and virtual mouse :((((((



Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011

First:

If Send fails, use SendInput

If SendInput fails try SendPlay and SendEvent

If those fail, try SendInput with sleep between button down and up

If that fails try sending same key multiple times (Send {W 3})

If that fails go all in and use dllcall keybd event and last if that doesnt work

try dllcall keybd event with sleep between button down and up

example:

dllcall("keybd_event", int, 57, int, 0x049, int, 0, int, 0)
Sleep, 64
dllcall("keybd_event", int, 57, int, 0x049, int, 2, int, 0)

^It sends 8 happy.png very simple

 

Hope this is useful for someone ^^

 

In some games I play I have to use:

 

#InstallKeybdHook
#UseHook

 

So those are something I also general try when trying to get AutoHotkey to work in a game.

 

FG


Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

In some games I play I have to use:

 

#InstallKeybdHook
#UseHook

 

So those are something I also general try when trying to get AutoHotkey to work in a game.

 

FG

 

 

Actually I test all this types of sending EVENTS but when DirectInput all of them not work :(((( - because all of them SENDING events to windows message events trey and GAME actually not interesting of that EVENTS (keyboard and mouse).

 

Microsoft:

"

Interaction with Windows

Because DirectInput works directly with the device drivers, it either suppresses or ignores Windows mouse and keyboard messages. It also ignores mouse and keyboard settings made by the user in Control Panel. It does, however, use the calibrations set for a joystick or other game controller.

"

By general meaning DirectInput made modern programing to meat OLDFASHION DOS programing.

 

I "love" modern fashion programing that doit the basic things to be complicated and far of mind with tones of codes / classes / .netes / restrictions and so on.

 

 

Q:Now what the INPUT in the end mean ? A:Get/Set the "REAL" data from/to the "REAL" device.

Q:And where the physical device meat OS ? A:Device driver.

Q:And what this "device driver" do? A:Nothing :)))))) but continuously.

 

 

http://wiki.osdev.or...PS/2_Controller

 

Q:And ?

A: Device driver communicate with device trough communications  PORTS by given protocol to understand the status of the device and then convert this status to OSunderstanding EVENTS. After that OS manipulate this basic EVENTS to do them HUMANunderstanding EVENTS.

 

If we think for keyboard like symbols that we push WE FAR FROM sollution. Actually keyboard is clearOne buttons puting together in some unknown order and some or without led. :p

 

IN OLDFASHION DAYS was easy just catch the interupt vector and put there your one OR catch the port and HELLO WORLD.

Modern OS "PREVENT" all this methods BUT how the driver do this FORBIDDEN thing to work even the device is the same one ?????

 

OK I cant gloat more but there HAVE lowlevel keyboard and mouse manipulating that give the manipulation REAL status and causes DIRECTINPUT to "think" that all is OK.

 

 

I cant explain how this all work just will mention that POSSIBLE to simulate button pressing avoid ALL OS dependent restriction by manipulating INPUT device DIRECTLY.

 

1. We need NT/XP direct port manipulator FIRST - to give us direct access to basic communication with device (I use kioport.sys / kioport.dll).

2. We need backward converter that will convert HUMANmeanings to DEVICEstatuses (that I will work down like small ahk library).

3. We need to reproduce what the HUMAN do over the device. (your deal lol)

 

 

For now I have 4 AHK functions (still in working stage - but still worked :p)

 

 

global DD_BtnDelay ;A_KeyDelay compatible

global DD_BtnPress ;A_KeyPress - if someday will be

 

DD_SetBtnDelay(btnDelay=10, btnPress=80) ;SetKeyDelay alternative

 

DD_BtnSend(btnString, btnDelay= 0, btnPress= 0, raw= 0) ;Send like button sequence manipulator 

DD_Button(btn, release=0) ;Single button manipulator

DD_ScanCode(btn, release= 0) ;Backward button to ScanCode converter (you said {Esc} DD_ScanCode return 0x01(press) or 0x81(release))

 

All together represent ALL that me need inside DirectInput GAME for keyboard that conventional methods CANT.

NOW working around the mouse. :))))))))



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

 After some day of stress tests I completely rewrite the keyboard library and now it work perfect.

Mouse:

1. Mouse return only relative coordinates (delta X / Y) that mean we must send relative coordinates.

2. Mouse delta -X (left) +X (right) / -Y (DOWN) +Y (UP) - event you will find other explanations. In other words mouse(0, 0) LEFT / DOWN corner. :)

3. Different  delta values bring different movements :(((((((

examples:

1axe: 1 = 0.5 / 2 = 1 / 254 = 400 

2axe: 1 = 0.5 / 2 = 1 / 254 = 443

in other words:

start possition Upper / Left

relative      +2/   -2 ==> mouse abs coordinates 1/1

relative +254/-254 ==> mouse abs coordinates 443/443 or 403/403 - still fine

relative     +2/-254 ==> mouse abs coordinates   43/443 - ultra cool :))))))))))

 

here the explanation why:

http://physics.stack...-computer-mouse :))))

 

and here solution:

(null pointer) :((((((((((((((

 

now me need not so complicated algorithm to determinate sequence of delta values that move mouse pointer to given absolute coordinates (linear movement not ussable)

 

first my suggest is to run around till got the coordinates EQUAL something like that:

;only X will be moved
newX
MouseGetPos, mX, mY
deltaX:= newX - mX

if(deltaX > 255)
{
  FastMove +/- 255 (about +/- 660pixels)
  recursive call
}
else if(deltaX > 64)
{
  FastMove +/- 20 (about +/- 52pixels)
  recursive call
}
else
{
  Loop deltaX
    SlowMove +/- 2 (about +/- 1 pixel)
}

Idea is to decrease delta till find position - actually movement standing ultra slow :(((((



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

There some comments about the same http://www.autohotke...tohotkey/page-9

1.kioport - work only at 32 bit OS http://www.codeproje...ts-under-Win-NT

2.use inpout 32/64 instead of kioport http://www.highrez.c...loads/InpOut32/

3.depend of OS inpout 32/64 SYS

4.depend of AHK interpretator inpout 32/64 DLL

 

Let say that IO SYS driver is installed and IO DLL is near the script

 

!!! IT IS ALPHA STAGE - SHORT TIME TESTED (only 32bit architecture) - VERSION - BE CAREFUL !!!

DD_IOPortInit()
{
global InpOut32 
global DD_MouseStatus
  DD_MouseStatus:= 0x00
        if DllCall("InpOut\inpout32\IsInpOutDriverOpen")  ;must try 32 bit first
          InpOut32:= 1
;       if DllCall("InpOut\inpoutx64\IsInpOutDriverOpen") 
;         InpOut32:= 1
  else        
  {
    MsgBox, InpOut not loaded
    ExitApp
} } ; ==========================================================================

This function just check IF IO mechanism exist and set InpOut32 variable to NON ZERO

DD_outport(port, valu) ; DllCall(variable,,,,) not supported 
{
global InpOut32
  if InpOut32
       DllCall("InpOut\inpout32\Out32", Short, port, Char, valu)
; DllCall("InpOut\inpout64\Out32", Short, port, Char, valu)
} ; ============================================================================

DD_inport(port) ; DllCall(variable,,,,) not supported
{
global InpOut32
  if InpOut32
       return DllCall("InpOut\inpout32\Inp32", Short, port)
; return DllCall("InpOut\inpout64\Inp32", Short, port)
} ; ============================================================================

2 basic functions that replace calling of 32/64 DLL 

DD_PS2command(comm, valu)
{
  Suspend On ; DONT REMOVE -------------
      InpOut32:= 1000
      While (DD_inport(0x64) & 0x02)  && InpOut32--  ;wait to get communication
        Sleep 1
      If InpOut32 ;if InpOut32 ZERO - PS2 controler BUZZY or MISSING
      {
        DD_outport(0x64, comm)        ;send command
        InpOut32:= 1000
        While (DD_inport(0x64) & 0x02) && InpOut32--  ;wait to get communication
          Sleep 1
        DD_outport(0x60, valu)        ;send data
        Sleep 1                       ;wait to OS get data
      }  
  Suspend Off ; DONT REMOVE ------------
} ; ============================================================================

Communication to PS2 controler is sending commands to controler mean send to port 0x64 command then send data to port 0x60 but waiting PS2 controler to be ready.

 

In the basic conditions this 4 functions and IO mechanism is enough to start sending KEYBOARD and MOUSE actions (not events) to OS. It is LOW LEVEL action EMULATION used in OLD FASHION days :p

 

Now the problems:

1. Keyboard send to OS ScandCodes - that determinate preesing / releasing of buttons

2. Mouse send ONLY delta X/Y movement actions - that are kinetics related (long to explain just will mention that slow motion void to low values and fast motion void to high values). Mouse send +/- X/Y movement related values:

-X: move left

+X: move right

-Y: move DOWN (even other explanations)

+Y: move UP

 

Command 0xD2 - write to keyboard buffer (not to keyboard !!!) - hardware possibilities for KEYBOARD emulation

; PRESS / RELEASE button
; DD_Button("{Ctrl}"), DD_Button("{Alt}"), DD_Button("{Shift}") ; PRESS and HOLD all {Ctrl}{Alt}{Shift} down together
DD_Button(btn, release= 0, delay= 0)
{
global DD_BtnDelay
  
  if delay  
    Sleep, DD_BtnDelay
  DD_PS2command(0xD2, DD_ScanCode(btn, release))  
} ; ============================================================================

Function that pressed buttons (DD_ScanCode - ButtonName to ScanCode converter) 

Let First set the next terms:

1.ButtonName - HUMAN understanding NAME of given BUTTON (it is just NAME that represent button for HUMAN understanding)

2.ScanCode - KEYBOARD native button representation.

DD_ScanCode(btn, release= 0) ;Button name to ScanCode converter
{
        if scode:= InStr("1234567890-=", btn)
          scode += 0x01
  else  if scode:= InStr("QWERTYUIOP[]", btn)
          scode += 0x0F
  else  if scode:= InStr("ASDFGHJKL;'`", btn)
          scode += 0x1D
  else  if scode:= InStr("\ZXCVBNM,./", btn)
          scode += 0x2A
  else  if scode:= InStr(" {Space}", btn)
          scode:= 0x39
  else  if scode:= InStr("{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}", btn)
          scode := scode // 4 + 0x3B
  else  if scode:= InStr("{Numpad7}{Numpad8}{Numpad9}{Numpad-}{Numpad4}{Numpad5}{Numpad6}{Numpad+}{Numpad1}{Numpad2}{Numpad3}{Numpad0}{Numpad.}", btn)
            scode:= scode // 9 + 0x47
  else  if InStr("{Numpad*}", btn)
          scode:= 0x37
  else  if scode:= InStr("{F11{F12", btn)
          scode:= scode // 4 + 0x57
  else  if InStr("{LShift}{Shift}{SH}", btn) 
          scode:= 0x2A
  else  if InStr("{LShiftU}{ShiftU}{SU}", btn) ;untested possibility to write {SH}U{SU}pper{SH}C{SU}ase I use {CL}
          scode:= 0x2A | 0x80       
  else  if InStr("{LCtrl}{Ctrl}", btn)
          scode:= 0x1D
  else  if InStr("{LAlt}{Alt}", btn)
          scode:= 0x38
  else  if InStr("{Esc}{Escape}", btn)
          scode:= 0x01
  else  if InStr("{Enter}", btn)
          scode:= 0x1C
  else  if InStr("{Tab}", btn)
          scode:= 0x0F
  else  if InStr("{BS}{BackSpace}", btn)
          scode:= 0x0E
  else  if InStr("{RShift}", btn)
          scode:= 0x36
  else  if InStr("{CL}{CapsLock}", btn) ;use this for {CL}UPER{CL} case
          scode:= 0x3A
  else  if InStr("{NL}{NumLock}", btn)
          scode:= 0x45
  else  if InStr("{SL}{ScrolLock}", btn)
          scode:= 0x46
  else  scode:= 0x00 ;return 0x00 that mean no scancode        

  return scode | (release? 0x80: 0x00)
} ; ============================================================================
;ScanCodes and ButtonNames
;0x01 {Esc}
;0x02 1234567890-=
;0x0E {BS}{BackSpace}
;0x0F {Tab}
;0x10 QWERTYUIOP[] 
;0x1C {Enter}
;0x1D {LCtrl}
;0x1E ASDFGHJKL;'`
;0x2A {LShift}
;0x2B \ZXCVBNM,./ 
;0x36 {RShift}
;0x37 {Numpad*}
;0x38 {LAlt}{Alt}
;0x39 {Space}
;0x3A {CL}{CapsLock}
;0x3B {F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10} 
;0x45 {NumLock}
;0x46 {ScrolLock}
;0x47 {Numpad7}{Numpad8}{Numpad9}{Numpad-}{Numpad4}{Numpad5}{Numpad6}{Numpad+}{Numpad1}{Numpad2}{Numpad3}{Numpad0}{Numpad.} 
;0x57 {F11}{F12}

;UNSUPPORTED scancodes yet and ALPHA names
;0xE0, 0x1C 	 {Nend} 
;0xE0, 0x1D 	 {Rctr} 
;0xE0, 0x35 	 {Num/} 
;0xE0, 0x38 	 {Ralt}
;0xE0, 0x47 	 {Home} 
;0xE0, 0x48 	 {Upar} 
;0xE0, 0x49 	 {PgUp}
;0xE0, 0x4B 	 {Left}
;0xE0, 0x4D 	 {Rght}
;0xE0, 0x4F 	 {Endk}
;0xE0, 0x50 	 {Down}
;0xE0, 0x51 	 {PgDn} 
;0xE0, 0x52 	 {Insk}
;0xE0, 0x53 	 {Delk}
;0xE0, 0x5B 	 {Lwin} 
;0xE0, 0x5C 	 {Rwin} 
;0xE0, 0x5D 	 {Apps}
;0xE0, 0x2A, 0xE0, 0x37 	 {Prnt}
;0xE1, 0x1D, 0x45, 0xE1, 0x9D, 0xC5 	 {Paus}

Now we MAY send button to OS

Lets do the sequences - emulating keyboard typing

DD_SetBtnDelay(btnDelay=85, btnPress=10) ; SetKeyDelay but for buttons
{
global DD_BtnDelay, DD_BtnPress
  DD_BtnDelay:= btnDelay
  DD_BtnPress:= btnPress ;actually not used but let exist (languge must have treads to produce this mechanism to work)
} ; ============================================================================
; Send but for buttons
; !!! Button sequence just typed not released
DD_BtnSend(btnString, btnDelay= 0, btnPress= 0)
{
global DD_BtnDelay, DD_BtnPress
  DD_BtnDelay:= btnDelay? btnDelay: DD_BtnDelay
  DD_BtnPress:= btnPress? btnPress: DD_BtmPress
  while StrLen(btnString)
  {
    btn:= SubStr(btnString, 1, btnSize:= 1)
    if InStr(btn, "{")
      btn:= SubStr(btnString, 1, btnSize:= InStr(btnString, "}"))
    DD_Button(btn,,delay)
    delay:= 1  
    btnString:= SubStr(btnString, btnSize+1)
} } ; ==========================================================================

KEYBOARD DONE. DD_BtnDelay value depend on hardware / CPU usage and GAME

!!! WARNING !!!

ALL BUTTONS ARE SEND TO COMPUTER NOT TO APPLICATION OR OS - DUALBOXING / MULTI APPLICATION CANT BE SUPPORTED 

IT IS FOR ONE ONLY GAME INSTANCE AT ONE ONLY COMPUTER

!!! WARNING !!!

 

Now Mouse - Scroll movement (Z movement) NOT SUPPORTED yet and may be never will be (no reason to be supported)

 

Command 0xD3 - write to mouse buffer (not to mouse !!!) - hardware possibilities for MOUSE emulation

; PRESS / RELEASE mouse buttons (+value = PRESS / -value = RELEASE / 0 = no action)
DD_MouseBtn(lft= 0, mid= 0, rgh= 0)
{
global DD_MouseStatus
  if lft ; LEFT BUTTON -------------------
    if lft > 0
         DD_MouseStatus |= 0x01 ;xxxx xxx1
    else DD_MouseStatus &= 0xFE ;xxxx xxx0
  if rgh ; RIGHT BUTTON ------------------
    if rgh > 0
         DD_MouseStatus |= 0x02 ;xxxx xx1x
    else DD_MouseStatus &= 0xFD ;xxxx xx0x    
  if mid ; MIDDLE BUTON ------------------
    if mid > 0
         DD_MouseStatus |= 0x04 ;xxxx x1xx
    else DD_MouseStatus &= 0xFB ;xxxx x0xx
  
  DD_PS2command(0xD3, DD_MouseStatus)
  DD_PS2command(0xD3, 0x00)
  DD_PS2command(0xD3, 0x00)
} ; ============================================================================

Function manipulate LEFT / MIDDLE / RIGHT buttons together 

And at end MouseMove

;MOVE Mouse to X/Y possition in binary search mode (possible +/- 1 pixel disorder)
DD_MouseMove(X, Y)
{
global DD_MouseStatus
CoordMode, Mouse, Screen
vX:= 1, vY:= 1 ; fake init

while vX || vY
{  
  MouseGetPos, mX, mY
  vX:= abs(dX:= X - mX), vX:= vX > 256? 127: vX // 2 
  if dX < 0
  {
    DD_MouseStatus |= 0x10 ;xxx1 xxxx
    vX:= 256 - vX
  }
  else DD_MouseStatus &= 0xEF ;xxx0 xxxx
  
  vY:= abs(dY:= Y - mY), vY:= vY > 256? 127: vY // 2 
  if dY > 0
  {
    DD_MouseStatus |= 0x20 ;xxx1 xxxx
    vY:= 256 - vY
  }
  else DD_MouseStatus &= 0xDF ;xxx0 xxxx
  
  if (vX = 0) || (vX = 256)
  {
    DD_MouseStatus &= 0xEF ;xxx0 xxxx 
    vX:= 0
  }
  if (vY = 0) || (vY = 256)
  {
    DD_MouseStatus &= 0xDF ;xxx0 xxxx 
    vY:= 0
  }
  DD_PS2command(0xD3, DD_MouseStatus & 0xFF)
  DD_PS2command(0xD3,             vX & 0xFF)
  DD_PS2command(0xD3,             vY & 0xFF)
} } ; ==========================================================================

Sorry for this iterative mouse positioning but I cant find method to move mouse fast and to EXACTLY coordinates. Actually InGame 1pixel disorder is acceptable disorder.

 

IT IS FIRST SHORT PERIOD TESTED FUNCTIONS

;Send greating to the world :P
;USE THIS CONVENTION
#!S::
  DD_BtnSend("{CL}H{CL}allo world{Enter}")
return
;INSTEAD OF THIS
#!S::DD_BtnSend("{CL}H{CL}allo world{Enter}")

;I noticced that one line convention in some case forget to return and run next line command (AHK depending).

;Drag from current mouse position to 100/100
#!D::
  DD_MouseBtn(+1) ;press LEFT 
  DD_MouseMove(100, 100) ;move mouse to 100, 100 absolute coordinates - dragigng
  DD_MouseBtn(-1) ;release LEFT
return
;dont forget for the LAGG Sleep is all the time welcome to be used  

ANY response ARE highly recommended.

I think there have more UNUGLY method for KEYBOARD/MOUSE emulation BUT me need years READING to produce IT.



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

My last post for unknown reason not posted but iLL repost it

;All output to port 0x60 or 0x64 must be preceded by waiting for bit 1 (value=2) of port 0x64 to become clear.
;Similarly, bytes cannot be read from port 0x60 until bit 0 (value=1) of port 0x64 is set.
DD_PS2command(comm, valu)
{
; ---------- disable interupts ---------
    Suspend On
; ---------- DONT REMOVE ---------------
  
      While (DD_inport(0x64) & 0x02) ;waiting for communication
        Sleep 1
      DD_outport(0x64, comm)         ;send command
      While (DD_inport(0x64) & 0x02) ;waiting for communication
        Sleep 1
      DD_outport(0x60, valu)         ;send data
        Sleep 1                      ;just wait

; ---------- enable interupts ----------    
  Suspend Off
; ---------- DONT REMOVE ---------------  
} ; ============================================================================

Strange but unconditional WHILE work better than time limited

 

WHEELMOUSE - if mouse have WHEEL (scroller) - then packet is 1 more byte long:

NOwheel - 3 byte packet

WHEEL - 4 byte packet

; PRESS / RELEASE mouse buttons (+value = PRESS / -value = RELEASE / 0 = no action)
DD_MouseBtn(lft= 0, mid= 0, rgh= 0)
{
global DD_MouseStatus
  if lft ; LEFT BUTTON -------------------
    DD_MouseStatus:= lft > 0? DD_MouseStatus | 0x01: DD_MouseStatus & 0xFE
  if rgh ; RIGHT BUTTON ------------------
    DD_MouseStatus:= rgh > 0? DD_MouseStatus | 0x02: DD_MouseStatus & 0xFD    
  if mid ; MIDDLE BUTON ------------------
    DD_MouseStatus:= mid > 0? DD_MouseStatus | 0x04: DD_MouseStatus & 0xFB
  
  DD_PS2command(0xD3, DD_MouseStatus)
  DD_PS2command(0xD3, 0x00)
  DD_PS2command(0xD3, 0x00)
  If WHEELMOUSE ; if mouse have scroller
  DD_PS2command(0xD3, 0x00) ;send 1 extra byte
} ; ============================================================================

If mouse packet shorter or longer than mouse TYPE then PS2 controller FREEZE 

Still I dont know how to get MouseID and I set WHEELMOUSE manualy (not so clever but work :))))) )

If WHEELMOUSE ; if mouse have scroller

DD_PS2command(0xD3, 0x00) ;send 1 extra byte

must be added to DD_MouseMove too

 

TouchPad:

1. Touchpad without installed drivers -> WHEELMOUSE:= 1 (rare used because produced unconditional zooming in most games)

2. Touchpad with installed drivers -> WHEELMOUSE:= 0 (driver got control and replace scroll areas native actions with EVENTS)



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

!!! WARNING !!!

DD_MouseStatus:= 0x00 MUST BE REPLACED WITH DD_MouseStatus:= 0x08 in DD_IOPortInit

some mouses (Logitech for example) need this bit to be set or else controler FREEZE.

 

!!! WHEELMOUSE !!!

WHEELMOUSE depend on first (main) pointer device.

For Example:

Touchpad with instaled drivers -> WHEELMOUSE must be 0 (ZERO) even you have connected additional mouse with wheel (scroller).



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

NOW I do battle test 

{ completely rewrite delay strategy - global values and other local values

}

 

and want to suggest next syntaxes (I use Notepad++) 

If expression ;short text
{ <if_TRUE_action>
} else 
{ <if_FALSE_action>
}

perfect divided different sections

<hotkey>::<action>
return

adding <return> after key remapping avoid 100% running next line (that I noticed like bug in AHK).

functionNAME([arg1, arg2, ...]) ;short text ===================================
;arg1 - short text
;arg2 - short text
;...  - short text
{ 
  <action>
} ; ===========================================================================

I like this C like function write.

 

Will be fine next syntax but actually :(

If (expression) action_TRUE


_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

Battle tests:

1. The most important that I mention is timing - delay between buttons and delay to send release ScanCode.

2. Sequences of buttons must have additional (different) delays if buttons activated buffs / potions.

3. It is better to don`t use mouse movements in battle.

 

In additions I do "debuffer" - that ImageSearch any second given debuff and if exist send command to use right portion - And what a surprise "debuffer" remove debuff perfect and economize potions 3 times (33 instead 80/90 in manual mode) and at the same time allow continuous fighting.

 

Now I do fine tune up.



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

There one good and one bad news.

The good first - not need to use any additional IO drivers XP and next come with added (HAL.DLL)


DD_PS2command(comm, valu) 
{
; ---------- disable interupts ---------
    Suspend On
; ---------- DONT REMOVE ---------------
                     ;HAL.DLL
      While (DllCall("READ_PORT_UCHAR", 0x64) & 0x02) ;waiting for communication
        Sleep 1
      DllCall("WRITE_PORT_UCHAR", 0x64, comm)         ;send command
      While (DllCall("READ_PORT_UCHAR", 0x64) & 0x02) ;waiting for communication
        Sleep 1
      DllCall("WRITE_PORT_UCHAR", 0x60, valu)         ;send data
        Sleep 1                                       ;just wait

; ---------- enable interupts ----------    
  Suspend Off
; ---------- DONT REMOVE ---------------  
} ; ============================================================================

And the BAD one - game now use Themida for protecting and ofcourse all major functions are catched.

I will read about some more weeks for Kernel Debugging and Kernel Device Drivers and may be start hardware solution for keyboard and mouse emulating.

 

Hardware emulating maybe will more cheaper and more easier solution.


Edited by _3D, 26 June 2013 - 08:47 PM.


_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

Now I teach my lesson to don`t write basic truths to the forums and to provoke strong protection evolving.

 

NEVER SAY NEVER. :)

 

I tempted to ask "What if we replace ... ?" but can`t. :)



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

Seeing as this seems to be the place where solutions to game quirks are collecting, I thought I would add this nugget of info.

 

In a game I am playing at the moment (MechWarrior online, using the Crysis 3 engine) there is this quirk:

 

Say I have LButton mapped to send the 1 key very fast.

LMB is not bound to anything in the game.

 

You do not rapid fire, it behaves as if you have the 1 key held.

 

Solution:

Send {LButton Up} on LButton down.

 

Despite LButton doing nothing in game, it obviously treats the LButton you are pressing and the 1 the macro is sending as a pair of keys or something and wont recognize a 1 up until LButton goes up.

 

Works the same for all keys, LButton was just an example.

 

This also solves another issue which I at first interpreted as macroing detection.

I had another macro which would send a timed fire pulse (not quick so doesnt seem to suffer from the not rapid fire issue) but after a (long) time using it I would notice that the macro stopped working.

When I sent the keyup on fire, it all went away.

Maybe I was filling some keyboard buffer if I didnt send the keyup?



_3D_
  • Members
  • 79 posts
  • Last active: Mar 14 2014 07:49 PM
  • Joined: 28 Feb 2013

Dear evilc I don`t understand anything.

Understanding how the given device work is manual work - then we use some automations to don`t do that manually.