使用AU3编写光盘自动启动菜单

前一篇文章,和大家说了我这段时间在搞GhostXP是吧,GhostXP的Windows下的光盘启动菜单,我找来找去都不满意,后来决定自己写一个玩玩,因为VB、VC我都不会,我就勉强看几篇自由天空的教程,查着AU3简体中文手册,写成了这个Autorun,当然,我承认,这里很多东西网上都有成品源码可抄,所以我左吸收一点,右搬空一点,勉勉强强弄成这样子的程序。

放出图片预览:

Autorun UI 界面

不错吧,好了,放出源码:

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=Autorun.ico
#AutoIt3Wrapper_outfile=Autorun.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#NoAutoIt3Execute
#NoTrayIcon
#RequireAdmin
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form = GUICreate("Nikbobo GXP SP3 菜单", 640, 480, -1, -1)
GUISetBkColor(0xABCDEF)
$Background = GUICtrlCreatePic(@ScriptDir & "\Autorun.jpg", 0, 0, 640, 480)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetDefBkColor($GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetDefColor($GUI_BKCOLOR_TRANSPARENT)
_API_SetLayeredWindowAttributes($Form, 0xABCDEF)
GUISetFont(14)
$Label1 = GUICtrlCreateLabel("安装系统到硬盘第一分区", 220, 230, 205, 20)
$Label2 = GUICtrlCreateLabel("运行 Ghost32 备份/还原", 220, 260, 205, 20)
$Label3 = GUICtrlCreateLabel("运行 Ghost 镜像浏览器", 220, 290, 200, 20)
$Label4 = GUICtrlCreateLabel("备份当前计算机驱动程序", 220, 320, 205, 20)
$Label5 = GUICtrlCreateLabel("备份当前计算机资料", 220, 350, 170, 20)
$Label6 = GUICtrlCreateLabel("查看光盘说明", 220, 380, 110, 20)
$Label7 = GUICtrlCreateLabel("浏览光盘", 350, 380, 80, 20)
GUICtrlSetCursor($Label1, 0)
GUICtrlSetCursor($Label2, 0)
GUICtrlSetCursor($Label3, 0)
GUICtrlSetCursor($Label4, 0)
GUICtrlSetCursor($Label5, 0)
GUICtrlSetCursor($Label6, 0)
GUICtrlSetCursor($Label7, 0)
GUISetState(@SW_SHOW)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Label1
			Run("OneKey.exe")
		Case $Label2
			Run("Ghost32.exe")
		Case $Label3
			Run("GhostExp.exe")
		Case $Label4
			Run("Driver.exe")
		Case $Label5
			Run("Backup.exe")
		Case $Label6
			ShellExecute("Readme.txt")
		Case $Label7
			ShellExecute(@ScriptDir)
	EndSwitch
WEnd
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
Local Const $AC_SRC_ALPHA = 1
Local Const $ULW_ALPHA = 2
Local Const $LWA_ALPHA = 0x2
Local Const $LWA_COLORKEY = 0x1
If Not $isColorRef Then
  $i_transcolor = Hex(String($i_transcolor), 6)
  $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
Select
  Case @error
   Return SetError(@error, 0, 0)
  Case $Ret[0] = 0
   Return SetError(4, 0, 0)
  Case Else
   Return 1
EndSelect
EndFunc   ;==>_API_SetLayeredWindowAttributes

 

源码、所需材料和成品文件打包下载:Autorun.Zip

放置于你所制作的光盘根目录。

仿制指南:

1、修改AutoRun.jpg,换成你喜欢的背景图片。

2、修改AutoRun.au3,根据你的需要,更换文字,及文字坐标、文字点击框块宽高,运行程序名称等。

3、换成你喜欢的Autorun.ico。

呵呵,只是初学AU3,若其中有些代码,可能在高手眼中还有更好办法,让大家见笑了。

此文章是由nikbobo发表在旧博客分类目录的。将固定链接加入收藏夹。

关于 nikbobo

Nikbobo,本名刘永强,记忆空间站长,男,1998 年出生于广东茂名,至今(2022 年)23 岁,目前(2022 年)就读于广州大学华软软件学院,常以“nikbobo”这个网名混迹互联网。如无特殊注明,Nikbobo 在本站发表的文章,遵循 知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议。详情请参阅关于页面的作者介绍。

使用AU3编写光盘自动启动菜单》上有100个想法

发表回复

您的电子邮箱地址不会被公开。