Jump to content
Sign in to follow this  
gil900

Help with a filter from Array

Recommended Posts

gil900

I wrote this code:

#include <ScreenCapture.au3>
#include <Array.au3>

Global $v = 0, $n = 1,$XYPoints[1],$FXYPoints[1],$Emtey[1]
;=====================Settings========================
$XpChack = 12
$YpChack = 10
$TSleep = 500
;====================End Settings=====================

$size = WinGetPos("Program Manager")
$handle = WinGetHandle("Program Manager", "")
$XLength = $size[2]
$YLength = $size[3]
$TXYChack = $XpChack*$YpChack


$XPointSpace = StringSplit($XLength/$XpChack,".")
$XPointSpace = $XPointSpace[1]
$YPointSpace = StringSplit($YLength/$YpChack,".")
$YPointSpace = $YPointSpace[1]

While 1
;--------------------------------------------------------------------------------
For $y = 0 To $YLength
;Sleep(1000)    
    $y = $y+$YPointSpace
        For $x = 0 To $XLength
            ;Sleep(1000)    
            $x = $x+$XPointSpace
            $var = PixelGetColor($x,$y)
            _ArrayAdd($XYPoints,$x & "," & $y & "," & $var )
            ToolTip($var,$x,$y)
            $v = $v+$var
        Next
    Next
_ArrayDisplay($XYPoints, "test")
$XYPoints = $Emtey
WEnd

Posted Image

I need to extract the Arrays which have numbers (xxx,xxx,xxxxxxx) that appear only once.

I do not know how to do it ..

Help me.

Edited by gil900

Share this post


Link to post
Share on other sites
bogQ

probably StringRegExp can do it in one line

Dim $final[1]
For $x = 1 to UBound($XYPoints)-1
    $tmp = StringSplit($XYPoints[$x],',')
    $XYPoints[$x] = $tmp[3]
Next
_ArraySort($XYPoints,Default,1)
_ArrayAdd($XYPoints,'' )
For $x = 1 to UBound($XYPoints)-1
    If $XYPoints[$x] <> $XYPoints[$x+1] And $XYPoints[$x] <> $XYPoints[$x-1] Then _ArrayAdd($final,$XYPoints[$x])
    If $XYPoints[$x+1] = '' Then ExitLoop
Next
_ArrayDisplay($final, "test")

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
gil900

probably StringRegExp can do it in one line

Dim $final[1]
For $x = 1 to UBound($XYPoints)-1
$tmp = StringSplit($XYPoints[$x],',')
$XYPoints[$x] = $tmp[3]
Next
_ArraySort($XYPoints,Default,1)
_ArrayAdd($XYPoints,'' )
For $x = 1 to UBound($XYPoints)-1
If $XYPoints[$x] <> $XYPoints[$x+1] And $XYPoints[$x] <> $XYPoints[$x-1] Then _ArrayAdd($final,$XYPoints[$x])
If $XYPoints[$x+1] = '' Then ExitLoop
Next
_ArrayDisplay($final, "test")

Thank you ..

But I need it to return the numbers without missing this information - xxx,yyy,nnnnnn

This algorithm that I am building (and you are very help building part of it) can recognize where there is a picture on the screen.

And in order that the process will continue, this information must remain.

Edited by gil900

Share this post


Link to post
Share on other sites
bogQ

you can use Assign($tmp[3],$tmp[1]&','&$tmp[2]) to store position data and after that you can call that datga with MsgBox(0,'Pixel: '&$final[$x],Eval($final[$x]))


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
UEZ

What about this here?

#include <Array.au3>

Global $aTest[6] = [        "123,456,15264747", _
                                                "560,123,16777215", _
                                                "1120,222,5197209", _
                                                "1367,76,16777215", _
                                                "333,445,00000000", _
                                                "774,634,16769739"]

Global $sTest = _ArrayToString($aTest)
Global $sSearch = "15264747,2641305,12582912,16777215"
Global $aSearch = StringSplit($sSearch, ",", 2), $sResult, $a

