找回密码
 加入
搜索
查看: 8140|回复: 13

[GUI管理] 运行后为什么不能同时选择多个checkbox去卸载?

 火.. [复制链接]
发表于 2011-3-28 18:27:41 | 显示全部楼层 |阅读模式
#NoTrayIcon
#include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
DIM $_REG,$_REG_DP="DisplayName",$_REG_DI="DisplayIcon",$_REG_US="UninstallString",$X=0
DIM $_REG_String="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

$GUI=GUICreate("添加删除程序",820,400,-1,-1)
$Label_01=GUICtrlCreateLabel("添加删除程序",10,20,800,40,0x01)
$Button_01=GUICtrlCreateButton("卸载",10,370,150,20)
$Button_02=GUICtrlCreateButton("退出",660,370,150,20)
$Lv=GUICtrlGetHandle(GUICtrlCreateListView("",10,50,800,315, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE))
_GUICtrlListView_SetExtendedListViewStyle($Lv,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_SUBITEMIMAGES,$LVS_EX_CHECKBOXES))
_GUICtrlListView_AddColumn($Lv, "", 40)
_GUICtrlListView_AddColumn($Lv, "列表",400)
_GUICtrlListView_AddColumn($Lv, "路径",355)


GUICtrlSetBkColor($Label_01, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($Button_01,"_Uninstall")
GUICtrlSetOnEvent($Button_02,"_EXIT")
GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT")
GUISetOnEvent($GUI_EVENT_MINIMIZE,"_MINIMIZE")
GUISetOnEvent($GUI_EVENT_RESTORE,"_RESTORE")
GUISetState()


for $i=1 to 1000
$_REG=RegEnumKey($_REG_String,$i)
If @error <> 0 then ExitLoop
if RegRead($_REG_String&$_REG,$_REG_DP)="" OR StringLeft($_REG,1)="{" Then
Else
_GUICtrlListView_AddItem($Lv,$x+1,$x)
_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_DP),1)
_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_US),2)
$x=$x+1
EndIf
Next

While 1
sleep(10)
WEnd

func _EXIT()
Exit
EndFunc

func _MINIMIZE()
GUISetState(@SW_MINIMIZE)
EndFunc

func _RESTORE()
GUISetState(@SW_RESTORE)
EndFunc

func _Uninstall()
               $log = _GUICtrlListView_GetItemCount($Lv)
                For $i = 0 To $log
                If _GUICtrlListView_GetItemChecked($Lv, $i) = True Then
                 _GuiCtrlListView_SetItemselected($Lv, $i,True,True)
                 Run (_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_US),2)) 
              Else
                    _GuiCtrlListView_SetItemselected($Lv, $i,False,,False)
              EndIf
        Next
 EndFunc
运行后为什么不能同时选择多个checkbox去卸载?

纠结了好久都不知道问题出在哪,大侠们、版主们救命啊~~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-3-28 19:08:08 | 显示全部楼层
回复 1# pdp320921

Run不行就用RunWait试试.
 楼主| 发表于 2011-3-28 19:11:22 | 显示全部楼层
回复 2# lixiaolong

都有试过都不行~
发表于 2011-3-28 20:16:26 | 显示全部楼层
这个要加个判断才行啊
发表于 2011-3-28 20:30:23 | 显示全部楼层
本帖最后由 xxoojoeooxx 于 2011-3-28 20:32 编辑

Run (_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_US),2)) 

改成
Local  $Path=_GUICtrlListView_GetItemTextArray($Lv,$i)
Run($Path[3])



Run(_GUICtrlListView_GetItemText($Lv, $i, 2))
 楼主| 发表于 2011-3-28 20:40:28 | 显示全部楼层
本帖最后由 pdp320921 于 2011-3-28 20:51 编辑

回复 4# xz00311

回去再试试~~
谢谢楼上各位的关注!
谢谢!
 楼主| 发表于 2011-3-29 11:55:28 | 显示全部楼层
本帖最后由 pdp320921 于 2011-3-29 14:54 编辑

我想在Run(_GUICtrlListView_GetItemText($Lv,$i,2))后根据弹出的窗口来判断去自动完成卸载~
我有监视几个程序的卸载,如何添加到Run(_GUICtrlListView_GetItemText($Lv,$i,2))后才能正常执行???
大虾们帮下忙啊~~
;DisplayName Skype Toolbars
;DisplayVersion 1.0.4051
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{981029E0-7FC9-4CF3-AB39-6F133621921A}
;UninstallString REG_SZ MsiExec.exe /I{981029E0-7FC9-4CF3-AB39-6F133621921A}
If WinWaitActive("Skype Toolbars Setup","") Then
Send("!n")
WinWaitActive("Skype Toolbars Setup","Removes Skype Toolbars")
Send("!r")
WinWaitActive("Skype Toolbars Setup","Ready to remove Skype Toolbar")
Send("!r")
WinWaitActive("Skype Toolbars Setup","Completed the Skype Toolbars Setup Wizard")
Send("{ENTER}")
EndIf        
                                                
