Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Array.au3>
- ; BINDINGS
- HotKeySet("{F7}", "_exit")
- Global Const $iTrue = 1
- Global Const $iFalse = 0
- ; Minimap
- Global Const $arrMiniMap[4] = ["8", "808", "269", "1067"]
- ; Lane Corridors
- Global Const $arrCorridorRadSafe[4] = ["61", "1039", "256", "1057"] ; Radiant Safe 61,1039 | 256,1057
- Global Const $arrCorridorDireOff[4] = ["239", "881", "258", "1054"] ; Dire Offlane 239,881 | 258,1054
- Global Const $arrCorridorDireSafe[4] = ["20", "820", "202", "840"] ; Dire Safe 20,820 |202,840
- Global Const $arrCorridorRadOff[4] = ["9", "824", "35", "1001"] ; Radiant Offlane 9,824 | 35,1001
- Global Const $arrCorridorMid[4] = ["53", "865", "213", "1029"] ; Mid Lane 53,865 | 213,1029
- ; Player Colors
- Global Const $arrColorPlayersRadiant[5] = ["2777816", "5824422", "11206827", "13881608", "14572544"]
- Global Const $arrColorPlayersDire[5] = ["14578857", "14513320", "9346622", "28699", "9394944"]
- Global Const $iColorPlayerCircle = 15921906
- Global Const $iColorLevelUp = 14269272
- Global Const $iColorHealth = 4502831
- Global Const $iColorNeutralCamp = 6964480
- Global Const $iColorNeutralUnit = 11184810
- ; Radiant Camp Positions
- Global Const $arrRadiantCamps_X[9] = ["228", "195", "145", "134", "106", "141", "73", "48", "95"]
- Global Const $arrRadiantCamps_Y[9] = ["1017", "1023", "1023", "997", "1017", "973", "922", "945", "952"]
- ; Radiant Camp Positions
- Global Const $arrDireCamps_X[9] = ["64", "97", "107", "166", "137", "123", "184", "221", "216"]
- Global Const $arrDireCamps_Y[9] = ["878", "852", "858", "880", "879", "899", "937", "926", "944"]
- ;Buildings
- Global Const $iColor_Frindly_Building = 8385024
- Global Const $iColor_Enemy_Building_Fog = 16711680
- Global Const $iColor_Enemy_Building = 16711680
- ; Safelane Mid Offlane
- Global Const $arrRadiant_Tower_PosX[9] = ["228", "137", "68", "111", "77", "55", "26", "28", "20"]
- Global Const $arrRadiant_Tower_PosY[9] = ["1049", "1051", "1049", "964", "985", "1012", "905", "955", "1000"]
- Global Const $arrDire_Tower_PosX[9] = ["54", "139", "204", "149", "184", "216", "252", "252", "254"]
- Global Const $arrDire_Tower_PosY[9] = ["830", "830", "834", "925", "898", "868", "969", "932", "884"]
- ; Units
- Global Const $iColor_Frindly_Creep = 5415168
- Global Const $iColor_Enemy_Unit = 11141120
- Global $iColorPlayer = 0
- ;-------------------------------------------
- ; @@@@@@@ MAIN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;-------------------------------------------
- While 1
- Sleep(100)
- _main()
- WEnd
- Func _main()
- ; Random Test Code
- $posPlay = _findUnitPosition($arrMiniMap,$arrColorPlayersDire[0])
- $posE = _findNextWave($posPlay)
- _AttackAndMovement(1,$posE)
- _tt("Pos Player | X: " & $posPlay[0] & " Y: " & $posPlay[1])
- $posCamp = _findNextCamp($posPlay,$arrDireCamps_X,$arrDireCamps_Y)
- _AttackAndMovement(1,$posCamp)
- EndFunc ;==>_main
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _tt
- ; Syntax ........: _tt($sToolTip)
- ; Parameters ....: $sToolTip - String to Display
- ; Example .......: No
- ; ===============================================================================================================================
- Func _tt($sToolTip)
- If UBound($sToolTip) = 2 Then
- ToolTip("X: " & $sToolTip[0] & "Y: "& $sToolTip[1], 0, 0)
- Else
- ToolTip($sToolTip, 0, 0)
- EndIf
- EndFunc ;==>_tt
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _generateBuildingState
- ; Description ...: Iterates building position arrays and checks if up or down
- ; Syntax ........: _generateBuildingState($bIsFrindly, $arrX, $arrY, $iArrLengths)
- ; Parameters ....: $bIsFrindly - 0 = enemy; 1 = Frindly
- ; $arrX - Array with X Coordinates
- ; $arrY - Array with Y Coordinates
- ; Return values .: Array with Building States; 0 or 1
- ; ===============================================================================================================================
- Func _generateBuildingState($bIsFrindly, $arrX, $arrY)
- ; Exception Handling
- If IsArray($arrX) And IsArray($arrY) And UBound($arrX) = UBound($arrY) Then
- Local $iArrLength = UBound($arrX)
- ; Initialize Array Range
- Local $iBuildingStates[$iArrLength]
- ; Check building state for every Index
- For $i = 0 To $iArrLength - 1
- Local $pos_current = _buildPoint($arrX[$i], $arrY[$i])
- $iBuildingStates[$i] = _checkBuildingState($bIsFrindly, $pos_current)
- Next
- Return $iBuildingStates
- Else
- _tt(" _generateBuildingState: Wrong Data Type or Array Length not Matching")
- Return 0
- EndIf
- EndFunc ;==>_generateBuildingState
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _checkBuildingState
- ; Description ...: Checks a Coordinate on Minimap for Building status
- ; Syntax ........: _checkBuildingState($bIsFrindly, $Pos)
- ; Parameters ....: $bIsFrindly - 0 = Enemy; 1 = Frindly; Use 0,1
- ; $Pos - Building position on Minimap
- ; Return values .: True if Up / False if down
- ; ===============================================================================================================================
- Func _checkBuildingState($bIsFrindly, $Pos)
- ; Check Exceptions
- If IsArray($Pos) And ($bIsFrindly = 0 Or $bIsFrindly = 1) Then
- ; Frindly Building
- If $bIsFrindly = 1 Then
- If PixelGetColor($Pos[0], $Pos[1]) = $iColor_Frindly_Building Then
- _tt("Frindly Building Up")
- Return 1
- Else
- _tt("Frindly Building Down")
- Return 0
- EndIf
- ; Enemy Building
- ElseIf $bIsFrindly = 0 Then
- If PixelGetColor($Pos[0], $Pos[1]) = $iColor_Enemy_Building Or $iColor_Enemy_Building_Fog Then
- _tt("Enemy Building Up")
- Return 1
- Else
- _tt("Enemy Building Down")
- Return 0
- EndIf
- EndIf
- Else
- ; Exception
- _MsgBox("_checkBuildingState Wrong Parameters")
- Exit
- EndIf
- EndFunc ;==>_checkBuildingState
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _findNextCamp
- ; Description ...: Returns nearest unfarmed creep camp
- ; Syntax ........: _findNextCamp($posPlayer,$arrCampsX,$arrCampsY)
- ; Parameters ....: $posPlayer - Current Player Position
- ; $arrCampsX - Array with X coordinates
- ; $arrCampsY - Array with Y coordinates
- ; Return values .: $arrPositions[$i] - Position of the nearest farmable camp
- ; Remarks .......: Determines and returns the position of the next free camp of given creep camps
- ; ===============================================================================================================================
- Func _findNextCamp($posPlayer,$arrCampsX,$arrCampsY)
- ; Dummy or Backup Return
- Local Static $posBackup
- Local $iLength = UBound($arrCampsX)
- ; Build array with all point positions
- Local $arrPositions[UBound($arrCampsX)]
- Local $posTemp
- $arrPositions = _buildPointArray($arrCampsX,$arrCampsY)
- $posBackup = $arrPositions[0]
- ; Array for Distances
- Local $arrDistances [UBound($arrPositions)]
- Local $iDistanceTemp
- ; Calculate all distances
- For $i = 0 To UBound($arrPositions) - 1
- $posTemp = _buildPoint($arrCampsX[$i],$arrCampsY[$i])
- $iDistanceTemp = _calculatePointDistance($posPlayer,$posTemp)
- $arrDistances[$i] = $iDistanceTemp
- Next
- ; Bubble Sort
- ; Sort Distances and adjust Position array to match distance array
- Local $iTemp
- Local $bSwapped = True
- While $bSwapped
- $bSwapped = False
- For $i = 0 To $iLength - 2
- If $arrDistances[$i] > $arrDistances[$i+1] Then
- ; Swap
- $iTemp = $arrDistances[$i]
- $arrDistances[$i] = $arrDistances[$i+1]
- $arrDistances[$i+1] = $iTemp
- ; Swap
- $posTemp = $arrPositions[$i]
- $arrPositions[$i] = $arrPositions[$i+1]
- $arrPositions[$i+1] = $posTemp
- $bSwapped = True
- EndIF
- Next
- WEnd
- ; Iterate over all Positions until farmable position is found
- For $i = 0 To $iLength - 1
- ; When not at camp and camp exist, then return cordinates
- If Not _checkPointProximity($posPlayer,$arrPositions[$i]) and (_MiniMapMarkerExist($iColorNeutralCamp,$arrPositions[$i],4) or _MiniMapMarkerExist($iColorNeutralUnit,$arrPositions[$i],4)) Then
- $posBackup = $arrPositions[$i]
- Return $arrPositions[$i]
- EndIf
- Next
- _tt("Wit camps to Spawn")
- Sleep(5000)
- Return _findNextCamp($posPlayer,$arrCampsX,$arrCampsY)
- EndFunc ;==>_findNextCamp
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _findNextWave
- ; Description ...: Finds nearest position of a creep wave
- ; Syntax ........: _findNextWave($posPlayer)
- ; Parameters ....: $posPlayer - Current Player Positions
- ; Return values .: $arrPositions[$i] - Position of the nearest visible wave
- ; Remarks .......: Determines and returns the position of the next visible wavw
- ; ===============================================================================================================================
- Func _findNextWave($posPlayer)
- _TT("Find nearest Wave")
- ; Variables
- Local Static $posLastSeenWave
- Local $arrDistances[3]
- Local $iLength = UBound($arrDistances)
- Local $arrEquilibriumPositions[3]
- Local $posSafe
- Local $posMid
- Local $posOff
- ; Scan Safe Lane
- $posSafe = _scanLaneEquilibrium($arrCorridorDireSafe)
- If IsArray($posSafe) Then
- $arrEquilibriumPositions[0] = $posSafe
- ElseIf Not IsArray($posSafe) Then
- $posSafe = _scanLaneEquilibrium($arrCorridorRadOff)
- $arrEquilibriumPositions[0] = $posSafe
- EndIF
- ; Scan Mid Lane
- $posMid = _scanLaneEquilibrium($arrCorridorMid)
- If IsArray($posMid) Then
- $arrEquilibriumPositions[1] = $posMid
- EndIf
- ; Scan Off Lane
- $posOff = _scanLaneEquilibrium($arrCorridorDireOff)
- If IsArray($posOff) Then
- $arrEquilibriumPositions[2] = $posOff
- ElseIf Not IsArray($posOff) Then
- $posOff = _scanLaneEquilibrium($arrCorridorRadSafe)
- $arrEquilibriumPositions[2] = $posOff
- EndIf
- ; Calculate distances for returned Arrays
- For $i = 0 To UBound($arrEquilibriumPositions) - 1
- Local $posTemp = $arrEquilibriumPositions[$i]
- If IsArray($posTemp) Then
- Local $iDistanceTemp = _calculatePointDistance($posPlayer,$posTemp)
- $arrDistances[$i] = $iDistanceTemp
- Else
- $arrDistances[$i] = 0
- EndIf
- Next
- ; Bubble Sort
- ; Sort Distances and adjust Position array to match distance array
- Local $iTemp
- Local $bSwapped = True
- While $bSwapped
- $bSwapped = False
- For $i = 0 To $iLength - 2
- If $arrDistances[$i] > $arrDistances[$i+1] Then
- ; Swap
- $iTemp = $arrDistances[$i]
- $arrDistances[$i] = $arrDistances[$i+1]
- $arrDistances[$i+1] = $iTemp
- ; Swap
- $posTemp = $arrEquilibriumPositions[$i]
- $arrEquilibriumPositions[$i] = $arrEquilibriumPositions[$i+1]
- $arrEquilibriumPositions[$i+1] = $posTemp
- $bSwapped = True
- EndIF
- Next
- WEnd
- ; Return Lowest Index that is not 0
- For $i = 0 To Ubound($arrEquilibriumPositions) - 1
- If IsArray($arrEquilibriumPositions[$i]) Then
- $posLastSeenWave = $arrEquilibriumPositions[$i]
- Return ($arrEquilibriumPositions[$i])
- EndIf
- Next
- ; NEEDS TO BE MODIFIED
- If IsArray($posLastSeenWave) Then
- Return $posLastSeenWave
- Else
- Return False
- EndIf
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _scanLaneEquilibrium
- ; Description ...: Scans a given lane corridor for creep eqilibrium
- ; Syntax ........: _scanLaneEquilibrium($arrLane)
- ; Parameters ....: $arrLane - An array of unknowns.
- ; Return values .: Equilibrium Position or 0
- ; ===============================================================================================================================
- Func _scanLaneEquilibrium($arrLane)
- Local $arrEquilibriumPositions
- $arrEquilibriumPositions = _findUnitPosition($arrLane, $iColor_Enemy_Unit)
- If IsArray($arrEquilibriumPositions) and _MiniMapMarkerExist($iColor_Frindly_Creep,$arrEquilibriumPositions, 15) Then
- Return $arrEquilibriumPositions
- Else
- Return 0
- EndIf
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _findUnitPosition
- ; Description ...: Find Unit position of a given color on minimap
- ; Syntax ........: _findUnitPosition($arrSearchRange, $iColor)
- ; Parameters ....: $arrSearchRange - An array of TOPLEFT XY and BOTTOMRIGHT XY.
- ; $iColor - Color value of Unit
- ; Return values .: Unit Position on Minimap / False
- ; ===============================================================================================================================
- Func _findUnitPosition($arrSearchRange, $iColor)
- ; Exception Handling
- If IsArray($arrSearchRange) Then
- ; Search for Unit
- Local $posUnit
- Local Static $posBackUp
- $posUnit = PixelSearch($arrSearchRange[0], $arrSearchRange[1], $arrSearchRange[2], $arrSearchRange[3], $iColor, 3)
- If IsArray($posUnit) Then
- $posBackUp = $posUnit
- Return $posUnit
- ElseIf Not @error Then
- _tt("Unit Not Found")
- Return $posBackUp
- EndIf
- Else
- _tt("_findUnitPosition: Wrong Data Type")
- EndIf
- EndFunc ;==>_findUnitPosition
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _findPlayerColor
- ; Description ...: Find the color the player is currently playing
- ; Syntax ........: _findPlayerColor($arrColors)
- ; Parameters ....: $arrColors - Array with all possible player colors.
- ; Return values .: Color of Player Unit; 0 if not found
- ; ===============================================================================================================================
- Func _findPlayerColor($arrColors)
- ; Check if Player Color already determined
- If $iColorPlayer > 0 Then
- _tt("Player Color Already Determined")
- Return $iColorPlayer
- EndIf
- Local $iColorCurrent
- Local $posCurrentColor_Up, $posCurrentColor_Down
- Local $posTemp_Up, $posTemp_Down
- ;Rectangle Up
- Local $posX1_up = 0
- Local $posY1_up = 0
- Local $posX2_up = 0
- Local $posY2_up = 0
- ; Rectangle down
- Local $posX1_down = 0
- Local $posY1_down = 0
- Local $posX2_down = 0
- Local $posY2_down = 0
- ; Iterate Player Colors
- For $i = 0 To UBound($arrColors) - 1
- ; Grab Player Colors
- $iColorCurrent = $arrColors[$i]
- ; Get current color minimap position
- $posCurrentColor_Up = _findUnitPosition($arrMiniMap, $iColorCurrent)
- $posCurrentColor_Down = $posCurrentColor_Up
- ; If found, search in offset range for white circle around player
- If IsArray($posCurrentColor_Up) Then
- ; Generate Bottom Rectangle
- $posX1_up = $posCurrentColor_Up[0] - 5
- $posY1_up = $posCurrentColor_Up[1] - 5
- $posX2_up = $posCurrentColor_Up[0] + 5
- $posY2_up = $posCurrentColor_Up[1]
- ; Generate Bottom Rectangle
- $posX1_down = $posCurrentColor_Down[0] - 5
- $posY1_down = $posCurrentColor_Down[1]
- $posX2_down = $posCurrentColor_Down[0] + 5
- $posY2_down = $posCurrentColor_Down[1] + 5
- ; Search Upper Rectangle for white Pixel around current player color
- $posTemp_Up = PixelSearch($posX1_up, $posY1_up, $posX2_up, $posY2_up, $iColorPlayerCircle, 2)
- If IsArray($posTemp_Up) Then
- _tt("Player Color Determined UP " & $iColorCurrent)
- Return $iColorCurrent
- EndIf
- ; Search Lower Rectangle for white Pixel around current player color
- $posTemp_Down = PixelSearch($posX1_down, $posY1_down, $posX2_down, $posY2_down, $iColorPlayerCircle, 2)
- If IsArray($posTemp_Down) Then
- _tt("Player Color Determined DOWN " & $iColorCurrent)
- Return $iColorCurrent
- EndIf
- EndIf
- Next
- ; Exception
- If Not IsArray($posTemp_Down) And Not IsArray($posTemp_Up) Then
- _tt("Player Color Not Determined")
- Return 0
- EndIf
- EndFunc ;==>_findPlayerColor
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _MiniMapMarkerExist
- ; Description ...: Searches around a position for a given color in offset range
- ; Syntax ........: _MiniMapMarkerExist($iColor, $Pos, $iOffset)
- ; Parameters ....: $iColor - Color to search for.
- ; $Pos - Position to seach around.
- ; $iOffset - Position Offset to create Rectangles
- ; Return values .: True if Marker Exist Else False
- ; ===============================================================================================================================
- Func _MiniMapMarkerExist($iColor,$Pos,$iOffset)
- ; Exception
- If Not IsArray($Pos) Then
- _MsgBox("_MiniMapMarkerExist: $Pos non Array")
- Exit
- EndIf
- Local $posTemp
- ; Build Top Rectangle
- Local $posX1_up = $Pos[0] - $iOffset
- Local $posY1_up = $Pos[1] - $iOffset
- Local $posX2_up = $Pos[0] + $iOffset
- Local $posY2_up = $Pos[1]
- ; Build Bottom Rectangle
- Local $posX1_down = $Pos[0] - $iOffset
- Local $posY1_down = $Pos[1]
- Local $posX2_down = $Pos[0] + $iOffset
- Local $posY2_down = $Pos[1] + $iOffset
- ; Check Top Rectangle
- $posTemp = PixelSearch($posX1_up,$posY1_up,$posX2_up,$posY2_up,$iColor,1)
- If IsArray($posTemp) Then
- Return True
- EndIf
- ; Check Bottom Rectangle
- $posTemp = PixelSearch($posX1_down,$posY1_down,$posX2_down,$posY2_down,$iColor,1)
- If IsArray($posTemp) Then
- Return True
- EndIf
- Return False
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _checkLevelUp
- ; Syntax ........: _checkLevelUp()
- ; Return values .: True / False
- ; ===============================================================================================================================
- Func _checkLevelUp()
- Local $Pos = PixelSearch(843, 937, 1096, 942, $iColorLevelUp, 1)
- If IsArray($Pos) Then
- _tt("Level Up")
- Return True
- Else
- _tt("No Level Up")
- Return False
- EndIf
- EndFunc ;==>_checkLevelUp
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _checkPointProximity
- ; Description ...:
- ; Syntax ........: _checkPointProximity($posCurrent, $posTarget)
- ; Parameters ....: $posCurrent - A pointer value.
- ; $posTarget - A pointer value.
- ; Return values .: None
- ; Author ........: Your Name
- ; Modified ......:
- ; Remarks .......:
- ; Related .......:
- ; Link ..........:
- ; Example .......: No
- ; ===============================================================================================================================
- Func _checkPointProximity($posCurrent,$posTarget)
- If Not IsArray($posCurrent) or Not IsArray($posTarget) Then
- _MsgBox("_checkPointProximity: Called with Wrong Parameter")
- Return 0
- EndIf
- Local $iDistance = 9999
- $iDistance = _calculatePointDistance($posCurrent,$posTarget)
- If $iDistance <= 5 Then
- Return True
- ElseIf $iDistance > 6 Then
- Return False
- EndIf
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _checkDead
- ; Syntax ........: _checkDead()
- ; Return values .: True / False
- ; ===============================================================================================================================
- Func _checkDead()
- ; Check entire Health Bar for HealthColor
- Local $Pos = PixelSearch(781, 1017, 1095, 1043, $iColorHealth, 10)
- If IsArray($Pos) Then
- _tt("Not Dead")
- Return False
- Else
- _tt("Dead")
- Return True
- EndIf
- EndFunc ;==>_checkDead
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _AttackAndMovement
- ; Description ...:
- ; Syntax ........: _AttackAndMovement($bAttack, $Pos)
- ; Parameters ....: $bAttack - 0 = Move; 1 = Attack
- ; $Pos - Position
- ; ===============================================================================================================================
- Func _AttackAndMovement($bAttack,$Pos)
- ; Expcetion
- If Not IsArray($pos) Then
- _MsgBox("_AttackAndMovement: $pos is no Array")
- Exit
- EndIf
- ; Attack Move
- If $bAttack = 1 Then
- MouseMove($pos[0],$pos[1])
- Send("a")
- ; Needed to avoid Attack Canceling and complete movement
- Sleep(500)
- ; Movement Command
- ElseIf $bAttack = 0 Then
- MouseMove($pos[0],$pos[1])
- Send("m")
- ; Needed to complete movement (To fast update = no movement = might stuck)
- Sleep(500)
- Else
- _MsgBox("_AttackAndMovement: Wrong Attack Parameter")
- Exit
- EndIf
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _buildPoint
- ; Description ...:
- ; Syntax ........: _buildPoint($iX, $iY)
- ; Parameters ....: $iX - An integer value.
- ; $iY - An integer value.
- ; Return values .: Array with X Y
- ; ===============================================================================================================================
- Func _buildPoint($iX, $iY)
- Local $posPoint[2]
- $posPoint[0] = $iX
- $posPoint[1] = $iY
- Return $posPoint
- EndFunc ;==>_buildPoint
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _buildPointArray
- ; Description ...:
- ; Syntax ........: _buildPointArray($arrX, $arrY)
- ; Parameters ....: $arrX - X Coordinates
- ; $arrY - Y Coordinates
- ; Return values .: Returns an array with Points
- ; ===============================================================================================================================
- Func _buildPointArray($arrX,$arrY)
- ; Exception
- If Not UBound($arrX) = UBound($arrY) Then
- _MsgBox("_buildPointArray: Wrong Array Constraints")
- Exit
- EndIf
- Local $arrPositions[UBound($arrX)]
- For $i = 0 To UBound($arrX) - 1
- $arrPositions[$i] = _buildPoint($arrX[$i],$arrY[$i])
- Next
- Return $arrPositions
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _calculatePointDistance
- ; Syntax ........: _calculatePointDistance($pos_1, $pos_2)
- ; Parameters ....: $pos_1
- ; $pos_2
- ; Return values .: Distance between points (Pixel)
- ; ===============================================================================================================================
- Func _calculatePointDistance($pos_1, $pos_2)
- ; Exception Handling
- If IsArray($pos_1) And IsArray($pos_2) Then
- ; Point 1
- Local $pos_x1 = $pos_1[0]
- Local $pos_y1 = $pos_1[1]
- ; Point 2
- Local $pos_x2 = $pos_2[0]
- Local $pos_y2 = $pos_2[1]
- ; Calculate Distance and make it Integer
- Local $iDistance = Sqrt((($pos_x2 - $pos_x1) * ($pos_x2 - $pos_x1)) + (($pos_y2 - $pos_y1) * ($pos_y2 - $pos_y1)))
- $iDistance = Int($iDistance)
- Return $iDistance
- Else
- _MsgBox("_calculatePointDistance: Non Array Parameters")
- Return 0
- EndIf
- EndFunc ;==>_calculatePointDistance
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _MsgBox
- ; Description ...: Debug Function
- ; Syntax ........: _MsgBox($sMsgbox)
- ; Parameters ....: $sMsgbox - A string value.
- ; Return values .: None
- ; ===============================================================================================================================
- Func _MsgBox($sMsgbox)
- MsgBox(0, "Debug", $sMsgbox)
- EndFunc ;==>_MsgBox
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _convertTimer
- ; Description ...: Calculate Time in seconds
- ; Syntax ........: _convertTimer($timer)
- ; Parameters ....: $timer - A dll struct value.
- ; Return values .: Timer in Seconds
- ; ===============================================================================================================================
- Func _convertTimer($timer)
- Local $iConvertedTimer = Int(TimerDiff($timer) / 1000)
- Return $iConvertedTimer
- EndFunc ;==>_convertTimer
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _MouseMove
- ; Description ...: Easy Mouse Move
- ; Syntax ........: _MouseMove($Pos)
- ; Parameters ....: $Pos - Postion to Move Mouse To
- ; ===============================================================================================================================
- Func _MouseMove($Pos)
- If IsArray($Pos) and UBound($Pos) = 2 Then
- MouseMove($pos[0],$pos[1])
- Else
- _MsgBox("_MouseMove: Wrong Array Constraints")
- EndIf
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name ..........: _exit
- ; Syntax ........: _exit()
- ; Return values .: None
- ; ===============================================================================================================================
- Func _exit()
- Exit
- EndFunc ;==>_exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement