Chinaunix首页 | 论坛 | 博客
  • 博客访问: 599858
  • 博文数量: 60
  • 博客积分: 3993
  • 博客等级: 中校
  • 技术积分: 1572
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 17:08
文章分类

全部博文(60)

文章存档

2012年(7)

2011年(35)

2010年(8)

2009年(7)

2008年(3)

分类: Python/Ruby

2011-11-17 18:58:28

样例1:修改“Start”样式为经典启动菜单

autoIT:

  1. Func changeStartMenu()
  2.         GUICtrlSetData($statusLabel,"Running ... changeStartMenu")
  3.         Send("{LWIN}")
  4.         Local $startMenuWnd = WinWait("Start Menu","",1)
  5.         If ($startMenuWnd) Then
  6.                 WinActivate("Start Menu")
  7.                 Send("{APPSKEY}")
  8.                 Sleep(1000)
  9.                 Send("+r")
  10.                 Local $startMenuPropertesWnd = WinWait("Taskbar and Start Menu Properties","Select this option",2)
  11.                 If ($startMenuPropertesWnd) Then
  12.                         ControlClick("Taskbar and Start Menu Properties","","[CLASS:Button;INSTANCE:2]")
  13.                         Sleep(1000)
  14.                         ControlClick("Taskbar and Start Menu Properties","","[CLASS:Button;INSTANCE:5]")
  15.                         WinClose("Taskbar and Start Menu Properties") ; force window close
  16.                         GUICtrlSetData($statusLabel,"Completed ... changeStartMenu: change StartMenu -> Classic StartMenu")
  17.                 Else
  18.                         GUICtrlSetData($statusLabel,"Error ... changeStartMenu: no found 'Taskbar and Start Menu Properties' window")

  19.                 EndIf
  20.         Else
  21.                 Send("{LWIN}")
  22.                 GUICtrlSetData($statusLabel,"Completed ... changeStartMenu: Already set to Classic Menu")
  23.         EndIf
  24. EndFunc

Perl:

  1. use Win32::GuiTest qw(:ALL);

  2. sub changeStartMenu() {
  3.     my $rtStatus=0;
  4.     my $errMsg="";
  5.     SendKeys("{LWIN}",1);
  6.     my $startMenuID;
  7.     WaitWindowLike(0,"","^DV2ControlHost\$",0,9,2);        
  8.     ($startMenuID) = FindWindowLike(0,"","^DV2ControlHost\$");
  9.     SetForegroundWindow($startMenuID);
  10.     print "find startMenu:$startMenuID\n";
  11.     if ($startMenuID) {
  12.         print "send {APP}\n";
  13.         SendKeys("{APP}",1);
  14.         print "send ctrl-r\n";
  15.         SendKeys("^r",1);
  16.         my $menuSettingsID;
  17.         WaitWindowLike(GetDesktopWindow(),"","^#32770\$",$startMenuID,9,3);        
  18.         ($menuSettingsID) = FindWindowLike(0,"","^#32770\$");
  19.         SetForegroundWindow($menuSettingsID);
  20.         print "find menuSettingsID:$startMenuID\n";
  21.         if ($menuSettingsID) {
  22.             MouseClick("&M",$menuSettingsID, undef, undef, '{LEFT}');
  23.             sleep 1;
  24.             #MouseClick("确定",$menuSettingsID, undef, undef, '{LEFT}');
  25.             MouseClick(1,$menuSettingsID, undef, undef, '{LEFT}'); #确定Button的ID为1
  26.             $rtStatus = 1;
  27.         } else {
  28.             $$errMsg = "can not find start up settinig window";
  29.             $rtStatus=-1;
  30.         }
  31.     } else {
  32.         SendKeys("{LWIN}",1);
  33.         $errMsg = "Already changed to classic menu";
  34.         $rtStatus=1;
  35.     }
  36.     return($rtStatus,$errMsg);
  37. }
阅读(1959) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~