Micro Focus QTP (UFT) Forums
"How to Count Desktop Icons" - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: "How to Count Desktop Icons" (/Thread-How-to-Count-Desktop-Icons)



"How to Count Desktop Icons" - suresz449 - 11-21-2011

Hi Folks,

I have lot of Icons my Desktop, I need total count of icons and verify that particular file/folder/etc are present on my desktop or not?


RE: "How to Count Desktop Icons" - Ankesh - 11-21-2011

Hi Suresh,

'get the desktop item count
Code:
intCount=Window("title:=Program Manager").WinListView("object class:=SysListView32").GetItemsCount
msgbox intCount

I am still trying to get the items for validation/verification. I will keep you posted.

Regards,
Ankesh


RE: "How to Count Desktop Icons" - suresz449 - 11-22-2011

Hi Ankesh,

First of all thanks for your reply, I tried your code but I got the error like type mismath.
Hi Ankesh,

Sorry for the previous post it's working fine.Now I need to print the name of each icon present on desktop can you please send the code to me.


RE: "How to Count Desktop Icons" - Ankesh - 11-22-2011

Hi Suresh,

Usually the below code works fine to get the items

Code:
strItems=Window("title:=Program Manager").WinListView("object class:=SysListView32").GetROProperty("all items")

but for me "all items" property is blank. Can you plz post the snapshot of object spy by spying any of the icon on the desktop?

Regards,
Ankesh


RE: "How to Count Desktop Icons" - vIns - 11-23-2011

I am not sure of your requirement. You can use VBScript to get this done.
Code:
Set fso = createobject("Scripting.FileSystemObject")
DesktopPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")

'Files count
msgbox fso.GetFolder(DesktopPath).Files.Count

'Folders count
msgbox fso.GetFolder(DesktopPath).SubFolders.Count

'Check if specified file is present
msgbox fso.FileExists(DesktopPath & "\" & "qtp.txt")

'Check if specified folder is present
msgbox fso.FolderExists(DesktopPath & "\" & "DSC_019612")



RE: "How to Count Desktop Icons" - suresz449 - 11-23-2011

Hi vIns,

I am getting the count of Desktop Icons but I need the names of Ecah icon present on Desktop.If you know please share code with me and along with Ankesh.