If  WinWaitActive("Norton Internet Security 2011","") Then
Opt("MouseCoordMode", 0)  
;Run("C:\Program Files\NortonInstaller\{0C55C096-0F1D-4F28-AAA2-85EF591126E7}\NIS\A5E82D02\18.5.0.125\InstStub.exe /X /ARP")
;WinWaitActive("Norton Internet Security 2011","")
MouseClick("",381,328)
WinWaitActive("Norton Internet Security 2011","")
MouseClick("",397,363)
WinWaitActive("Norton Internet Security 2011","")
MouseClick("",82,416)
EndIf        
                                                   
;DisplayName Microsoft SQL Server 2005 Compact Edition [ENU]
;DisplayVersion 3.1.0000
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F0B430D1-B6AA-473D-9B06-AA3DD01FD0B8}
;UninstallString REG_SZ MsiExec.exe /I{F0B430D1-B6AA-473D-9B06-AA3DD01FD0B8}
;Run("MsiExec.exe /I{F0B430D1-B6AA-473D-9B06-AA3DD01FD0B8}")
If  WinWaitActive("Microsoft SQL Server 2005 Compact Edition [ENU]","remove Microsoft SQL Server") Then                        
Send("!n")
WinWaitActive("Microsoft SQL Server 2005 Compact Edition [ENU]","Remove Microsoft SQL Server Compact Edition from your computer")
Send("!r")
Send("!n")
WinWaitActive("Microsoft SQL Server 2005 Compact Edition [ENU]","If you want to review")
Send("!r")
Send("!f")
EndIf        
                                                        
;DisplayName Adobe Flash Player 10 ActiveX
;DisplayVersion 10.1.85.3
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX
;UninstallString REG_SZ C:\windows\system32\Macromed\Flash\FlashUtil10k_ActiveX.exe -maintain activex
;Run("C:\windows\system32\Macromed\Flash\FlashUtil10k_ActiveX.exe -maintain activex")
  If  WinWaitActive("Uninstall Adobe Flash Player","This program will remove") Then
  ControlClick("Uninstall Adobe Flash Player","",102)
        Sleep(2000)
WinWaitActive("Uninstall Adobe Flash Player","")
ControlClick("Uninstall Adobe Flash Player","",102)
EndIf        
                
;DisplayName WildTangent Games
  ;DisplayVersion 1.0.1.3
   ;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WildTangent toshiba Master Uninstall
    ;UninstallString REG_SZ "C:\Program Files\TOSHIBA Games\Uninstall.exe"
   ;Run("C:\Program Files\TOSHIBA Games\Uninstall.exe")
If WinWaitActive("Remove WildTangent Games","") Then
;Sleep(300)
Opt("MouseCoordMode", 2)
MouseClick("",106,216)
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
Send("{TAB}{SPACE}")
MouseClick("",490,426)
WinWaitActive("WildTangent Games Uninstall","Are you sure you want to remove")
Send("{ENTER}")
;WinWaitActive("Remove WildTangent Games","Click")
  Sleep(60000)
MouseClick("",493,429)
EndIf        
;DisplayName Amazon Kindle For PC v1.1
;DisplayVersion 15.4.3502.0922
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Amazon Kindle For PC
;UninstallString REG_SZ C:\Program Files\Amazon\Kindle For PC\uninstall.exe
;Run("C:\Program Files\Amazon\Kindle For PC\uninstall.exe")
   If  WinWaitActive("Uninstall Amazon Kindle For PC ","Uninstalling from") Then
Send("!u")
WinWaitActive("Uninstall Amazon Kindle For PC ","All software components have been removed")
ControlClick("Uninstall Amazon Kindle For PC ","Take me to Manage",1203)
Send("!f")
EndIf        
;DisplayName Windows Live Essentials
;DisplayVersion 15.4.3502.0922
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinLiveSuite
;UninstallString REG_SZ C:\Program Files\Windows Live\Installer\wlarp.exe
  ;Run("C:\Program Files\Windows Live\Installer\wlarp.exe")
If WinWaitActive("Windows Live Essentials 2011","Uninstall or repair Windows Live programs") Then
Send("{SPACE}")
WinWaitActive("Windows Live Essentials 2011","What do you want to uninstall")
Send("{SPACE}")
Send("{RIGHT}")
Send("{SPACE}")
Send("{DOWN}")
Send("{SPACE}")
Send("{LEFT}" )
Send("{SPACE}")
Send("{DOWN}" )
Send("{SPACE}")
Send("!u")
WinWaitActive("Windows Live Essentials 2011","Done")
Send("!c")
EndIf
发表于 2011-3-29 19:00:52 | 显示全部楼层
这是论坛里面一位大哥的代码你可以看一下
#include <GUIListView.au3>
#include <WindowsConstants.au3>

