找回密码
 加入
搜索
查看: 597|回复: 9

[网络通信] [已解决] 为什么用AutoIt v3.3.16.1编译的时候以前好些代码不能生成exe?

[复制链接]
发表于 2023-4-19 04:42:14 | 显示全部楼层 |阅读模式
本帖最后由 令狐大虾 于 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[0]
        $aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
        Local $iThreadId = $aResult[0]
        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[0]
        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[3] <> '' Or $match[4] <> '' Then
                        If $match[3] = '' Then $match[3] = Default
                        If $match[4] = '' Then $match[4] = Default
                        WinMove($wParam, '', $match[3], $match[4])
                EndIf
                ; 修改按钮文字
                If $match[0] <> '' Then ControlSetText($wParam, '', 'Button1', $match[0])
                If $match[1] <> '' Then ControlSetText($wParam, '', 'Button2', $match[1])
                If $match[2] <> '' Then ControlSetText($wParam, '', 'Button3', $match[2])
        EndIf
EndFunc   ;==>MB__CallBack

;============================================================================================================================

        EndSwitch
WEnd
代码里面用了指定msg的修改变量,以前用3.3.14.5编译后是可以正常运行的。


发表于 2023-4-19 16:07:27 来自手机 | 显示全部楼层
若 功力不够的话,scite里F5运行下看看哪里错误,至少会给你指出出错的行吧

点评

谢谢!  发表于 2023-4-19 22:25
发表于 2023-4-19 20:36:23 | 显示全部楼层
函数不能放在条件语句内。

移动到外部就正常了
#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[0]
        $aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
        Local $iThreadId = $aResult[0]
        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[0]
        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[3] <> '' Or $match[4] <> '' Then
                        If $match[3] = '' Then $match[3] = Default
                        If $match[4] = '' Then $match[4] = Default
                        WinMove($wParam, '', $match[3], $match[4])
                EndIf
                ; 修改按钮文字
                If $match[0] <> '' Then ControlSetText($wParam, '', 'Button1', $match[0])
                If $match[1] <> '' Then ControlSetText($wParam, '', 'Button2', $match[1])
                If $match[2] <> '' Then ControlSetText($wParam, '', 'Button3', $match[2])
        EndIf
EndFunc   ;==>MB__CallBack

 楼主| 发表于 2023-4-19 21:38:59 | 显示全部楼层
gyp2000 发表于 2023-4-19 20:36
函数不能放在条件语句内。

移动到外部就正常了

谢谢哥们!今天去帮同学网吧组装机子现在才看到。再次谢谢!
 楼主| 发表于 2023-4-19 22:32:29 | 显示全部楼层
本帖最后由 令狐大虾 于 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[0]
        $aResult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
        Local $iThreadId = $aResult[0]
        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[0]
        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[3] <> '' Or $match[4] <> '' Then
                        If $match[3] = '' Then $match[3] = Default
                        If $match[4] = '' Then $match[4] = Default
                        WinMove($wParam, '', $match[3], $match[4])
                EndIf
                ; 修改按钮文字
                If $match[0] <> '' Then ControlSetText($wParam, '', 'Button1', $match[0])
                If $match[1] <> '' Then ControlSetText($wParam, '', 'Button2', $match[1])
                If $match[2] <> '' Then ControlSetText($wParam, '', 'Button3', $match[2])
        EndIf
EndFunc   ;==>MB__CallBack
发表于 2023-4-20 00:40:24 | 显示全部楼层
令狐大虾 发表于 2023-4-19 22:32
再次请教,示例一下,这个代码只要添加了复制文件进度条就会提示出错

你这不是重犯一样的错误吗
Func _DirCopy 定义段 40-46 移出来
 楼主| 发表于 2023-4-20 00:45:51 | 显示全部楼层
afan 发表于 2023-4-20 00:40
你这不是重犯一样的错误吗
Func _DirCopy 定义段 40-46 移出来

我只想要个复制进度条啊。谢谢回复

点评

A版的意思是 函数语句 不能放在条件语句里面,,移出来,你照样可以调用  发表于 2023-4-20 08:59
发表于 2023-4-24 10:35:37 | 显示全部楼层
学习学习,路过支持一下。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 15:49 , Processed in 0.091391 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表