Jump to content
Sign in to follow this  
autocomplex

Fix the fast Moving Box

Recommended Posts

autocomplex

I made a script that follows a color on a set screen with a box. However, the box is very fidgety and moves like back and forth between the objects that have the color. I need to make this stop ... lol. I thought maybe I could get 3 or 4 different scans going from different locations and get an average of the location. (Like they get the location of Earthquakes.) Any suggestions on how to fix this, or implement what I've said above?

Here's the Code incase its somthing I've written.

#NoTrayIcon
    #include <GUIConstants.au3>
    #include <Misc.au3>

HotKeySet("!^x", "Abort")

Global $StartX = 0
Global $StartY = 0
Global $x = $StartX, $y = $StartY
Global $ScanWidth = 100, $ScanHeight = 100
Global $SmallMoveMode = True
Global $smallmove = true
Global $ScanColor = 9003840
Global $SleepScan = 50
Global $AppTitle = "Beta Testing ..."
    
    $GUI = GUICreate($AppTitle,1,1,$x,$y,$WS_POPUP)
    GUISetState(@SW_LOCK)
    WinSetOnTop($GUI,"",1)
    
    $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    
    While 1
        ScanScreen()
    WEnd
    
    
    Func ScanScreen()
                            $smallMoveMode = True

                    $MousePos = PixelSearch(400,250,600,350,$ScanColor, 8)
                    If IsArray($MousePos)Then
                    WinMove($Top,"", $MousePos[0],$MousePos[1])
                    WinMove($Left,"", $MousePos[0],$MousePos[1])
                    WinMove($Right,"", $MousePos[0]+100,$MousePos[1])
                    WinMove($Bottom,"", $MousePos[0],$MousePos[1]+100)
                
                        $x = $MousePos[0]
                        $y = $MousePos[1]
                    EndIf
                    Sleep(10)
            EndFunc
            
    Func Abort()
    AdlibDisable()
    HotKeySet("!^x")
    SplashTextOn("Alert", "Emergency Exit", 200,30)
    Sleep(800)
    Exit
    EndFunc

Share this post


Link to post
Share on other sites
autocomplex

I changed it to this, but I'm getting all kinds of Errors.

Func ScanScreen()
                            $smallMoveMode = True

                    $MousePos1 = PixelSearch(350,150,775,480,$ScanColor, 8)
                    $MousePos2 = PixelSearch(550,350,575,280,$ScanColor, 8)
                    $MousePos3 = PixelSearch(750,550,375,80,$ScanColor, 8)
                    
                    If IsArray($MousePos1) Then
                    WinMove($Top,"", $MousePos1[0]+$MousePos2[0]+$MousePos3[0]/3,$MousePos1[1]+$MousePos2[1]+$MousePos3[1]/3)
                    WinMove($Left,"", $MousePos1[0]+$MousePos2[0]+$MousePos3[0]/3,$MousePos1[1]+$MousePos2[1]+$MousePos3[1]/3)
                    WinMove($Right,"", $MousePos1[0]+$MousePos2[0]+$MousePos3[0]/3+100,$MousePos1[1]+$MousePos2[1]+$MousePos3[1]/3)
                    WinMove($Bottom,"", $MousePos1[0]+$MousePos2[0]+$MousePos3[0]/3,$MousePos1[1]+$MousePos2[1]+$MousePos3[1]/3+100)
                
                        $x = $MousePos1[0]+$MousePos2[0]+$MousePos3[0]/3
                        $y = $MousePos1[1]+$MousePos2[1]+$MousePos3[1]/3
                    EndIf
                    Sleep(10)
            EndFunc

Share this post


Link to post
Share on other sites
bogQ

inline853 you dont have to post new topic 4 every problem in the same script, you can post your other problem 4 the same script on the old topic, so that others can see how you started and where r you gooign

your problem is red box becose she is makeing red color to go ower your pixelsearch, try with no box to see if the mouse is chaseing that pixel

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>

HotKeySet("!^x", "Abort")

Global $StartX = 0
Global $StartY = 0
Global $x = $StartX, $y = $StartY
Global $ScanWidth = 100, $ScanHeight = 100
Global $SmallMoveMode = True
Global $smallmove = true
Global $ScanColor = "0xFFFFFF" ;<== changed your collor 4 testing put it back on oldone
Global $SleepScan = 50
Global $AppTitle = "Beta Testing ..."

While 1
    ScanScreen()
WEnd

Func ScanScreen()
    $smallMoveMode = True
    $MousePos = PixelSearch(400,250,600,350,$ScanColor, 8)
    If IsArray($MousePos)Then
        $x = $MousePos[0]
        $y = $MousePos[1]
        MouseMove($x,$y)
    EndIf
    Sleep(10)
EndFunc

Func Abort()
    AdlibDisable()
    HotKeySet("!^x")
    SplashTextOn("Alert", "Emergency Exit", 200,30)
    Sleep(800)
    Exit
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
bogQ

or you can do -20 on your coordinates of box so that pixelsearch will not go ower the red line and to reset position if pixel not finded pls

try it and telme is it now ok?

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>

HotKeySet("!^x", "Abort")

Global $StartX = 0
Global $StartY = 0
Global $x = $StartX, $y = $StartY
Global $ScanWidth = 100, $ScanHeight = 100
Global $SmallMoveMode = True
Global $smallmove = true
Global $ScanColor = "0xFFFFFF" ;<== changed your collor 4 testing put it back on oldone
Global $SleepScan = 50
Global $AppTitle = "Beta Testing ..."

$GUI = GUICreate($AppTitle,1,1,$x,$y,$WS_POPUP)
GUISetState(@SW_LOCK)
WinSetOnTop($GUI,"",1)
$Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
GUISetBkColor(0xFF0000)
GUISetState()
$Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
GUISetBkColor(0xFF0000)
GUISetState()
$Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
GUISetBkColor(0xFF0000)
GUISetState()
$Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
GUISetBkColor(0xFF0000)
GUISetState()

While 1
    ScanScreen()
WEnd

Func ScanScreen()
    $smallMoveMode = True
    $MousePos = PixelSearch(400,250,600,350,$ScanColor, 8)
    Select
    case Not IsArray($MousePos)
        WinMove($Top,"", $x,$y + 40)
        WinMove($Left,"", $x,$y + 40)
        WinMove($Right,"", $x + $ScanWidth - 2,$y + 40)
        WinMove($Bottom,"", $x,$y + 40 + $ScanHeight)

    Case IsArray($MousePos)
        WinMove($Top,"", $MousePos[0]-49,$MousePos[1]-49)
        WinMove($Left,"", $MousePos[0]-49,$MousePos[1]-49)
        WinMove($Right,"", $MousePos[0]+49,$MousePos[1]-49)
        WinMove($Bottom,"", $MousePos[0]-49,$MousePos[1]+49)
        MouseMove($MousePos[0],$MousePos[1])
    EndSelect
EndFunc

Func Abort()
    AdlibDisable()
    HotKeySet("!^x")
    SplashTextOn("Alert", "Emergency Exit", 200,30)
    Sleep(800)
    Exit
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
bogQ

k it fixed ... I put in the red box, so I could see what it was doing lol. By the way I am actually adding on to a script started by Manadar. I have made much progress ... =)

i reedited my last scriptpost try it now ^^

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.