For $i = 0 To UBound($aSearch) - 1
    $a = StringRegExp($sTest, "(d+,d+," & $aSearch[$i] & ")", 3)
    If Not @error Then
        $sResult &= _ArrayToString($a) & "|"
    EndIf
Next
$aResult = StringSplit(StringTrimRight($sResult, 1), "|", 2)
_ArrayDisplay($aResult)

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
gil900

you can use Assign($tmp[3],$tmp[1]&','&$tmp[2]) to store position data and after that you can call that datga with MsgBox(0,'Pixel: '&$final[$x],Eval($final[$x]))

I could not understand ..

Can you give me an example?

Share this post


Link to post
Share on other sites
guinness

Example of Assign from the latest beta:

; Assign the variable string sString with data.
Assign("sString", "This is a string which is declared using the function Assign")

; Find the value of the variable string sString and assign to the variable $sEvalString.
Local $sEvalString = Eval("sString")

; Display the value of $sEvalString. This should be the same value as $sString.
MsgBox(4096, "", $sEvalString)

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
bogQ

#include <ScreenCapture.au3>
#include <Array.au3>
 
Global $v = 0, $n = 1, $XYPoints[1], $FXYPoints[1], $Emtey[1]
;=====================Settings========================
$XpChack = 12
$YpChack = 10
$TSleep = 500
;====================End Settings=====================
 
$size = WinGetPos("Windows Task Manager")
$handle = WinGetHandle("Program Manager", "")
$XLength = $size[2]
$YLength = $size[3]
$TXYChack = $XpChack * $YpChack
 
$XPointSpace = StringSplit($XLength / $XpChack, ".")
$XPointSpace = $XPointSpace[1]
$YPointSpace = StringSplit($YLength / $YpChack, ".")
$YPointSpace = $YPointSpace[1]
For $y = 0 To $YLength
    $y = $y + $YPointSpace
    For $x = 0 To $XLength
        $x = $x + $XPointSpace
        $var = PixelGetColor($x, $y)
        _ArrayAdd($XYPoints, $x & "," & $y & "," & $var)
        $v = $v + $var
    Next
Next
_ArrayDisplay($XYPoints, "test")
 
;upper example
Dim $final[1]
For $x = 1 To UBound($XYPoints) - 1
    $tmp = StringSplit($XYPoints[$x], ',')
    $XYPoints[$x] = $tmp[3]
    Assign($tmp[3], $tmp[1] & ',' & $tmp[2]);added Assign line
Next
_ArraySort($XYPoints, Default, 1)
_ArrayAdd($XYPoints, '')
For $x = 1 To UBound($XYPoints) - 1
    If $XYPoints[$x] <> $XYPoints[$x + 1] And $XYPoints[$x] <> $XYPoints[$x - 1] Then _ArrayAdd($final, $XYPoints[$x])
    If $XYPoints[$x + 1] = '' Then ExitLoop
Next
_ArrayDisplay($final, "test")
 
;test return data, get pos from Eval($final[$x]), get pixel from $final[$x]
For $x = 1 To UBound($final) - 1
    MsgBox(0, 'Pixel: ' & $final[$x], Eval($final[$x]))
Next

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
gil900

#include <ScreenCapture.au3>
#include <Array.au3>

Global $v = 0, $n = 1, $XYPoints[1], $FXYPoints[1], $Emtey[1]
;=====================Settings========================
$XpChack = 12
$YpChack = 10
$TSleep = 500
;====================End Settings=====================

$size = WinGetPos("Windows Task Manager")
$handle = WinGetHandle("Program Manager", "")
$XLength = $size[2]
$YLength = $size[3]
$TXYChack = $XpChack * $YpChack

