【发布时间】:2011-04-18 10:58:24
【问题描述】:
我正在尝试使用 Win32::GuiTest 来测试基于 InstallShield 的卸载过程。我可以打开控制面板,找到应用程序,然后调用 InstallShield,但我所做的似乎没有让我在安装程序中选择“删除”按钮。到目前为止,我有:
sub uninstall($;$) {
my ($name, $force) = @_;
if (! defined($force)) {
$force=0;
}
my @windows;
# Control Panel window
my $cpwin;
my $w;
my $text;
# Install Shield window
my $iswin;
# Run the Control Panel (In windir, do `control appwiz.cpl`)
system("cd %windir% && control appwiz.cpl");
sleep 1;
print("Opened control panel\n");
# Get the Window ID of the control panel
# FIXME - this label is system specifie (W7)
@windows = FindWindowLike(undef, "Programs and Features", "");
$cpwin = $windows[0];
printf("Found CP window ID %x\n", $cpwin);
# Get the Folder View window of the control panel
# Find the list of applications
@windows = FindWindowLike($cpwin, "FolderView");
$w = $windows[0];
# Find program in the list
if (Win32::GuiTest::SelListViewItemText($w, $name) == 0) {
printf("Could not find '$name'.\n");
return -1;
}
# Invoke the installer for by pressing [Return]
Win32::GuiTest::SendKeys("~");
# Wait for the "initializing the wizard" window
@windows = Win32::GuiTest::WaitWindow("InstallShield Wizard", 5);
# Wait for the real installer window
sleep 10;
@windows = Win32::GuiTest::WaitWindow("InstallShield Wizard", 3);
$iswin = $windows[0];
# Win32::GuiTest::WaitWindow("Remove");
printf("Found IS window ID %x\n", $iswin);
# Win32::GuiTest::SetFocus($iswin);
@windows = FindWindowLike($iswin, "&Remove", "Button");
my $remove = $windows[0];
printf("Found remove button %x\n", $remove);
Win32::GuiTest::PushButton($remove);
# Win32::GuiTest::SetFocus($remove);
# Win32::GuiTest::SendKeys("%r");
# Win32::GuiTest::MouseClick("Remove",$iswin);
# Win32::GuiTest::CheckButton($remove);
# Win32::GuiTest::SendKeys("{DOWN}{DOWN}");
# Win32::GuiTest::MouseClick("Next",$iswin);
# Win32::GuiTest::PushChildButton($iswin, "Cancel");
我尝试过的所有方法(最后注释掉)似乎都没有任何效果。
如果有任何问题,我在 Windows 7 上使用 ActivePerl 和 Win32::GuiTest。
(请客气。我的 Perl 可能很烂。我有超过 25 年的编程经验,但在 Perl 上不到一个月。)
【问题讨论】:
-
我继续尝试驱动 NSIS 安装程序。我也无法让它工作。我的同事让它在他真正的 XP 系统上工作,但我的 W7 VM 中没有启动器。 OTOH,记事本示例 (search.cpan.org/dist/Win32-GuiTest/lib/Win32/GuiTest/…) 对我来说很好。
标签: perl windows-7 installshield