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

A little code from "DBFfer".

#!G:: ; ARMED / DISARMED DBF
  If GRB_ACTIVE:=!GRB_ACTIVE
  { ToolTip, % "<<< ARMED >>>"
    SetTimer, LABEL_removeBuff, 500   ;check for debuff any 0.5 sec (500 ms)
  } else
  { ToolTip, % "<<< disarmed >>>"
    SetTimer, LABEL_removeBuff, Off
  }
  SetTimer, LABEL_removeToolTip, 5000 ;5 sec delay to remova ToolTip
return

LABEL_removeToolTip:
  SetTimer, LABEL_removeToolTip, Off
  ToolTip
return

LABEL_removeBuff:
  SetTimer, LABEL_removeBuff,  Off ;disable timing
  ;{ leftUP_X,  leftUP_Y} - left Upper corner coordinates of buffs field
  ;{rightDN_X, rightDN_Y} - right Down corner coordinates of buffs field
  ;*80 - about 31% picture disorder (80/256)
    ImageSearch, iX, iY, leftUP_X, leftUP_Y, rightDN_X, rightDN_Y,% "*80 " A_ScriptDir "\DBF-debufName.bmp"
    If !ErrorLevel
      DD_BtnSend("z") ; button that activate debuff remove potion
  SetTimer, LABEL_removeBuff       ; enable timing
return

Why so complicated?

1. One only shortkey activate / deactivate DBFfer.

2. Simple time changing.

3. Fast and not breakable mechanism.  

 

Fine tunning:

1. Timing (500 ms) - this value control in how many ms after last check will be next check - remember not at any (500 ms) but (500 ms) after last check.

