AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

need help finishing up this scripts problems.

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Cyber



Joined: 10 Mar 2009
Posts: 86
Location: Nsw/Syd/Kiama

PostPosted: Tue Dec 08, 2009 3:10 pm    Post subject: need help finishing up this scripts problems. Reply with quote

Hey, i made a post about 2 weeks inquiring for help. and i got alot, so thanks guys, iv only just been able to get back to ahk so imim gona post my script at the end of my questions=]

first question/problem is: the guii window named "hitbox" is not always ontop altho i specificuly added a always on top code.
secondquestion/problem is: the pixel search i belive also is not on the top window. (ps its a ful screen game fyi)
third problem: this is desighned for a fullscreen game. and when this full screen game is open the software prety much pretends theres nothing there... when this game isnt current the script works fine, it finds the color and clicks it as per usual.

a quick reminder sumery of what this program is ment to do:

this program is ment to be a small gui window box shape, about 30 by 30 pixels. inside the area of 30-30 pixels is a pixel search, (the gui window is for show... it shows the user were the pixel search is) as i was saying inside the 30-30 pixel area is a pixelsearch, this is ment to pick a up the color green...ish, it is a bright green/mustard green color, (refer to the script for the color id)
once it finds this color it, sends the mouse to that location and clicks. then returns... and starts the loop again, searching for that color.

and example of why i wld need this is:

its made for a game called quake , it emulates a crosshair (the gui box) anywere isnide my custom crosshair is a pixel search... and the mouse clicks the pixel if its detecteded yatayatayta..u get the point =]

i think the reason why the pixel search wont work on the game is maby becuse of shades on the models in the game, they look bright green/yellow. but.. when i take the color of an exact part of a model its always a mustardy color or a limey color... so maby shades?

i have no clue why the script doesnt always run on top...?

(ps, leaf me was helping me with this script so if u see "leaf me's choic" throught this script just ignore it) =]=]=]=]=]=]=]

Code:

;============================================================================
; set coordinates for the screen so GUI position, search and clicks will align

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

;-----------the gui hitbox---------------------------------------------------
bDim = 35 ; Change this to desired size.
;bDim = 5 ; Change this to desired size.
xPos = % (A_ScreenWidth/2) - bDim
yPos = % (A_ScreenHeight/2) - bDim

;============================================================================
; Leef_me's choice of pixel color
pixel_color= 0x0000FF ; search for red ; BLUE/GREEN/RED order

;Cyber's choice of pixel color
pixel_color= 0xC3CCC7 ; <----------------- Please edit this line for Cyber's choice

;============================================================================
; If you want to test on an image you can enable this
;image = shot0027.bmp ; <------filename goes here
;gui, add, picture, , %image%

Gui, +alwaysontop
Gui, -Caption Border AlwaysOnTop ToolWindow

; RED/GREEN/BLUE order
Gui, Color, C0C0C0
;Gui, Color, ff0000 ; <----- Leef_me's choice of GUI fill color

Gui, Show, NA W%bDim% H%bDim% X%xPos% Y%yPos%, hitBox

WinWait, hitBox
WinSet, TransColor, C0C0C0 255, hitBox

;============================================================================
; get the location of the box, without relying on the above xpos & ypos
; report actual location of the window, and save for imagesearch

WinGetPos , X, Y, Width, Height, hitBox
msgbox !%Title% x%X% Y%Y% W%Width% H%Height%! `n wanted upper_left-> X%xPos% Y%yPos% `n press OK to start search
;return

;================================================================================
;start the search

settimer, find_pixel,-1 ; wait 0.001 seconds before searching
return

;============================================================================

find_pixel:

b:=A_TickCount ; <--- measure the time the pixelsearch takes

pixelSearch  , TL , BR , X, Y, X+Width, Y+Height, pixel_color , 20 ; BLUE/GREEN/RED order

c:=A_TickCount ; <--- measure the time the pixelsearch takes
d:=c-b

;============================================================================
; for testing, show a tooltip instead of causing a mouseclick

;tooltip, !!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

; the next line shows 1/1000 second, 0 if found, x and y coordinates
tooltip, !%d%!!%errorlevel%!%TL%!%BR%!, xpos+50, ypos

;MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]

;If ErrorLevel = 0    ; if pixel was found
   ;MouseClick , left , TL , BR , 1 , 10

settimer, find_pixel , -200 ; wait 0.2 seconds between searches

return

;================================================================================
f3::   ; get the color of the pixel at the mouse cursor location
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

; coodinates are relative to screen based on CoordMode used at top of script

MouseGetPos, xx , yy
PixelGetColor, cc, xx, yy
tooltip %xx% %yy% %cc%
return
 
;----------------------------end statemnts------------------------------------
esc::
^z::ExitApp


_________________
---{+.-}---
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group