Global $ListView1, $Texts
GUICreate("ListView", 280, 300)
$ListView1 = GUICtrlCreateListView("编号|姓名|ID", 1, 1, 278, 230, -1, _
                BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_REPORT))
;GUICtrlSetImage(-1, @ScriptDir & '\星星图标.ico')
$anniu1 = GUICtrlCreateButton("读取选中项", 20, 250, 100, 30)
$anniu2 = GUICtrlCreateButton("删除选中项", 150, 250, 100, 30)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 100)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 100)
GUISetState(@SW_SHOW)

GUICtrlCreateListViewItem('1|张三|65786315', $ListView1)
GUICtrlCreateListViewItem('2|李四|56454688', $ListView1)
GUICtrlCreateListViewItem('3|王五|86575765', $ListView1)
GUICtrlCreateListViewItem('4|孙六|87654832', $ListView1)
GUICtrlCreateListViewItem('5|赵七|96325478', $ListView1)
GUICtrlCreateListViewItem('6|成八|64651873', $ListView1)
GUICtrlCreateListViewItem('7|冯九|96437251', $ListView1)
GUICtrlCreateListViewItem('8|钱十|64976835', $ListView1)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case - 3
                        Exit
                Case $anniu1
                        read()
                Case $anniu2
                        Del()
        EndSwitch
WEnd

Func read()
        $a = _GUICtrlListView_GetItemCount($ListView1)
        For $i = 0 To $a
                $Text = _GUICtrlListView_GetItemTextString($ListView1, $i)
                If _GUICtrlListView_GetItemChecked($ListView1, $i) = True Then $Texts &= '第:' & $i + 1 & ' 项被选中' & '   项目文本:' & $Text & @CRLF & @CRLF
        Next
        MsgBox(64, '选中项目', $Texts)
        $Texts = ''
EndFunc   ;==>read

Func Del()
        Local $z = 0
        $Num = _GUICtrlListView_GetItemCount($ListView1)
        For $i = 0 To $Num
                If _GUICtrlListView_GetItemChecked($ListView1, $i - $z) = True Then
                        _GUICtrlListView_DeleteItem($ListView1, $i - $z)
                        $z += 1
                EndIf
        Next
EndFunc   ;==>Del
发表于 2011-3-29 23:01:07 | 显示全部楼层
回覆 8# pdp320921

在Run(_GUICtrlListView_GetItemText($Lv, $i, 2))後面插入一个函数传入要卸载的程序名
AutoUninstall(_GUICtrlListView_GetItemText($Lv, $i, 1))


Func AutoUninstall($Name)
        Switch $Name
                Case "Skype Toolbars"
                        If WinWaitActive("Skype Toolbars Setup","") Then
                                Send("!n")
                                WinWaitActive("Skype Toolbars Setup","Removes Skype Toolbars")
                                Send("!r")
                                WinWaitActive("Skype Toolbars Setup","Ready to remove Skype Toolbar")
                                Send("!r")
                                WinWaitActive("Skype Toolbars Setup","Completed the Skype Toolbars Setup Wizard")
                                Send("{ENTER}")
                        EndIf 
                Case "Microsoft SQL Server 2005 Compact Edition [ENU]"
                        ;.  以下省略
                        ;.
                        ;.
        EndSwitch
EndFunc
 楼主| 发表于 2011-3-30 10:17:59 | 显示全部楼层
本帖最后由 pdp320921 于 2011-3-30 10:19 编辑

回复 10# xxoojoeooxx
感谢楼上的回复,基本可以解决了,不过程序运行时会同时打开多个卸载窗口我把Run(_GUICtrlListView_GetItemText($Lv, $i, 2))换成
Runwait(_GUICtrlListView_GetItemText($Lv, $i, 2))后程序停留在卸载窗口不能继续下一步(自动卸载的脚本代码没问题),
不知如何解决??
发表于 2011-3-30 18:49:36 | 显示全部楼层
回复 11# pdp320921

Runwait会在某些卸载程序中停住直到卸载程序结束
所以在Runwait 之後的自动卸载 无法执行

你可以在
Case "xxx"
之後添加一个msgbox测试是否有执行到
没执行到将会执行下一个卸载程序
其中"xxx"要确定与传入的参数相同
 楼主| 发表于 2011-3-30 19:18:58 | 显示全部楼层
回复 12# xxoojoeooxx

不懂,我只希望虽然我点选了多个checkbox,但程序依然能够一个一个地去完成自动卸载,而不是同时~
发表于 2011-3-30 19:28:55 | 显示全部楼层
回复 13# pdp320921


简单的说
对应的WinWaitActive可能没有执行到
 楼主| 发表于 2011-3-30 19:57:36 | 显示全部楼层
回复 14# xxoojoeooxx

我知道啊,可不知怎么得以解决啊~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-11 05:18 , Processed in 0.146814 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表