Jump to content

Target a control on an autoit form


Recommended Posts

Hey guys, im trying to pixel search on a autoit form that has a MacromediaFlashPlayerActiveX control on it.

The pixel detection needs to be on the control.

But it seems to not be finding a pixel for some reason.

$Monster is my pixel color and it is a green

$Monster = 0x008E00

Global $WinRect

$penguin_massacre = 'http://blah blah blah.swf'

$Game = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")

$GUIActiveX = GUICtrlCreateObj($Game, 10, 10, 780, 580)

With $Game

.bgcolor = "#000000"

.Movie = $penguin_massacre

.ScaleMode = 2

.Loop = True

.wmode = "Opaque"

ControlFocus("", "", 14433752)
        $WinRect = ControlGetPos("Window", "", "[CLASS:MacromediaFlashPlayerActiveX]")
        $coord = PixelSearch($WinRect[0], $WinRect[1], $WinRect[2] - 100, $WinRect[3], $Monster, 1)
        If Not @error Then
            $coord[0] = $coord[0] + 25
            $coord[1] = $coord[1] + 30
            MouseClick("left", $coord[0], $coord[1], 2, 1)
            Sleep(100)
Link to comment
Share on other sites

Think about it. PixelCoordMode is by default on screen coordinates, and you give PixelSearch() client coordinates.

You should decide on one to use, not mix them that's just confusuing.

Link to comment
Share on other sites

Think about it. PixelCoordMode is by default on screen coordinates, and you give PixelSearch() client coordinates.

You should decide on one to use, not mix them that's just confusuing.

I'm not sure what your trying to say mate.

I'm wanting to do a pixel search over a certain area on the flash object.

Then click the coords of where it was detected.

Isn't pixelsearch what you use for that?

$coord= PixelSearch 100,100,500,600,color,shade

then use

mouseclick left $coord[0],$coord[1]

for some reason it doesn't see the pixel color selected. For that matter it doesn't see any pixel on it.

I know I'm doing sometuig wrong, just can't put my finger on it. I hve done this very thing before. Then stopped messing with autoit for about a year.

Stupid move on my end for doing that....

Link to comment
Share on other sites

Here is the entire code:

My Error is:

Subscript used with non-Array variable.:

MouseClick("left", $coord[0], $coord[1], 3, 1)

MouseClick("left", $coord^ ERROR

Now i have done this several times in other applications and have not had this happen.

I have even looked at other sources of ones where i have done this.

Whats going on here please? I have looked and altered and tried other ways and i still do not understand why it is giving me this error.

#include <GUIConstants.au3>
#Include <Misc.au3>
;~ #NoTrayIcon
Opt("WinWaitDelay", 100)
Opt("WinDetectHiddenText", 1)   ;0=don't detect, 1=do detect
Opt("WinTextMatchMode", 2)      ;1=complete, 2=quick
Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("PixelCoordMode", 2)        ;1=absolute, 0=relative, 2=client
Opt("MouseCoordMode", 2)        ;1=absolute, 0=relative, 2=client
HotKeySet("{DEL}", "Terminate")
HotKeySet("{INSERT}", "ON")
HotKeySet("{HOME}", "OFF")


$bot = 0
$Color = 0x009900
$penguin_massacre = 'http://armorgames.com/files/games/penguin-massacre-4964.swf'


Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ON()
    MsgBox(0, "ON", "The AimBot is ON!", 1)
    $bot = 1
EndFunc   ;==>ON

Func OFF()
    $bot = 0
    MsgBox(0, "OFF", "The AimBot is OFF!", 1)
EndFunc   ;==>OFF

Func FIRE()
    If $bot = 1 Then
        Sleep(100)
        $coord = PixelSearch(19, 119, 700, 536, $Color, 8)
        MouseClick("left", $coord[0], $coord[1], 3, 1);( "button" [, x, y [, clicks [, speed ]]] )
    EndIf
EndFunc   ;==>FIRE

While 1
    $SelectionForm = GUICreate("Penguin Aim Bot", 800, 600, -1, -1)
    $Game = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
    $GUIActiveX = GUICtrlCreateObj($Game, 10, 10, 780, 580)

    With $Game
        .bgcolor = "#000000"
        .Movie = $penguin_massacre
        .ScaleMode = 2
        .Loop = True
        .wmode = "Opaque"
    EndWith
    GUISetState()
    While 1
        Call("FIRE")
    WEnd
;~  Sleep(1000)
WEnd
Link to comment
Share on other sites

You need to check if the pixel was found:

Func FIRE()
    If $bot = 1 Then
        Sleep(100)
        $coord = PixelSearch(19, 119, 700, 536, $Color, 8);, 1, $hWnd)
        If @error = 0 Then MouseClick("left", $coord[0], $coord[1], 3, 1)
    EndIf
EndFunc   ;==>FIRE

..and as AdmiralAlkex, if you're using PixelCoordMode 2 you may want to specify to which window the coordinates are relating.

Link to comment
Share on other sites

