Jump to content
Sign in to follow this  
Kanta

Pixelsearch help please

Recommended Posts

Kanta

Hello. I've been searching this site and the web in general for the last 4 days to try and find a solution to my current issue. The problem being I really do not know what I'm doing, where to start what to search for and the list goes on. Every example I find for possible solutions rely on the script initially opening the window. I can't find anything on how to use any sort of code with an already loaded window and I have no clue how to adapt the code. Here's what I'm trying to do:

In a game that I am playing, I need to do a pixel search for certain colors for the game to use certain potions. I can't tell you how many different code lines I have tried with this. I can get it to successfully detect the color and use the potion. The hitch that I can't figure out is that if I move the window it is no longer checking the right pixels. I have tried setting the pixelcoordmode, mousecoordmode and so on but nothing is working. I've tried making sure the window is active before anything is done but apparently I can't get that right either. I even went so far as to figure out how to rename the window via AutoIt to try and make my job easier, and I succeeded to get it to change the name, but in the end it didn't help me any. I see there's an $hWnd variable or something that can be set in the pixelsearch but I can't figure out how to get this to even come close to working. Seriously, I'm trying, I'm searching and I'm failing miserably.

#include <WinAPI.au3>
WinSetTitle("[CLASS:Gamebryo Application]", "", "Changed name")
_WinAPI_SetFocus("Changed name")
$hwnd = WinGetHandle("Changed name")
Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)
 
##########  CUTTING OUT IRRELEVANT LOOP CODE ##########

   ;--------------------------------------------------------------------
   ; Check for Blue Color and if we don't find it, cast a mana pot
   ;--------------------------------------------------------------------
    $myColor = PixelSearch(150, 52, 150, 52, 0x112A8E, 99, 1, $hwnd)
    ;we get an error if the color was *not* found
    If @error Then
     ;F4 is the key for the mana pot
     _SendEx("{F3}");
    EndIf

How do I make this script use the window coordinates that I have set in here? No matter what I have tried it seems to keep using desktop coordinates. I used client coord mode to obtain the values I used in the script. The first 6 lines are outside the loop code, the following lines after my comment are within the loop code.

Share this post


Link to post
Share on other sites
Melba23

Kanta,

Welcome to the AutoIt forum. ;)

Unfortunately you appear to have missed the Forum Rules on your way in. Please read them now and then you will understand why you will get no help and this thread will now be locked. :)

See you soon with a legitimate question I hope. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×