[已解决] 为什么用AutoIt v3.3.16.1编译的时候以前好些代码不能生成exe?
本帖最后由 令狐大虾 于 2023-4-20 01:50 编辑以前的版本是可以,这个版本有些代码编译时候无法生成exe,麻烦帮我看看啊
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1_1 = GUICreate('多合一系统安装器 By 令狐大虾', 420, 150)
$Button1 = GUICtrlCreateButton('1、Windows XP SP3 Professional', 5, 20, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button2 = GUICtrlCreateButton('2、Windows 2003 SP2 Enterprise', 5, 70, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button3 = GUICtrlCreateButton('3、Ghost手动备份和恢复程序', 220, 20, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button4 = GUICtrlCreateButton('使用说明', 220, 70, 55, 30, $BS_LEFT)
$Label1= GUICtrlCreateLabel('', 5, 120, 195, 30, $BS_LEFT)
$Label2= GUICtrlCreateLabel('QQ:425283 微信:D286688496', 220, 120, 195, 30, $BS_LEFT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;============================================================================================================================
Case $Button1 ;1、Windows XP SP3 Professional
$msg = MsgBoxE(3+64, '','Windows XP SP3 Professional全自动安装程序'&@CRLF&@CRLF&'警告:程序将格式化C盘、请预先备份好资料、并确认PE下C盘为可安装系统分区后再运行!', 0, '', 'wim安装版', 'i386版', '退出', '', 0)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;退出
EndSelect
;============================================================================================================================
Case $Button2 ;2、Windows 2003 SP2 Enterprise
$msg = MsgBoxE(3+64, '','Windows 2003 SP2 Enterprise全自动安装程序'&@CRLF&@CRLF&'警告:程序将格式化C盘、请预先备份好资料、并确认PE下C盘为可安装系统分区后再运行!', 0, '', 'wim安装版', 'i386版', '退出', '', 0)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;退出
EndSelect
;============================================================================================================================
Case $Button3 ;3、Ghost手动备份和恢复程序
$msg = MsgBoxE(3+64, '提示','Ghost手动备份和恢复程序', 0, '', 'Ghost32', 'GhostZ9', '退出', '',100)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;==>退出
EndSelect
;============================================================================================================================
Case $Button4 ;使用说明
FileInstall('相关调用\03PE多合一系统安装器使用说明.txt',@TempDir & '\',1)
If FileExists (@TempDir & '\03PE多合一系统安装器使用说明.txt') Then ShellExecute(@TempDir & '\03PE多合一系统安装器使用说明.txt')
;============================================================================================================================
;总体$msg = MsgBoxE 位置和文字
Func MsgBoxE($flag, $title, $text, $timeout = 0, $hwnd = '', $Button1 = '', $Button2 = '', $Button3 = '', $x = '', $y = '')
; 参数加在 title 后面传递给 MB__CallBack,避免使用全局变量
$title &= @CRLF & 'B1=' & $Button1 & @CRLF & 'B2=' & $Button2 & @CRLF & 'B3=' & $Button3 & @CRLF & 'x=' & $x & @CRLF & 'y=' & $y
Local $hGUI = GUICreate("")
Local $sFuncName = "GetWindowLongW"
If @AutoItX64 Then $sFuncName = "GetWindowLongPtrW"
Local $aResult = DllCall("user32.dll", "long_ptr", $sFuncName, "hwnd", $hGUI, "int", -6)
Local $hInst = $aResult
$aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
Local $iThreadId = $aResult
Local $hCallBack = DllCallbackRegister("MB__CallBack", "int", "int;hWnd;ptr")
Local $pCallBack = DllCallbackGetPtr($hCallBack)
$aResult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", 5, "ptr", $pCallBack, "handle", $hInst, "dword", $iThreadId)
Local $hHook = $aResult
Local $msg = MsgBox($flag, $title, $text, $timeout, $hwnd)
GUIDelete($hGUI)
DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hHook)
DllCallbackFree($hCallBack)
Return $msg
EndFunc ;==>MsgBoxE
Func MB__CallBack($iCode, $wParam, $lParam)
;~ ConsoleWrite('$iCode=' & $iCode & ', $wParam=' & $wParam & ', $lParam=' & $lParam & @CRLF)
If $iCode = 5 Then
Local $title = WinGetTitle($wParam)
If Not StringInStr($title, @CRLF & 'B1=') Then Return
Local $match = StringRegExp($title, '(?i)\r\nB1=(.*)\r\nB2=(.*)\r\nB3=(.*)\r\nx=(.*)\r\ny=(.*)', 1)
If @error Then Return
; 改回 title
$title = StringRegExpReplace($title, '(?i)(?s)\r\nB1=.*', '')
WinSetTitle($wParam, '', $title)
; 移动 MsgBox 位置
If $match <> '' Or $match <> '' Then
If $match = '' Then $match = Default
If $match = '' Then $match = Default
WinMove($wParam, '', $match, $match)
EndIf
; 修改按钮文字
If $match <> '' Then ControlSetText($wParam, '', 'Button1', $match)
If $match <> '' Then ControlSetText($wParam, '', 'Button2', $match)
If $match <> '' Then ControlSetText($wParam, '', 'Button3', $match)
EndIf
EndFunc ;==>MB__CallBack
;============================================================================================================================
EndSwitch
WEnd
代码里面用了指定msg的修改变量,以前用3.3.14.5编译后是可以正常运行的。
若 功力不够的话,scite里F5运行下看看哪里错误,至少会给你指出出错的行吧 函数不能放在条件语句内。
移动到外部就正常了
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1_1 = GUICreate('多合一系统安装器 By 令狐大虾', 420, 150)
$Button1 = GUICtrlCreateButton('1、Windows XP SP3 Professional', 5, 20, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button2 = GUICtrlCreateButton('2、Windows 2003 SP2 Enterprise', 5, 70, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button3 = GUICtrlCreateButton('3、Ghost手动备份和恢复程序', 220, 20, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button4 = GUICtrlCreateButton('使用说明', 220, 70, 55, 30, $BS_LEFT)
$Label1 = GUICtrlCreateLabel('', 5, 120, 195, 30, $BS_LEFT)
$Label2 = GUICtrlCreateLabel('QQ:425283 微信:D286688496', 220, 120, 195, 30, $BS_LEFT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;============================================================================================================================
Case $Button1 ;1、Windows XP SP3 Professional
$msg = MsgBoxE(3 + 64, '', 'Windows XP SP3 Professional全自动安装程序' & @CRLF & @CRLF & '警告:程序将格式化C盘、请预先备份好资料、并确认PE下C盘为可安装系统分区后再运行!', 0, '', 'wim安装版', 'i386版', '退出', '', 0)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;退出
EndSelect
;============================================================================================================================
Case $Button2 ;2、Windows 2003 SP2 Enterprise
$msg = MsgBoxE(3 + 64, '', 'Windows 2003 SP2 Enterprise全自动安装程序' & @CRLF & @CRLF & '警告:程序将格式化C盘、请预先备份好资料、并确认PE下C盘为可安装系统分区后再运行!', 0, '', 'wim安装版', 'i386版', '退出', '', 0)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;退出
EndSelect
;============================================================================================================================
Case $Button3 ;3、Ghost手动备份和恢复程序
$msg = MsgBoxE(3 + 64, '提示', 'Ghost手动备份和恢复程序', 0, '', 'Ghost32', 'GhostZ9', '退出', '', 100)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;==>退出
EndSelect
;============================================================================================================================
Case $Button4 ;使用说明
FileInstall('相关调用\03PE多合一系统安装器使用说明.txt', @TempDir & '\', 1)
If FileExists(@TempDir & '\03PE多合一系统安装器使用说明.txt') Then ShellExecute(@TempDir & '\03PE多合一系统安装器使用说明.txt')
;============================================================================================================================
;总体$msg = MsgBoxE 位置和文字
;============================================================================================================================
EndSwitch
WEnd
Func MsgBoxE($flag, $title, $text, $timeout = 0, $hwnd = '', $Button1 = '', $Button2 = '', $Button3 = '', $x = '', $y = '')
; 参数加在 title 后面传递给 MB__CallBack,避免使用全局变量
$title &= @CRLF & 'B1=' & $Button1 & @CRLF & 'B2=' & $Button2 & @CRLF & 'B3=' & $Button3 & @CRLF & 'x=' & $x & @CRLF & 'y=' & $y
Local $hGUI = GUICreate("")
Local $sFuncName = "GetWindowLongW"
If @AutoItX64 Then $sFuncName = "GetWindowLongPtrW"
Local $aResult = DllCall("user32.dll", "long_ptr", $sFuncName, "hwnd", $hGUI, "int", -6)
Local $hInst = $aResult
$aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
Local $iThreadId = $aResult
Local $hCallBack = DllCallbackRegister("MB__CallBack", "int", "int;hWnd;ptr")
Local $pCallBack = DllCallbackGetPtr($hCallBack)
$aResult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", 5, "ptr", $pCallBack, "handle", $hInst, "dword", $iThreadId)
Local $hHook = $aResult
Local $msg = MsgBox($flag, $title, $text, $timeout, $hwnd)
GUIDelete($hGUI)
DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hHook)
DllCallbackFree($hCallBack)
Return $msg
EndFunc ;==>MsgBoxE
Func MB__CallBack($iCode, $wParam, $lParam)
;~ ConsoleWrite('$iCode=' & $iCode & ', $wParam=' & $wParam & ', $lParam=' & $lParam & @CRLF)
If $iCode = 5 Then
Local $title = WinGetTitle($wParam)
If Not StringInStr($title, @CRLF & 'B1=') Then Return
Local $match = StringRegExp($title, '(?i)\r\nB1=(.*)\r\nB2=(.*)\r\nB3=(.*)\r\nx=(.*)\r\ny=(.*)', 1)
If @error Then Return
; 改回 title
$title = StringRegExpReplace($title, '(?i)(?s)\r\nB1=.*', '')
WinSetTitle($wParam, '', $title)
; 移动 MsgBox 位置
If $match <> '' Or $match <> '' Then
If $match = '' Then $match = Default
If $match = '' Then $match = Default
WinMove($wParam, '', $match, $match)
EndIf
; 修改按钮文字
If $match <> '' Then ControlSetText($wParam, '', 'Button1', $match)
If $match <> '' Then ControlSetText($wParam, '', 'Button2', $match)
If $match <> '' Then ControlSetText($wParam, '', 'Button3', $match)
EndIf
EndFunc ;==>MB__CallBack
gyp2000 发表于 2023-4-19 20:36
函数不能放在条件语句内。
移动到外部就正常了
谢谢哥们!今天去帮同学网吧组装机子现在才看到。再次谢谢! 本帖最后由 令狐大虾 于 2023-4-19 22:37 编辑
gyp2000 发表于 2023-4-19 20:36
函数不能放在条件语句内。
移动到外部就正常了
再次请教,示例一下,这个代码只要添加了复制文件进度条就会提示出错#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=x64.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Description=AutoInstall_x64
#AutoIt3Wrapper_Res_Fileversion=0.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=令狐大虾
#AutoIt3Wrapper_Res_Language=2052
#AutoIt3Wrapper_Res_requestedExecutionLevel=None
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Antidecompile=y
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1_1 = GUICreate('多合一系统安装器 By 令狐大虾', 420, 150)
$Button1 = GUICtrlCreateButton('1、Windows XP SP3 Professional', 5, 20, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button2 = GUICtrlCreateButton('2、Windows 2003 SP2 Enterprise', 5, 70, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button3 = GUICtrlCreateButton('3、Ghost手动备份和恢复程序', 220, 20, 195, 30, $BS_LEFT, $WS_EX_TRANSPARENT)
$Button4 = GUICtrlCreateButton('使用说明', 220, 70, 55, 30, $BS_LEFT)
$Label1 = GUICtrlCreateLabel('', 5, 120, 195, 30, $BS_LEFT)
$Label2 = GUICtrlCreateLabel('QQ:425283 微信:D286688496', 220, 120, 195, 30, $BS_LEFT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;============================================================================================================================
Case $Button1 ;1、Windows XP SP3 Professional
$msg = MsgBoxE(3 + 64, '', 'Windows XP SP3 Professional全自动安装程序' & @CRLF & @CRLF & '警告:程序将格式化C盘、请预先备份好资料、并确认PE下C盘为可安装系统分区后再运行!', 0, '', 'wim安装版', 'i386版', '退出', '', 0)
Select
Case $msg = 6
;复制进度条
_DirCopy(@UserProfileDir & '\桌面','D:\My Documents\')
Func _DirCopy($SourceDir,$Destdir)
Local $Shell
Local $FOF_SIMPLEPROGRESS = 16
If Not FileExists($Destdir) Then DirCreate($Destdir)
$Shell = ObjCreate("shell.application")
$Shell.namespace($Destdir).CopyHere($SourceDir,$FOF_SIMPLEPROGRESS)
EndFunc
Case $msg = 7
Case $msg = 2
;退出
EndSelect
;============================================================================================================================
Case $Button2 ;2、Windows 2003 SP2 Enterprise
$msg = MsgBoxE(3 + 64, '', 'Windows 2003 SP2 Enterprise全自动安装程序' & @CRLF & @CRLF & '警告:程序将格式化C盘、请预先备份好资料、并确认PE下C盘为可安装系统分区后再运行!', 0, '', 'wim安装版', 'i386版', '退出', '', 0)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;退出
EndSelect
;============================================================================================================================
Case $Button3 ;3、Ghost手动备份和恢复程序
$msg = MsgBoxE(3 + 64, '提示', 'Ghost手动备份和恢复程序', 0, '', 'Ghost32', 'GhostZ9', '退出', '', 100)
Select
Case $msg = 6
Case $msg = 7
Case $msg = 2
;==>退出
EndSelect
;============================================================================================================================
Case $Button4 ;使用说明
FileInstall('相关调用\03PE多合一系统安装器使用说明.txt', @TempDir & '\', 1)
If FileExists(@TempDir & '\03PE多合一系统安装器使用说明.txt') Then ShellExecute(@TempDir & '\03PE多合一系统安装器使用说明.txt')
;============================================================================================================================
;总体$msg = MsgBoxE 位置和文字
;============================================================================================================================
EndSwitch
WEnd
Func MsgBoxE($flag, $title, $text, $timeout = 0, $hwnd = '', $Button1 = '', $Button2 = '', $Button3 = '', $x = '', $y = '')
; 参数加在 title 后面传递给 MB__CallBack,避免使用全局变量
$title &= @CRLF & 'B1=' & $Button1 & @CRLF & 'B2=' & $Button2 & @CRLF & 'B3=' & $Button3 & @CRLF & 'x=' & $x & @CRLF & 'y=' & $y
Local $hGUI = GUICreate("")
Local $sFuncName = "GetWindowLongW"
If @AutoItX64 Then $sFuncName = "GetWindowLongPtrW"
Local $aResult = DllCall("user32.dll", "long_ptr", $sFuncName, "hwnd", $hGUI, "int", -6)
Local $hInst = $aResult
$aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
Local $iThreadId = $aResult
Local $hCallBack = DllCallbackRegister("MB__CallBack", "int", "int;hWnd;ptr")
Local $pCallBack = DllCallbackGetPtr($hCallBack)
$aResult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", 5, "ptr", $pCallBack, "handle", $hInst, "dword", $iThreadId)
Local $hHook = $aResult
Local $msg = MsgBox($flag, $title, $text, $timeout, $hwnd)
GUIDelete($hGUI)
DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hHook)
DllCallbackFree($hCallBack)
Return $msg
EndFunc ;==>MsgBoxE
Func MB__CallBack($iCode, $wParam, $lParam)
;~ ConsoleWrite('$iCode=' & $iCode & ', $wParam=' & $wParam & ', $lParam=' & $lParam & @CRLF)
If $iCode = 5 Then
Local $title = WinGetTitle($wParam)
If Not StringInStr($title, @CRLF & 'B1=') Then Return
Local $match = StringRegExp($title, '(?i)\r\nB1=(.*)\r\nB2=(.*)\r\nB3=(.*)\r\nx=(.*)\r\ny=(.*)', 1)
If @error Then Return
; 改回 title
$title = StringRegExpReplace($title, '(?i)(?s)\r\nB1=.*', '')
WinSetTitle($wParam, '', $title)
; 移动 MsgBox 位置
If $match <> '' Or $match <> '' Then
If $match = '' Then $match = Default
If $match = '' Then $match = Default
WinMove($wParam, '', $match, $match)
EndIf
; 修改按钮文字
If $match <> '' Then ControlSetText($wParam, '', 'Button1', $match)
If $match <> '' Then ControlSetText($wParam, '', 'Button2', $match)
If $match <> '' Then ControlSetText($wParam, '', 'Button3', $match)
EndIf
EndFunc ;==>MB__CallBack
令狐大虾 发表于 2023-4-19 22:32
再次请教,示例一下,这个代码只要添加了复制文件进度条就会提示出错
你这不是重犯一样的错误吗
Func _DirCopy 定义段 40-46 移出来 afan 发表于 2023-4-20 00:40
你这不是重犯一样的错误吗
Func _DirCopy 定义段 40-46 移出来
我只想要个复制进度条啊。谢谢回复 学习学习,路过支持一下。
页:
[1]