前言
最近刚开始接触学习AutoIT,该软件纯天然绿色、免费、轻量级、易上手,弱类型的BASIC语言风格,连CTRL+SHIFT+SPACE的用法都一样,不用安装身材硕大的开发环境,自带编译器,适合除98之外的WIN平台,解压后即可使用,我都是放在U盘里,随便插一台机器就能用了(这段算广告吧)。尽管说的那么容易,但还是要学习,尤其是各种函数以及辅助工具的配合使用。
言归正传
此次的学习实例是,解决在WIN7中安装VS2008后,无法在维护模式输入序列号的问题。分析一下,在WIN7以前的系统中可以显示,安装程序并没有更新,可以肯定只是在WIN7中对输入控件和升级按钮做了隐藏处理,我们要做的就是让这些控件显示出来即可,废话不多说,直接分享完整源代码。
完整源码
003 |
Company:www.chinavalue.net |
004 |
CreateTime:2010.08.07 |
005 |
Function :Show VS2008 Serial Number Controls
For WIN7 |
008 |
#include <GUIConstantsEx.au3> |
009 |
#include <ButtonConstants.au3> |
014 |
If @OSVersion <>
"WIN_7" Then |
015 |
ShowMessage( "该程序只能运行在Windows7系统中" ) |
019 |
;窗口标题,可根据本机安装的VS版本自行设置 |
020 |
Dim $windowTitle =
"Microsoft Visual Studio 2008 安装程序 - 维护页" |
022 |
;序列号,可根据本机安装的VS版本自行设置 |
024 |
$snArray[0] = "VS2008" |
025 |
$snArray[1] = "SerialNumber" |
026 |
$snArray[2] = "PYHYP" |
027 |
$snArray[3] = "WXB3B" |
028 |
$snArray[4] = "B2CCM" |
029 |
$snArray[5] = "V9DX9" |
030 |
$snArray[6] = "VDY8T" |
033 |
GUICreate( "WIN7安装VS2008的激活升级程序" , 336, 195) |
034 |
GUISetIcon( "VS2008.ico" ) |
035 |
GUISetBkColor(0xE4F4FF) |
038 |
FileInstall( "banner.jpg" , @TempDir &
"\banner.jpg" ) |
039 |
FileInstall( "blog.bmp" , @TempDir &
"\blog.bmp" ) |
040 |
FileInstall( "button.bmp" , @TempDir &
"\button.bmp" ) |
043 |
GuiCtrlCreatePic(@TempDir & "\banner.jpg" , 1, 1, 334, 157) |
046 |
$btnBlog = GUICtrlCreateButton( "博客地址" , 5, 165, 114, 23, $BS_BITMAP) |
047 |
GUICtrlSetImage($btnBlog, @TempDir &
"\blog.bmp" ) |
048 |
GUICtrlSetCursor($btnBlog, 0) |
051 |
$btnActive = GUICtrlCreateButton( "激活输入框" , 201, 165, 126, 23, $BS_BITMAP) |
052 |
GUICtrlSetImage($btnActive, @TempDir &
"\button.bmp" ) |
053 |
GUICtrlSetCursor($btnActive, 0) |
055 |
GUISetState(@SW_SHOW) |
061 |
Case
$msg = $btnActive |
063 |
WinActivate($windowTitle) |
066 |
Dim
$isActive = WinActive($windowTitle) |
069 |
If
$isActive = 0 Then |
070 |
ShowMessage( "请先进入VS2008维护模式再运行本程序" ) |
074 |
If
$isActive <> 0 Then |
080 |
ControlShow($windowTitle,
"" , "[CLASS:Edit; INSTANCE:"
& $controlID & "]" ) |
081 |
ControlEnable($windowTitle,
"" , "[CLASS:Edit; INSTANCE:"
& $controlID & "]" ) |
082 |
ControlSetText($windowTitle,
"" , "[CLASS:Edit; INSTANCE:"
& $controlID & "]" , $snArray[$controlID]) |
084 |
$controlID = $controlID + 1 |
088 |
ControlShow($windowTitle,
"" , "[CLASS:Button; INSTANCE:43]" ) |
089 |
ControlEnable($windowTitle,
"" , "[CLASS:Button; INSTANCE:43]" ) |
096 |
Case
$msg = $GUI_EVENT_CLOSE |
102 |
Func ShowMessage($msg) |
103 |
MsgBox(64,
"系统提示" , $msg) |
注释已经很清楚了,我就不多说什么了。
截图预览
![](https://pic002.cnblogs.com/img/im0417/201008/2010080812081544.jpg)
程序下载(已激活的也可以试用)