$XPointSpace = StringSplit($XLength / $XpChack, ".")
$XPointSpace = $XPointSpace[1]
$YPointSpace = StringSplit($YLength / $YpChack, ".")
$YPointSpace = $YPointSpace[1]
For $y = 0 To $YLength
$y = $y + $YPointSpace
For $x = 0 To $XLength
     $x = $x + $XPointSpace
     $var = PixelGetColor($x, $y)
     _ArrayAdd($XYPoints, $x & "," & $y & "," & $var)
     $v = $v + $var
Next
Next
_ArrayDisplay($XYPoints, "test")

;upper example
Dim $final[1]
For $x = 1 To UBound($XYPoints) - 1
$tmp = StringSplit($XYPoints[$x], ',')
$XYPoints[$x] = $tmp[3]
Assign($tmp[3], $tmp[1] & ',' & $tmp[2]);added Assign line
Next
_ArraySort($XYPoints, Default, 1)
_ArrayAdd($XYPoints, '')
For $x = 1 To UBound($XYPoints) - 1
If $XYPoints[$x] <> $XYPoints[$x + 1] And $XYPoints[$x] <> $XYPoints[$x - 1] Then _ArrayAdd($final, $XYPoints[$x])
If $XYPoints[$x + 1] = '' Then ExitLoop
Next
_ArrayDisplay($final, "test")

;test return data, get pos from Eval($final[$x]), get pixel from $final[$x]
For $x = 1 To UBound($final) - 1
MsgBox(0, 'Pixel: ' & $final[$x], Eval($final[$x]))
Next

Thank you.

I you brought a broken code ..

But I fix it ..

I will continue from this point ..

For those who want to continue from this point also, is the code:

#include <ScreenCapture.au3>
#include <Array.au3>

Global $v = 0, $n = 1,$XYPoints[1],$FXYPoints[1],$Emtey[1]
;=====================Settings========================
$XpChack = 12
$YpChack = 10
$TSleep = 500
;====================End Settings=====================

$size = WinGetPos("Program Manager")
$handle = WinGetHandle("Program Manager", "")
$XLength = $size[2]
$YLength = $size[3]
$TXYChack = $XpChack*$YpChack


$XPointSpace = StringSplit($XLength/$XpChack,".")
$XPointSpace = $XPointSpace[1]
$YPointSpace = StringSplit($YLength/$YpChack,".")
$YPointSpace = $YPointSpace[1]

While 1
;--------------------------------------------------------------------------------
For $y = 0 To $YLength
;Sleep(1000)    
    $y = $y+$YPointSpace
        For $x = 0 To $XLength
            ;Sleep(1000)    
            $x = $x+$XPointSpace
            $var = PixelGetColor($x,$y)
            _ArrayAdd($XYPoints,$x & "," & $y & "," & $var )
            ToolTip($var,$x,$y)
            $v = $v+$var
        Next
    Next
_ArrayDisplay($XYPoints, "test")

;upper example
Dim $final[1]
For $x = 1 To UBound($XYPoints) - 1
    $tmp = StringSplit($XYPoints[$x], ',')
    $XYPoints[$x] = $tmp[3]
    Assign($tmp[3], $tmp[1] & ',' & $tmp[2]);added Assign line
Next
_ArraySort($XYPoints, Default, 1)
_ArrayAdd($XYPoints, '')
For $x = 1 To UBound($XYPoints) - 1
    If $XYPoints[$x] <> $XYPoints[$x + 1] And $XYPoints[$x] <> $XYPoints[$x - 1] Then _ArrayAdd($final, $XYPoints[$x])
    If $XYPoints[$x + 1] = '' Then ExitLoop
Next
_ArrayDisplay($final, "test")
 
;test return data, get pos from Eval($final[$x]), get pixel from $final[$x]
For $x = 1 To UBound($final) - 1
    MsgBox(0, 'color: ' & $final[$x], Eval($final[$x]))
Next

$XYPoints = $Emtey
WEnd

I'll be happy if someone will continue this for me ..

Share this post


Link to post
Share on other sites
bogQ

continue with what? isnt this solved?

and it's not broken code, its code that works on my computer cuz i dont have win named Program Manager.


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  

×