Jump to content

macro only on certain windows


Recommended Posts

I have this code

While 1

$var1 = PixelSearch ( 642, 102, 646, 107, 0x181818 )

$var2 = PixelSearch ( 642, 102, 646, 107, 0xAF8840 )

If NOT $var1 OR $var2 Then

Send("{o}")

EndIf

Sleep(250)

WEnd

This is for health bar in a game.... imagename... hon.exe

and i also have other codes for automatic attacking.

But when i use it the window must be at front.

is there anyway i can do this without making the game window on top?

for example, i want to surf on the internet while the macro is working.

PS.. i am not going to block the pixel part.. for example, when i surf it will not block the game screen

If there is a such way...

please help me with above code and also a general code so that i can apply it to other codes as well.

thank you in advance

Edited by Mutalgaettae
Link to comment
Share on other sites

You need to use the last parameter of PixelSearch to specify the handle of the game window.

$hWndGame = WinGetHandle( "Insert game window title here")
While 1
 $var1 = PixelSearch ( 642, 102, 646, 107, 0x181818, 0, 1, $hWndGame)
 $var2 = PixelSearch ( 642, 102, 646, 107, 0xAF8840, 0, 1, $hWndGame)
 If NOT ($var1 OR $var2) Then
ControlSend ( "Insert game window title here", "", "", "{o}" )
EndIf
 Sleep(250)
WEnd
Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

You need to use the last parameter of PixelSearch to specify the handle of the game window.

$hWndGame = WinGetHandle( "Insert game window title here")
While 1
 $var1 = PixelSearch ( 642, 102, 646, 107, 0x181818, 0, 1, $hWndGame)
 $var2 = PixelSearch ( 642, 102, 646, 107, 0xAF8840, 0, 1, $hWndGame)
 If NOT ($var1 OR $var2) Then
ControlSend ( "Insert game window title here", "", "", "{o}" )
EndIf
 Sleep(250)
WEnd
I believe that still wont work, I may be wrong but when the application is minimized then there is no rendering taken place thus no pixels. I think its (impossible?) to detect pixels unless the window is active or being displayed.
Link to comment
Share on other sites

It worked perfectly!

however there is a weird problem.

i use that for automatic health.

when my health is low enough to trigger the code,

it doesn't fill the health.

however, during that time if i open a conversation box, i can see o constantly typing...

so it does work in game while i browse...

but y not actually heal?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...