au3控制桌面图标实例

Windows的桌面实际上是一个标题为“Program Manager”的窗口,桌面上的图标是一个标准的SysListView32控件,用ControlListView函数就可以对桌面图标进行基本的操作。因此,我们可以这样使用au3操作桌面图标:

$handle = WinGetHandle(“Program Manager”) ;窗口句柄
$tubiao = ControlGetHandle(“Program Manager”,””,”SysListView321″) ;控件句柄

ControlListView($handle,””,$tubiao,”SelectAll”) ;选中桌面全部图标
ControlListView($handle,””,$tubiao,”SelectClear”) ;取消选择

ControlListView($handle,””,$tubiao,”Select”,2,5) ;选中第3到6个图标

MsgBox(0,”第一个图标名称”,ControlListView($handle,””,$tubiao,”GetText”,0,0))

MsgBox(0,”图标总数”,ControlListView($handle,””,$tubiao,”GetItemCount”))

MsgBox(0,”选中图标数”,ControlListView($handle,””,$tubiao,”GetSelectedCount”))

ControlDisable ($handle,””,$tubiao) ;无法点击桌面图标
ControlEnable ($handle,””,$tubiao) ;恢复

ControlHide ($handle,””,$tubiao) ;隐藏桌面图标
ControlShow ($handle,””,$tubiao) ;恢复

;下面是列出全部选中的图标
$num = ControlListView($handle,””,$tubiao,”GetSelected”,1)
$array= StringSplit($num,”|”)
For $i = 1 To $array[0]
MsgBox(0,”选中的第”&$i&”个图标”,ControlListView($handle,””,$tubiao,”GetText”,$array[$i],0))
Next

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注