找回密码
 加入
搜索
查看: 4366|回复: 3

[GUI管理] 【已解决】如何通过判断语句将Button状态设置为不可用

[复制链接]
发表于 2014-12-29 09:45:13 | 显示全部楼层 |阅读模式
本帖最后由 szlanpa 于 2014-12-29 10:23 编辑

请教各位大大~
正在制作一个Office兼容模式切换的工具

现在已经实现判断Office版本并弹出提示告知用户安装的Office
能否做到再加个判断,如果检测安装的为Office2010版本,提示弹出来后将Office2007的几个按钮设置为Disable。反之将Office2010的按钮设置为Disable
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_icon=..\..\..\..\Program Files\Microsoft Office\Office14\protocolhandler.exe|-1
#PRE_Outfile=ODF.exe
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
ODF()
Func ODF()
        Local $Button1,$Button2,$Button3,$Button4,$msg
        $owordver = ObjCreate("Word.Application.8") 
        $OfficeVer = $owordver.Version
        If $OfficeVer ="12.0" Then
                MsgBox(0,"温馨提示","您的Office版本为Office 2007,请运行Office 2007脚本")
         ElseIf $OfficeVer ="14.0" Then
                MsgBox(0,"温馨提示","您的Office版本为Office 2010,请运行Office 2010脚本")
        EndIf
        GUICreate("Office兼容模式切换助手",280,230) 
        GUISetState(@SW_SHOW)
        GUICtrlCreateLabel("Office 2010",5,10)
        GUICtrlCreateLabel("Office 2007",5,70)
        GUICtrlCreateLabel("使用说明:",5,130)
        GUICtrlCreateLabel("工具适用范围(Word,Excel,PowerPoint)",5,150)
        GUICtrlCreateLabel("保存兼容模式:新建文档默认保存为Office2003格式",5,170)
        GUICtrlCreateLabel("还原默认模式:将文档默认保存恢复为原有格式",5,190)
        $Button1=GUICtrlCreateButton("保存兼容模式",25,30)
        $Button2=GUICtrlCreateButton("还原默认模式",135,30)
        $Button3=GUICtrlCreateButton("保存兼容模式",25,90)
        $Button4=GUICtrlCreateButton("还原默认模式",135,90)
        While 1
                $msg = GUIGetMsg()
                Select
                        Case $msg = $GUI_EVENT_CLOSE        ;点击关闭按钮,窗口关闭
                                ExitLoop
                        Case $msg = $Button1
                                Run('Office2010.bat')    ; 点击按钮 1 运行office 2007兼容脚本
                        Case $msg = $Button2
                                Run('Office2010_bak.bat')    ; 点击按钮 2 运行office 2007还原默认脚本
                        Case $msg = $Button3
                                Run('Office2007.bat')    ; 点击按钮 3 运行office 2010兼容脚本
                        Case $msg = $Button4
                                Run('Office2007_bak.bat')    ; 点击按钮 4 运行office 2010还原默认脚本                        
                EndSelect
        WEnd
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-12-29 10:19:21 | 显示全部楼层
回复 1# szlanpa
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_icon=..\..\..\..\Program Files\Microsoft Office\Office14\protocolhandler.exe|-1
#PRE_Outfile=ODF.exe
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
ODF()
Func ODF()
        Local $Button1,$Button2,$Button3,$Button4,$msg
        $owordver = ObjCreate("Word.Application.8") 
        $OfficeVer = $owordver.Version
        If $OfficeVer ="12.0" Then
                MsgBox(0,"温馨提示","您的Office版本为Office 2007,请运行Office 2007脚本")
         ElseIf $OfficeVer ="14.0" Then
                MsgBox(0,"温馨提示","您的Office版本为Office 2010,请运行Office 2010脚本")
        EndIf
        GUICreate("Office兼容模式切换助手",280,230) 
        GUISetState(@SW_SHOW)
        GUICtrlCreateLabel("Office 2010",5,10)
        GUICtrlCreateLabel("Office 2007",5,70)
        GUICtrlCreateLabel("使用说明:",5,130)
        GUICtrlCreateLabel("工具适用范围(Word,Excel,PowerPoint)",5,150)
        GUICtrlCreateLabel("保存兼容模式:新建文档默认保存为Office2003格式",5,170)
        GUICtrlCreateLabel("还原默认模式:将文档默认保存恢复为原有格式",5,190)
        $Button1=GUICtrlCreateButton("保存兼容模式",25,30)
        $Button2=GUICtrlCreateButton("还原默认模式",135,30)
        $Button3=GUICtrlCreateButton("保存兼容模式",25,90)
        $Button4=GUICtrlCreateButton("还原默认模式",135,90)
                If $OfficeVer ="12.0" Then 
                        GUICtrlSetState($Button1, $GUI_DISABLE)
                        GUICtrlSetState($Button2, $GUI_DISABLE)
                EndIf
                If $OfficeVer ="14.0" Then 
                        GUICtrlSetState($Button4, $GUI_DISABLE)
                        GUICtrlSetState($Button3, $GUI_DISABLE)
                EndIf
        While 1
                $msg = GUIGetMsg()
                Select
                        Case $msg = $GUI_EVENT_CLOSE        ;点击关闭按钮,窗口关闭
                                ExitLoop
                        Case $msg = $Button1
                                Run('Office2010.bat')    ; 点击按钮 1 运行office 2007兼容脚本
                        Case $msg = $Button2
                                Run('Office2010_bak.bat')    ; 点击按钮 2 运行office 2007还原默认脚本
                        Case $msg = $Button3
                                Run('Office2007.bat')    ; 点击按钮 3 运行office 2010兼容脚本
                        Case $msg = $Button4
                                Run('Office2007_bak.bat')    ; 点击按钮 4 运行office 2010还原默认脚本                        
                EndSelect
        WEnd
EndFunc
 楼主| 发表于 2014-12-29 10:23:26 | 显示全部楼层
回复 2# austere

非常感谢,功能已实现。
发表于 2014-12-30 08:15:29 | 显示全部楼层
謝謝樓主分享。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 13:38 , Processed in 0.080372 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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