code works in a window but not in a game

Ask gaming related questions (AHK v1.1 and older)
jeik
Posts: 14
Joined: 27 Jan 2016, 15:54

code works in a window but not in a game

29 Jan 2016, 12:11

hello, Im trying to catch a colorvalue at a fixed position for a moving object in a game.

Code works for windows (desktop) who has the colorvalue but not in the game.

Im using the colorvalue's pixelposition found by printscreen, ingame. Position of searched pixel and its color was found using Paintshop.

eh, the game runs if full screen mode .

Anyone can helpout here? Code below.

regards

Code: Select all

	#SingleInstance, force
	#InstallKeybdHook
	#InstallMouseHook
	DetectHiddenWindows, On
	CoordMode, Mouse, Relative ; needed for mouseclickdrag
;	CoordMode, Tooltip, Screen
	targetcolor = 0xF6F6F6
	
	
WinActivate, XXXX XXXX
WinSet, AlwaysOnTop, ON, XXXX XXXX
	
!j::

loopen:

PixelSearch, Px, Py, 99, 1014, 102, 1016, 0xf6f6f6, 3, Fast
if ErrorLevel
    goto, loopen
else
    MsgBox, A color within 3 shades of variation was found at X%Px% Y%Py%


WinSet, AlwaysOnTop, OFF, XXXX XXXX

!^r::
	MainGuiClose:
		if (winid !="")   ; Turn off AllwaysOnTop in case script is closed while test is running.
			WinSet, AlwaysOnTop, OFF, XXXX XXXX
		ExitApp

 
 return
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: code works in a window but not in a game

29 Jan 2016, 13:26

Without looking at your code, it probably due to the game being DirectX and fullscreen. Windowed mode should make a difference.
jeik
Posts: 14
Joined: 27 Jan 2016, 15:54

Re: code works in a window but not in a game

29 Jan 2016, 15:02

Nextron wrote:Without looking at your code, it probably due to the game being DirectX and fullscreen. Windowed mode should make a difference.
k,ty, Ill try that.
jeik
Posts: 14
Joined: 27 Jan 2016, 15:54

Re: code works in a window but not in a game

29 Jan 2016, 16:36

Nextron wrote:Without looking at your code, it probably due to the game being DirectX and fullscreen. Windowed mode should make a difference.
Hi.

Noticed following, for same mouse coordinate, using spywindow:

Absolute coord system: 96,1028
Relative coord system: 104,1047
Client coord system: 96,1016

So fare Ive tried the first and third coords (full screen/window mode) without any luck.
Ill try the second coord system, adding 8 pixels to x position and 19 to y positon.

Ill have a look in helpfile how to deal with the 3 coordinate systems.

regards
jeik
Posts: 14
Joined: 27 Jan 2016, 15:54

Re: code works in a window but not in a game

29 Jan 2016, 17:01

didnt help ......
jeik
Posts: 14
Joined: 27 Jan 2016, 15:54

Re: code works in a window but not in a game

29 Jan 2016, 18:11

just donated to Pulover and downloaded his macro tool application.
Will try that tomorrow.

I see he's export to akh file sets window pixel coordmode within local loop that uses PixelSearch

I asume that means ahk reads game's x,y positions running game in windowmode(?)

regards
Lycos_Rec
Posts: 3
Joined: 29 Jan 2016, 16:59

Re: code works in a window but not in a game

29 Jan 2016, 19:04

Perhaps you could try making a dummy script that pops up a message box with the coordinates of your current mouse position, and run that at the desired area in the game. Then you'd know what coordinates to hard code, or at least the coordinates the dummy script reads would give you some clue what coordinates the program is reading.
jeik
Posts: 14
Joined: 27 Jan 2016, 15:54

Re: code works in a window but not in a game

29 Jan 2016, 19:40

Solved :)
Used parts of the pulover's macro tool.
Works in game's full screen mode.
The positions of pixelsearch was taken from ingame printscreen when game was in window mode, loaded into PaintShop where positions and colors were found.

heres the code:

Code: Select all

#NoEnv
; SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
DetectHiddenWindows On
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1

		
!j::

Macro1:
Loop
{
	CoordMode, Pixel, Window
	PixelSearch, FoundX, FoundY, 99, 1026, 102, 1028, 0x6F6F6F, 1, Fast RGB
	If ErrorLevel = 0
		SoundBeep
}
Until ErrorLevel = 0
Return


Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 79 guests