2. *80 - in most games debuffs have blinking or fade effect - if value too low may produce unrecognizing - if value too high may produce unconditional activation (in my case if *100 DBFfer "remove" debuff event it don`t exist)

3. Coordinates - small field => better performance (set field as small as possible)

 

How to get debuff icon:

#!B:: ; GET debuff icons =======================================================
  mX:= leftUP_X, mY:= leftUP_Y
 
  Loop 8 ; first debuff line 
  { DD_GetImage(mX+1+(A_Index-1)*40, mY+1   , 29, 29, A_ScriptDir "\DBF-1-" A_Index ".bmp")
  }
  Loop 8 ; second debuff line
  { DD_GetImage(mX+1+(A_Index-1)*40, mY+1+40, 29, 29, A_ScriptDir "\DBF-2-" A_Index ".bmp")
  }
return

It is just sample: icon 29x29 pixels and 40pixels from leftUP corner in X/Y coordinates from icon to icon.

 

As you see most things omitted but core still there.

Use graphical things only in debug mode (complete code).

;#DEFINE ======================================================================
GUI_ACTIVE:= 1
IF GUI_ACTIVE
  InputBox, GUI_ACTIVE,GUI DEBUG MODE,!!! WARNING !!! this mode slowdown performance. Write 0 to disable GUI mode.,,478,120,,,,,%GUI_ACTIVE%
;==============================================================================

IF GUI_ACTIVE
{
pToken := Gdip_Startup()
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 1: Show, NA
  
hwnd1 := WinExist()
hbm := CreateDIBSection(mainWindowW, mainWindowH)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G   := Gdip_GraphicsFromHDC(hdc)
  
Gdip_SetSmoothingMode(G, 4)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, mainWindowW, mainWindowH)
}
return

#!B::
  mX:= leftUP_X, mY:= leftUP_Y
 
  IF GUI_ACTIVE
  bPen := Gdip_CreatePen(0xffFFFF00, 1)
  Loop 8
  { IF GUI_ACTIVE
    Gdip_DrawRectangle(G, bPen, mX+(A_Index-1)*40   , mY   , 31, 31) ; draw 31x31 square around icon
    DD_GetImage(mX+1+(A_Index-1)*40, mY+1   , 29, 29, A_ScriptDir "\DBF-1-" A_Index "=.bmp")
  }
  Loop 8
  { IF GUI_ACTIVE
    Gdip_DrawRectangle(G, bPen, mX+(A_Index-1)*40   , mY+40, 31, 31) ; draw 31x31 square around icon
    DD_GetImage(mX+1+(A_Index-1)*40, mY+1+40, 29, 29, A_ScriptDir "\DBF-2-" A_Index "=.bmp")
  }
  IF GUI_ACTIVE
  { UpdateLayeredWindow(hwnd1, hdc), Gdip_DeletePen(bPen)
  }
return

ENJOY !!!



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

_3D, my comment was nothing to do with your code, merely a note on how some games work and why rapid fire may not work in a game even though you are rapidly sending the fire button.



SnowFlake_FlowSnake
  • Members
  • 845 posts
  • Last active: Jan 24 2016 05:24 PM
  • Joined: 08 Oct 2012

Here is a simple tool to let you know what commands that work.

 

http://www.autohotke...icksend-tester/

/*

Click and Send Test Tool V0.2.0 Beta Stage |2013-07-28 22:47|
Made By Snow Flake ©  

http://www.autohotkey.com/board/user/21149-snow-flake/

http://www.autohotkey.com/board/topic/95653-clicksend-tester/


*/

if not A_IsAdmin
{
    Run *RunAs "%A_ScriptFullPath%"
    ExitApp
}

#SingleInstance, force
SetWorkingDir, %A_ScriptDir%
#Persistent
#NoEnv
#MaxThreadsPerHotkey 1
DetectHiddenWindows,On
SetTitleMatchMode 2

Start:
MsgBox,,Game Window Select,Press Ok then. `n Place the mouse cursor over the window you want to Select. Then press the middle mouse button to get the Title.
IfMsgBox OK
keywait, MButton, D
keywait, MButton
mousegetpos, winX, winY, winid
wingettitle, wintext, ahk_id %winid%

MsgBox, 4,Game Window,Is this the right Game window? `n `n %wintext% 
IfMsgBox No
goto, Start
IfMsgBox Yes

Gui, Add, Text,, Sleep Time (ms);  2000 is recommended:
Gui, Add, Edit, vWaitTime
Gui, Add, Button, default, OK 
Gui, Show,, Click and Send Test Tool V0.2.0
return

ButtonOK:
Gui, Submit
MsgBox  Window Text: %wintext%`n Sleep Time: %WaitTime%
 
msgbox,,Click and Send Test Tool V0.2.0, Running This Will Test different Click and Send types to confirm which works. `n Press F1 in game to Click test F3 Send Test `n`n Ctrl + Escape will Reload the script!

F1:: ; Press F3 to run Click test.
{
 KeyWait, F1, D
 SoundBeep
Goto, ClickTest
}
return

F3:: ; Press F1 to run Send test.
{
KeyWait, F3, D
SoundBeep
Goto, SendTest
}
return

ClickTest: ; ========================================================================================
{
sleep, %WaitTime%
ToolTip, Running Click Test
WinActivate,%wintext%
 
ToolTip, Testing Click
Click, 100, 100
sleep, %WaitTime%

ToolTip, Testing MouseClick
MouseClick, Left, 100, 100
sleep, %WaitTime%

ToolTip, Testing MouseClickDrag
MouseClickDrag, left, 0, 100, 100, 200, 50
sleep, %WaitTime%
 
ToolTip, Testing ControlClick
ControlClick, x100 y100, %wintext%, Left
sleep, %WaitTime%

ToolTip, Testing Send Click
Send, {Click 100, 100}
sleep, %WaitTime%
 
ToolTip, Testing SendRaw Click
sleep, %WaitTime%
SendRaw, {LButton}
 
ToolTip, Testing SendPlay Click
sleep, %WaitTime%
SendPlay, {LButton}
 
ToolTip, Testing SendEvent Click
sleep, %WaitTime%
SendEvent, {LButton}
 
ToolTip, Testing SendInput Click
sleep, %WaitTime%
SendInput, {LButton}

ToolTip, Testing ControlSend Click
sleep, %WaitTime%
ControlSend,,{Click 100, 100},%wintext%

ToolTip, Testing ControlSendRaw Click
sleep, %WaitTime%
ControlSendRaw,,{Click 100, 100},%wintext%

ToolTip, Testing PostMessage Click
sleep, %WaitTime%
PostMessage, 0x201, 0x00000000, 0x01f0010f, ,%wintext% ; Down
sleep, 500
PostMessage, 0x202, 0x00000000, 0x01f0010f, ,%wintext% ; UP

ToolTip, Testing SendMessage Click
sleep, %WaitTime%
SendMessage, 0x201, 0x00000000, 0x01f0010f, , %wintext% ; Down
sleep, 500
SendMessage, 0x202, 0x00000000, 0x01f0010f, , %wintext% ; UP

ToolTip, Testing ControlFocus Click
sleep, %WaitTime%
ControlFocus, x100 y100, %wintext%

ToolTip, Testing Dll Call Mouse_event
sleep, %WaitTime%
DllCall("mouse_event", uint, 2, int, x, int, y, uint, 0, int, 0)  ; Down
sleep, 500
DllCall("mouse_event", uint, 4, int, x, int, y, uint, 0, int, 0)  ; UP
 
ToolTip, Click Test Done
sleep, %WaitTime%
ToolTip,
}
return
 
SendTest: ; ========================================================================================
{
sleep, %WaitTime%
ToolTip, Running Send Test
WinActivate,%wintext%
 
ToolTip, Testing Send
Send, |send|
sleep, %WaitTime%
 
ToolTip, Testing SendRaw 
sleep, %WaitTime%
SendRaw, |SendRaw|
 
ToolTip, Testing SendInput
sleep, %WaitTime%
SendInput, |SendInput|
 
ToolTip, Testing SendPlay
sleep, %WaitTime%
SendPlay, |SendPlay|
 
ToolTip, Testing SendEvent
sleep, %WaitTime%
SendEvent, |SendEvent|
 
ToolTip, Testing ControlSend
sleep, %WaitTime%
ControlSend,,|ControlSend|, %wintext%
 
ToolTip, Testing ControlSendRaw
sleep, %WaitTime%
ControlSendRaw,,|ControlSendRaw|, %wintext%

ToolTip, Testing Dll call keybd_event (will send 9)
sleep, %WaitTime%
dllcall("keybd_event", int, 57, int, 0x049, int, 0, int, 0)
sleep, 500
dllcall("keybd_event", int, 57, int, 0x049, int, 2, int, 0)
 
 ToolTip, Testing Wscript
sleep, %WaitTime%
ComObjCreate("wscript.shell").SendKeys("|Wscript|")
 
ToolTip, Send Test Done
sleep, %WaitTime%
ToolTip,
}
 
return

^esc::Reload

  • Download link of my scripts on Autohotkey.com 2/10/2015 [DOWNLAND]
  • Contact Info:  https://github.com/floowsnaake //  FloowSnaake(A)gmail.com
  • IF you need Help send me a PM,Email or Post on Github

  • Quote by tank  Posted 29 September 2015 - 06:14 PM

  • "Eventually i will find a way to convert the DB back to PHPBB3. but i dont have the bandwidth right now. No one that has tried has had success. It is the Only way i can keep this open is if i could successfully convert it."

RHCP
  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006

Just curious, has anyone tried experimenting using send/post-message for sending keystrokes to some of these games?



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

Just curious, has anyone tried experimenting using send/post-message for sending keystrokes to some of these games?

Did you think that I evaluate low level keyboard and mouse emulation without test the any other possibility ? 



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

_3D, my comment was nothing to do with your code, merely a note on how some games work and why rapid fire may not work in a game even though you are rapidly sending the fire button.

Yes, Yes, Yes please read post #1 

We must automate something but automation not mean swiftness. Probably it mean working.



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

I think I maybe misinterpreted the point of the thread. I thought it was a place to share little gems of info on why macros may not work as expected in some games.



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

I think I maybe misinterpreted the point of the thread. I thought it was a place to share little gems of info on why macros may not work as expected in some games.

Yes,

My first idea was to represent some technics that used InGame and methods to reproduce it with AutoHotKey. 

At the same time My game got some updates and conventional methods Send stop working and I do "wrong turn".

 

Ofcours there no universal "right way", there too many specifics in any different game, but the core meaning is the understanding "how it work".

 

1. Find method to get information. (getcolor stop work first)

2. Find method to put "send" controls. (send was next)

3. Automate repeatedly actions with AHK macrosses.

 

LOL, simple, but when run the specifics turn over the train. 

AND think what post and what update it cost. :p



RHCP
  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006

Did you think that I evaluate low level keyboard and mouse emulation without test the any other possibility ? 

 

The question wasn't directed at you. No one has posted any information concerning this in this thread. It would be interesting for people to post what works and what doesn't work for various games. Obviously low level input isn't required for all situations. But anyway, keep up the good work.



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

 

Here is a simple tool to let you know what commands that work

See post #33

Very good, simple and usable tool that do INPUT method test. (not work in my case, but still good).



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

After DBFfer.

Many gamers have more than one account in the same game and in many times they play with twho accounts (warrior and oracle is best example).

Now I work for inter-computers AHK scripts.

What I mean: 

Let first computer will be WARR and the seconf computer will be ORC.

Now if WARR receive buff that no potion removal then ORC "spell" skill that remove the buff.

 

LOL

Many WARR, in real, trailed an ORC but at second computer in most cases other player or the same player that time to time pressed ORC skills.

Now idea is to automate this "time to time" pressing the second keyboard.  :p



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

Function ToolTip

The AHK ToolTip [, Text, X, Y, WhichToolTip]

 

When inGame, mostly FULLscreen, it is useful script to return short messages what is happen.

Here my own ToolTip function that appear near mouse pointer.

DD_ToolTip(text= "", time= 0)
;text - text for ToolTip
;time - in miliseconds to disappear text
{ ToolTip,% text
  if time
       SetTimer, LABEL_removeToolTip, -%time% ;(-) run only once
  else SetTimer, LABEL_removeToolTip, Off
  return ;end of function
;This sintax guarantee unique name and existing of LABEL in any scripts that INCLUDE this function  
  LABEL_removeToolTip: 
    ToolTip
  return ;end of LABEL   
}

It is made as function to encapsulate code and to guarantee existing and unique of LABEL. This time function can be set to library and will keep functionality.

USAGE:

DD_ToolTip("This text will disappear after 3 sec", 3000)

DD_ToolTip("This text will stay till other text or forever")
  
DD_ToolTip() ;remove ToolTip immediately

ENJOY.



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

timedFunction http://www.autohotke...me/#entry612957 sintax

and worked EXAMPLE (frend said: it is clicker ?)

#Persistent
#SingleInstance force

SysGet, mainWindowW, 78
SysGet, mainWindowH, 79

  DD_tf_timedRewards(mainWindowW//2-85, mainWindowH-35, 10000)
return

#!Space::DD_tf_timedRewards()
return

DD_ToolTip(text= "", time= 0) ;My first timed finction
{ ToolTip,% text
  if time
       SetTimer, LABEL_removeToolTip, -%time%
  else SetTimer, LABEL_removeToolTip, Off
  return  
  LABEL_removeToolTip:
  ToolTip
  return    
} ;many sections missing but this is the prototype of timedFuntion syntax

DD_tf_timedRewards(ax=0, ay=0, at=0)
{ static x:= 0, y:= 0, t:= 0, triger:= 0 ;static variables
  
  ;init variable section
  x:= ax? ax: x
  y:= ay? ay: y
  t:= at? at: t
  
  ;init timer section
  if (triger:=!triger)
  { SetTimer, LABEL_DD_tf_timedRewards, %t%
    DD_ToolTip("<<< CLICKER ON >>>" , 3000)
  } else 
  { SetTimer, LABEL_DD_tf_timedRewards, Off
    DD_ToolTip("<<< clicker off >>>", 3000)
  }
  return

  ;BODY
  LABEL_DD_tf_timedRewards:
    SetTimer, LABEL_DD_tf_timedRewards, Off ;disable interrupt
    ;this line prevent BODY to be interrupted itself
    
    ;check color at x:y and if color click there :P
    Loop 5
    { c:= DD_PixelGetColor(x, y)
      DD_ToolTip(c, 2000)
      if (c = 0xE79600) || (c = 0xCE9200)
      { MouseGetPos, mx, my
        DD_MouseMove(x-16, y)
        Sleep 200
        DD_MouseBtn(+1)
        Sleep 100
        DD_MouseBtn(-1)
        Sleep 200
        DD_MouseMove(mx, my)
        break
      }
      Sleep 700
    }
    SetTimer, LABEL_DD_tf_timedRewards  ;enable interrupt
  RETURN
}

#!Q::
  ExitApp
return  

Funny toy. LOL

 

This example represent two timed functions working together. The structure of functions is equal some sections missing and timed control is slightly different but the main idea is the same.

 

DD_tf_timedRewards - check color at given screen position any 10 seconds (actually 10 seconds after last check but "any" is good).

DD_ToolTip - appear message and timed disappear.



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

Rapid Fire my version.

Because "Rapid Fire" is frequently asked question I run my own version.

#NoEnv
#SingleInstance force 
SendMode Input

;  rapidFire(35) ;init rapideFire 35 ms timed and armed (this line not needed)
;return

;pressing and holfing LeftMouseButton generate only 1 LButton
;~sending LButton transparently 
~LButton::rapidFire()  ;run only BODY (autorepeat mode)
return
!Space:: rapidFire(-1) ;Alt+Space toggle armed / disarmed 
;when disarmed ~ needed to send LButton transparently
return
#!F4::ExitApp          ;Win+Alt+F4 Exit
return

rapidFire(_timer=0) ;timed function
{ static timer:=35, armed:=1 ;35ms timed and armed (35ms from original code)
  if _timer > 0
  { timer:= _timer
    return
  } else if _timer < 0
  { armed:=!armed
    DD_ToolTip(armed? "<<<ARMED>>>":">>>disarmed<<<", 2000) ;this line only to indicate function state
  }
  LABEL_rapidFire:
    SetTimer, LABEL_rapidFire, Off
    GetKeyState, state, LButton, P ;original code
    if (state = "D") && (armed)
    { SendInput {a down} ;<--test code | original code --> SendInput {Click down}
      Sleep 35           ;original code
      SendInput {a up}   ;<--test code | original code --> SendInput {Click up}
      SetTimer, LABEL_rapidFire, %timer%
    }
  RETURN
}

DD_ToolTip(text= "", time= 0)
{ ToolTip,% text
  if time
       SetTimer, LABEL_removeToolTip, -%time% ;(-) run only once
  else SetTimer, LABEL_removeToolTip, Off
  return
  LABEL_removeToolTip: 
    ToolTip
  RETURN
}

I got the code from here http://www.autohotke...re/#entry133287 and modify it using timedFunction method.

 

Using timedFunction method allows rapidFire to be placed at library and to be #included with the same functionality without copying the code that mean any further changing of code easy.

 

I change calling HotKey from LButton:: to ~LButton:: that allows sending LButton transparently to application and when rapidFire >>>disarmed<<< LButton still be send to application instead of the original code.

 

Don`t think that this rapidFire is UNIVERSAL function it is just perfect working EXAMPLE but ... 

Enjoy.



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

This days I start some optimization of DD_MouseMove and ... found major BUG.Now I wonder how this function worked 6 months without any exhibition. Shame but true. Now new version with better convergence.

DD_MouseMove(X, Y) 
{ global DD_IOControl, DD_MouseStatus, WHEELMOUSE
  CoordMode, Mouse, Screen
  If DD_IOControl
  { vX:= 1
    while (vX || vY) && (A_Index < 10) ;added iterations control
    { MouseGetPos, mX, mY
      if (vX:= abs(mX:= X - mX)) > 1 ;log(1) = 0
        if (vX:= vX / log(vX * 1.5)) > 255
          vX:= 255
      if (mX < 0) && (vX)
      { vX:= 256 - vX, DD_MouseStatus |= 0x10 ;xxx1 xxxx
      } else           DD_MouseStatus &= 0xEF ;xxx0 xxxx
    
      if (vY:= abs(mY:= Y - mY)) > 1 ;log(1) = 0
        if (vY:= vY / log(vY * 1.5)) > 255
          vY:= 255
      if (mY > 0) && (vY)
      { vY:= 256 - vY, DD_MouseStatus |= 0x20 ;xx1x xxxx
      } else           DD_MouseStatus &= 0xDF ;xx0x xxxx
     
     ;The BUG - when position bits at status register are set must be cleared !!! 0x100 move mouse at max in negative direction
      DD_PS2command(0xD3, DD_MouseStatus & 0xFF), DD_MouseStatus &= 0xCF ;xx00 xxxx ;FIXED
      DD_PS2command(0xD3,             vX & 0xFF)
      DD_PS2command(0xD3,             vY & 0xFF)
      If WHEELMOUSE
      DD_PS2command(0xD3, 0x00)
  } }
  else MouseMove, X, Y ;added normal MouseMove for better compatibility
}