Page 1 of 1

code works in a window but not in a game

Posted: 29 Jan 2016, 12:11
by jeik
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

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

Posted: 29 Jan 2016, 13:26
by Nextron
Without looking at your code, it probably due to the game being DirectX and fullscreen. Windowed mode should make a difference.

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

Posted: 29 Jan 2016, 15:02
by jeik
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.

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

Posted: 29 Jan 2016, 16:36
by jeik
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

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

Posted: 29 Jan 2016, 17:01
by jeik
didnt help ......

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

Posted: 29 Jan 2016, 18:11
by jeik
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

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

Posted: 29 Jan 2016, 19:04
by Lycos_Rec
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.

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

Posted: 29 Jan 2016, 19:40
by jeik
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