This is how I see your code,
def Test2():
button = Aliases.I_Software.HwndSource_HomeScreenWindow.HomeScreenWindow_.RemoveImagesButton
if aqObject.CheckProperty(button.Image, "Enabled", cmpEqual, True):
imageSelector = Aliases.I_Software.HwndSource_ImageSelector.ImageSelector
button.ClickButton()
imageSelector.SelectAllButton.ClickButton()
imageSelector.OKButton.ClickButton()
Aliases.I_Software.HwndSource_HomeScreenWindow.HomeScreenWindow_.ImportImageButton.ClickButton()
Aliases.I_Software.dlgImportImage.OpenFile("C:\\Users\\Test Complete\\Desktop\\Samples\\Samples\\Indian.jpg")
Aliases.I_Software.HwndSource_MessageBox.MessageBox.OKYesButton.ClickButton()
listView = Aliases.I_Software.HwndSource_HomeScreenWindow.HomeScreenWindow_.GalleryList
listView.HScroll.Pos = 0
listView.DblClickItem(0)
If TestComplete is not able to find the object on screen, then it means your actions are not correctly defined or your name mappings may have changed. Debug and step through the code, at the point of failure, check the name mapping and ensure TestComplete is able to identify the correct object.
Also, you might need to have a wait statement, for dlgImportImage to appear.