Sign in to follow this  
Followers 0
Chimaera

2D array problem

9 posts in this topic

Hi ive been trying to get a array working in 2D but it doesnt seem to work

I normally create an array like this

$sProgramString = ""    
$sProgramString = "|C:\Program Files\CCleaner\uninst.exe|C:\Program Files\Next item\uninst.exe"
$sProgramString &= "|C:\Program Files\Defraggler\uninst.exe|C:\Program Files\Next item\uninst.exe"

The thing is i want to use a switch to accompany the uninstall location Ccleaner for eg is "/S"

They wont all have switches so they have to be kept in line so they work with the right uninstaller. there could be possibly 50 of them?

I was looking at this but it gives syntax errors

Local $sProgramString = ""
$sProgramString[2][2] = [["C:\Program Files\CCleaner\uninst.exe|C:\Program Files\Defraggler\uninst.exe"],["/S|/S"]]

Am i better to create 2 individual arrays and try and blend them together?

Any suggestions would be helpfull

Share this post


Link to post
Share on other sites



This is how you declare an array.

Local $aProgramString[2][2] = [["C:\Program Files\CCleaner\uninst.exe|C:\Program Files\Defraggler\uninst.exe"],["/S|/S"]]
_ArrayDisplay($aProgramString)

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

The expected result is not very clear, what should the final array look like ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It should be

C:Program FilesCCleaneruninst.exe /S

C:Program FilesDefraggleruninst.exe /S

This will hopefully be the final form although i have no idea how to get there at the minute

ShellExecuteWait( $aProgramList ??, $aProgramList ??) equats to

ShellExecuteWait( C:Program FilesCCleaneruninst.exe, /S)

So i can run them through a loop one after another

Edited by Chimaera

Share this post


Link to post
Share on other sites

#include <Array.au3>
Local $aProgramString[2][2] = [["C:\Program Files\CCleaner\uninst.exe","/S"],["C:\Program Files\Defraggler\uninst.exe","/S"]]
For $i = 0 To UBound($aProgramString) -1
    ConsoleWrite($aProgramString[$i][0] & " " & $aProgramString[$i][1] & @CRLF)
Next
_ArrayDisplay($aProgramString)


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Local $aProgramString[2][2] = [["C:\Program Files\CCleaner\uninst.exe", "/S"], ["C:\Program Files\Defraggler\uninst.exe", "/S"]]
_ArrayDisplay($aProgramString)
For $i = 0 To UBound($aProgramString) - 1
    ShellExecuteWait($aProgramString[$i][0], $aProgramString[$i][1])
Next


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

I would recommend reading the wiki about arrays. This also isn't some new AutoIt thing, as arrays are the fundamental data structures in any language I know.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

Yep i am aware its not new and its always been my grey area, havent done anything for a long time now .

Ive actually thought this through badly as i realzed that on some of them they require extra code for pressing buttons etc

Local $sProgramString = ""
    $sProgramString = "|C:\Program Files\CCleaner\uninst.exe"
    $sProgramString &= "|C:\Program Files\Defraggler\uninst.exe|C:\Program Files (x86)\HD Tune\unins000.exe"
    Local $aProgramArray = StringSplit($sProgramString, "|")
    _ArrayDisplay($aProgramArray)

For $i = 0 To UBound($aProgramArray) - 1
    If FileExists($aProgramArray[$i]) Then
        Local $UninCheck = $aProgramArray[$i]
        Select
            Case $UninCheck = "C:\Program Files\CCleaner\uninst.exe"
                ShellExecuteWait($aProgramArray[$i], "/S")
                Sleep(1000)
            Case $UninCheck = "C:\Program Files\Defraggler\uninst.exe"
                ShellExecuteWait($aProgramArray[$i], "/S")
                Sleep(1000)
            Case $UninCheck = "C:\Program Files (x86)\HD Tune\unins000.exe"
;~              $iPID = ShellExecuteWait($aProgramArray[$i], "")
                $iPID = Run ( "C:\Program Files (x86)\HD Tune\unins000.exe", '', @SW_SHOW ) ; run program to create PID
                    Local $a = "" ; initalize array as empty
                    Local $iTimer = TimerInit() ; start timer
                    While Not IsArray($a) And TimerDiff($iTimer)<5000 ; If no array exists and timer is less than 5 secs
                        $a = _WinAPI_EnumProcessWindows ($iPID,True) ; remake array with current windows
                    WEnd

                    If IsArray($a) Then ; array data exists
                        Local $h = $a[1][0] ;  <.this is grabbing the window's handle from the array, just because $h is shorter than $a[1][0]
                        WinActivate($h) ; activate the window
                        ControlFocus($h, "", 6) ; set focus to Yes button
                        ControlClick($h, "", 6) ; click the button
                        WinWaitClose($h)
                    Else
                        MsgBox(1,1,"Coundn't Find Window")
                    EndIf
                Sleep(1000)
            Case Else
                ShellExecuteWait($aProgramArray[$i], "")
                Sleep(1000)
        EndSelect
    Else
        ContinueLoop
    EndIf
Next

Its not a fully working piece but you will get the idea of what im trying to do, the ones that have switches will be added with them the ones that need intervention will have extra code and the rest will use the case else

On this piece i was using some code from an earlier example with IE, but is there an easier way to find the window?

$iPID = Run ( "C:\Program Files (x86)\HD Tune\unins000.exe", '', @SW_SHOW ) ; run program to create PID
    Local $a = "" ; initalize array as empty
    Local $iTimer = TimerInit() ; start timer
    While Not IsArray($a) And TimerDiff($iTimer)<5000 ; If no array exists and timer is less than 5 secs
    $a = _WinAPI_EnumProcessWindows ($iPID,True) ; remake array with current windows
    WEnd
    If IsArray($a) Then ; array data exists
    Local $h = $a[1][0] ;  <.this is grabbing the window's handle from the array, just because $h is shorter than $a[1][0]
        WinActivate($h) ; activate the window
        ControlFocus($h, "", 6) ; set focus to Yes button
        ControlClick($h, "", 6) ; click the button
        WinWaitClose($h)

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  
Followers 0