OMG your right i left that out and didnt even see my mistake looking at other scripts that worked before.

I knew it has been too long,

Thank you very much my friend.

Well the app runs without a crash, but the code doesnt execute in that area.

Something is still wrong... :S No errors tho.

Edited by £åߥ®Ñth
Link to comment
Share on other sites

#include <GUIConstants.au3>
#Include <Misc.au3>
;~ #NoTrayIcon
Opt("WinWaitDelay", 100)
Opt("WinDetectHiddenText", 1)   ;0=don't detect, 1=do detect
Opt("WinTextMatchMode", 2)      ;1=complete, 2=quick
Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("PixelCoordMode", 2)        ;1=absolute, 0=relative, 2=client
Opt("MouseCoordMode", 2)        ;1=absolute, 0=relative, 2=client
Opt("GUIOnEventMode", 1)
HotKeySet("{DEL}", "Terminate")
HotKeySet("{INSERT}", "ON")
HotKeySet("{HOME}", "OFF")


$bot = 0
$Color = 0x009900
$penguin_massacre = 'http://armorgames.com/files/games/penguin-massacre-4964.swf'

$SelectionForm = GUICreate("Penguin Aim Bot", 800, 600, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
$Game = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
$GUIActiveX = GUICtrlCreateObj($Game, 10, 10, 780, 580)

With $Game
    .bgcolor = "#000000"
    .Movie = $penguin_massacre
    .ScaleMode = 2
    .Loop = True
    .wmode = "Opaque"
EndWith
GUISetState()

While 1
    Sleep(20)
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ON()
    TrayTip("ON", "The AimBot is ON!", 3)
    $bot = 1
    While $bot
        Sleep(20)
        $coord = PixelSearch(60, 120, 650, 550, $Color, 0, 1, $SelectionForm)
        If @error = 0 Then MouseClick("left", $coord[0]+50, $coord[1]+20, 3, 1)
    WEnd
EndFunc   ;==>ON

Func OFF()
    $bot = 0
   TrayTip("OFF", "The AimBot is OFF!", 3)
EndFunc   ;==>OFF

Funny game. ;)

Link to comment
Share on other sites

Well here is another attempt by using the browser.

I am having allot of trouble figuring out what im doing wrong people.

I know someone can see what im doing wrong, All i want is input. Negative or Positive i do not care.

This one finds a pixel, but does not send the click.

I have even used the regular old MouseClick as well.

Commented out OPT for coord mode and used all three setting on it as well.

With INFO tool i have done the same.

Im stuck.........I really need someone help on this crap.

Also, can you tell me why my HotKeySet doesnt work?

I had to set my variable $bot to 1 because the hot keys are not working.

This is nothing more then a silly little flash game.

Im just using it to refresh myself with autoit and having a ruff time of it.

Code:

#include <IE.au3>
#include <Misc.au3>
Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 2)

$bot = 1

$oIE = _IECreate("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf")
Sleep(1000)
;~ _IENavigate($oIE, "http://cache.armorgames.com/files/games/penguin-massacre-4964.swf")
;~ Sleep(2000)
WinWait("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf - Windows Internet Explorer", "")
If Not WinActive("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf - Windows Internet Explorer", "") Then WinActivate("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf - Windows Internet Explorer", "")
WinWaitActive("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf - Windows Internet Explorer", "")
WinMove("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf - Windows Internet Explorer", "", 0, 0, 800, 600)
Sleep(1000)

;~ PixelSearch(left, top, right, bottom, color [, shade-variation [, step [, hwnd]]] ) add a "step" for faster pixel searching.
While $bot = 1
    Call("FIRE")
WEnd



Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func AimOn()
    $bot = 1
EndFunc   ;==>AimOn

Func AimOff()
    $bot = 0
EndFunc   ;==>AimOff

Func FIRE()
    $coord = PixelSearch(116, 202, 575, 516, 0x009900, 10, 25)
    If Not @error Then
;~ ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )
        ControlClick("http://cache.armorgames.com/files/games/penguin-massacre-4964.swf", "", "[CLASS:MacromediaFlashPlayerActiveX; INSTANCE:1]", "left", 2, $coord[0], $coord[1])

;~      MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    EndIf
EndFunc   ;==>FIRE
Edited by £åߥ®Ñth
Link to comment
Share on other sites

Ok having the same thing happen on what should be very simple!

Is this site dead now? I used to get a reply fairly quick in this place.

This should detect the color on the windows calculator button. ;)

It just sits there and no message box showing coords.

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 2)
WinWait("Calculator", "")
If Not WinActive("Calculator", "") Then WinActivate("Calculator", "")
WinWaitActive("Calculator", "")

While 1
    $control = ControlGetFocus("[CLASS:Button; INSTANCE:22]")
    Call("Look")
WEnd

Func Look()
    $coord = PixelSearch(3, 3, 32, 24, 0xFF00FF, 3, $control)
     
    If Not @error Then
        MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    EndIf
EndFunc   ;==>Look
Edited by £åߥ®Ñth
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...