找回密码
 加入
搜索
查看: 5846|回复: 12

[AU3基础] 如何给ip设置代码加皮肤

  [复制链接]
发表于 2012-10-3 20:36:27 | 显示全部楼层 |阅读模式
本帖最后由 dnvplj 于 2012-10-3 20:39 编辑
 
#include <ButtonConstants.au3>
 
#include <ComboConstants.au3>
 
#include <EditConstants.au3>
 
#include <GUIConstantsEx.au3>
 
#include <StaticConstants.au3>
 
#include <WindowsConstants.au3>
 
Opt("MustDeclareVars", 1)
 
Global Const $gc_FormName = "IP设置程序"
 
#Region
 
Global $gu_Form1 = GUICreate($gc_FormName, 337, 307, -1, -1)
 
Global $gu_Group1 = GUICtrlCreateGroup("IP设置方案", 8, 8, 321, 57)
 
Global $gu_Combo1 = GUICtrlCreateCombo("", 72, 32, 249, 25, _
 
  BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
 
Global $gu_Label6 = GUICtrlCreateLabel("选择方案", 16, 34, 52, 17)
 
GUICtrlCreateGroup("", -99, -99, 1, 1)
 
Global $gu_Group2 = GUICtrlCreateGroup("网络设置", 8, 72, 321, 193)
 
Global $gu_Label1 = GUICtrlCreateLabel("IP地址", 16, 104, 52, 17)
 
Global $gu_Label2 = GUICtrlCreateLabel("子网掩码", 16, 136, 52, 17)
 
Global $gu_Label3 = GUICtrlCreateLabel("默认网关", 16, 168, 52, 17)
 
Global $gu_Label4 = GUICtrlCreateLabel("首选DNS", 16, 200, 52, 17)
 
Global $gu_Label5 = GUICtrlCreateLabel("备用DNS", 16, 232, 52, 17)
 
Global $gu_Input1 = GUICtrlCreateInput("", 72, 102, 249, 21)
 
Global $gu_Input2 = GUICtrlCreateInput("", 72, 134, 249, 21)
 
Global $gu_Input3 = GUICtrlCreateInput("", 72, 166, 249, 21)
 
Global $gu_Input4 = GUICtrlCreateInput("", 72, 198, 249, 21)
 
Global $gu_Input5 = GUICtrlCreateInput("", 72, 230, 249, 21)
 
GUICtrlCreateGroup("", -99, -99, 1, 1)
 
Global $gu_Button1 = GUICtrlCreateButton("关于", 8, 272, 57, 25)
 
Global $gu_Button2 = GUICtrlCreateButton("执行", 200, 272, 65, 25)
 
Global $gu_Button3 = GUICtrlCreateButton("退出", 272, 272, 57, 25)
 
#EndRegion
 
_Main()
 
Exit
 
Func _Main()
 
GUICtrlSetData($gu_Combo1, _
 
   "[方案1] 办公室|[方案2] 家庭|[无方案] 自定义", _
 
   "[无方案] 自定义")
 
GUISetState(@SW_SHOW)
 

Local $nMsg
 
While 1
 
  $nMsg = GUIGetMsg()
 
  Switch $nMsg
 
   Case $GUI_EVENT_CLOSE
 
    Exit
 
   Case $gu_Combo1
 
    Local $Set = GUICtrlRead($gu_Combo1)
 
    _UseSet($Set)
 
   Case $gu_Button1
 
    MsgBox(0 + 64, $gc_FormName, _
 
      "本程序用于便捷的修改网络设置", _
 
      0, $gu_Form1)
 
   Case $gu_Button2
 
    _SetIp()
 
    MsgBox(0 + 64, $gc_FormName, "设置完成!", _
 
      0, $gu_Form1)
 
    Exit
 
   Case $gu_Button3
 
    Exit
 
  EndSwitch
 
WEnd
 
EndFunc   ;==>_Main
 
Func _UseSet($Set)
 
Switch $Set
 
  Case "[方案1] 办公室"
 
   GUICtrlSetData($gu_Input1, "192.168.137.206")
 
   GUICtrlSetData($gu_Input2, "255.255.255.0")
 
   GUICtrlSetData($gu_Input3, "192.168.137.1")
 
   GUICtrlSetData($gu_Input4, "8.8.8.8")
 
   GUICtrlSetData($gu_Input5, "8.8.4.4")
 
  Case "[方案2] 家庭"
 
   GUICtrlSetData($gu_Input1, "192.168.1.10")
 
   GUICtrlSetData($gu_Input2, "255.255.255.0")
 
   GUICtrlSetData($gu_Input3, "192.168.1.1")
 
   GUICtrlSetData($gu_Input4, "202.102.152.3")
 
   GUICtrlSetData($gu_Input5, "202.102.154.3")
 
  Case "[无方案] 自定义"
 
   GUICtrlSetData($gu_Input1, "")
 
   GUICtrlSetData($gu_Input2, "")
 
   GUICtrlSetData($gu_Input3, "")
 
   GUICtrlSetData($gu_Input4, "")
 
   GUICtrlSetData($gu_Input5, "")
 
EndSwitch
 
EndFunc   ;==>_UseSet
 
Func _SetIp()
 
Local $Name = "本地连接"
 
Local $IP = GUICtrlRead($gu_Input1)
 
Local $Mask = GUICtrlRead($gu_Input2)
 
Local $GateWay = GUICtrlRead($gu_Input3)
 
Local $pDNS = GUICtrlRead($gu_Input4)
 
Local $sDNS = GUICtrlRead($gu_Input5)
 

ProgressOn($gc_FormName, "正在设置网络,请稍候……", _
 
   "", -1, -1, $gu_Form1)
 
Switch @OSVersion
 
  Case "WIN_2000", "WIN_XP", "WIN_2003"
 
   ProgressSet(20, "设置IP地址和子网掩码……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ip set address name="' & _
 
     $Name & '" source=static addr=' & $IP & _
 
     ' mask=' & $Mask, "", @SW_HIDE)
 
   ProgressSet(40, "设置默认网关……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ip set address name="' & _
 
     $Name & '" gateway=' & $GateWay & _
 
     ' gwmetric=0', "", @SW_HIDE)
 
   ProgressSet(60, "设置首选DNS服务器……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ip set dns name="' & _
 
     $Name & '" source=static addr=' & $pDNS & _
 
     ' register=PRIMARY', "", @SW_HIDE)
 
   ProgressSet(80, "设置备用DNS服务器……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ip add dns name="' & _
 
     $Name & '" addr=' & $sDNS, "", @SW_HIDE)
 
   ProgressSet(100, "完成设置……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ip set wins name="' & _
 
     $Name & '" source=static addr=none', _ 
     "", @SW_HIDE)
 
  Case "WIN_VISTA", "WIN_2008", "WIN_7", "WIN_2008R2"
 
   ProgressSet(40, "设置IP地址、子网掩码、默认网关……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ipv4 set address name="' & _
 
     $Name & '" source=static addr=' & $IP & _
 
     ' mask=' & $Mask & ' gateway=' & $GateWay, _
 
     "", @SW_HIDE)
 
   ProgressSet(60, "设置首选DNS服务器……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ipv4 set dns name="' & _
 
     $Name & '" source=static addr=' & $pDNS & _
 
     ' register=PRIMARY', "", @SW_HIDE)
 
   ProgressSet(80, "设置备用DNS服务器……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ipv4 add dns name="' & _
 
     $Name & '" addr=' & $sDNS, "", @SW_HIDE)
 
   ProgressSet(100, "完成设置……")
 
   RunWait(@ComSpec & " /c " & _
 
     'netsh interface ipv4 set wins name="' & _
 
     $Name & '" source=static addr=none', _ 
     "", @SW_HIDE)
 
EndSwitch
 
ProgressOff()
 
EndFunc   ;==>_SetIp
请问各位朋友:如何给下段代码加个皮肤
发表于 2012-10-3 20:56:01 | 显示全部楼层
加什么皮肤?有好几种格式的   搜索一下论坛
 楼主| 发表于 2012-10-3 21:22:00 | 显示全部楼层
Form1.kxf
Skin.skf
SkinCrafterDll.dll
 楼主| 发表于 2012-10-3 21:29:23 | 显示全部楼层
本帖最后由 dnvplj 于 2012-10-3 21:31 编辑

试了好几回,也不行,不知怎么调用皮肤。
发表于 2012-10-3 22:02:21 | 显示全部楼层
回复 4# dnvplj

复制你的代码,直接F5,发生无数错误,我都懒得搞了~~

贴两个我自己的
skf格式的
;======================= 装入到编译后的文件 ========================================
FileInstall(".\SkinCrafterDll.dll",@TempDir&"SkinCrafterDll.dll",1)
FileInstall(".\skin.skf",@TempDir&"skin.skf",1)
;===================================================================================
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("华哥最帅!!", 443, 254, 192, 124)
Global $Dll                                                                                                ;增加本行
_SkinGUI(@TempDir&"SkinCrafterDll.dll", @TempDir&"skin.skf", $Form1)                ;增加本行,按本行格式改变创建窗体的赋值名称(这里是$Form1)即可
$Button1 = GUICtrlCreateButton("按钮1", 32, 32, 89, 33)
$Radio1 = GUICtrlCreateRadio("Radio1", 200, 32, 97, 33)
$List1 = GUICtrlCreateList("", 200, 88, 105, 32)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 296, 40, 97, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Quit()                                                                                ;改成这个函数,用于退出时卸载皮肤
                Case $Button1
                        MsgBox(0,'','测试信息!!')                        
        EndSwitch
WEnd
;调用皮肤函数,直接复制即可(包括下面的退出函数),所有的脚本只要将皮肤及闪屏文件改成:skin.skf即可调用成功
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle) 
   $Dll = DllOpen($SkincrafterDll) 
   DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1") 
   DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1) 
   DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin) 
   DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25) 
   DllCall($Dll, "int:cdecl", "ApplySkin") 
EndFunc      

;退出
Func Quit()
    GUISetState(@SW_HIDE)
    DllCall($dll, "int:cdecl", "DeInitDecoration")
    DllCall($dll, "int:cdecl", "RemoveSkin")
    DllClose($dll)
    FileDelete(@TempDir&"SkinCrafterDll.dll")
    FileDelete(@TempDir&"skin.skf")
    Exit
EndFunc


she格式

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Outfile=..\..\桌面\222.exe
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;我的SHE皮肤
#NoTrayIcon
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $Dll
FileInstall('skin.dll',@ProgramFilesDir&'\skin.dll')
FileInstall('浅蓝(默认).she',@ProgramFilesDir&'\浅蓝(默认).she')        ;要使用皮肤,需要将文件名改成"skin",或者使-------------------------------------------        ****注意:au3没有filerename()函数,请使用,filemove()来重命名!******
#Region ### START Koda GUI section ### Form=                                                                        ;;                                                                                                                  |将这三个文件名改成你皮肤的文件名
Global $dllpath=@ProgramFilesDir&'\skin.dll',$She=@ProgramFilesDir&'\浅蓝(默认).she'  ;这种调用皮肤的方法只要加上这些有注释的行就可以                ------------|
$Form1 = GUICreate("            华哥最帅!!", 287, 200, 192, 114)
Skin($She)                                                                ;加这行,调用
$Label1 = GUICtrlCreateLabel("风云第一刀", 0, 8, 146, 41)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Checkbox1 = GUICtrlCreateCheckbox("GOOD", 176, 8, 65, 25)
$Radio1 = GUICtrlCreateRadio("雷迪奥", 176, 48, 65, 33)
$List1 = GUICtrlCreateList("", 8, 64, 81, 32)
$Combo1 = GUICtrlCreateCombo("Combo1", 96, 64, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("弹出看看!!", 80, 128, 81, 25)
GUISetState(@SW_SHOW)
;加入下面这个函数
Func Skin($She)
        $Dll = DllOpen($dllpath)
        DllCall($Dll, "int", "SkinH_AttachEx", "str", $She, "str", "mhgd")
        DllCall($Dll, "int", "SkinH_SetAero", "int", 1)
EndFunc   ;==>Skin

#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        GUIDelete($Form1)
                        DllClose($Dll)
                        FileDelete($dllpath)
                        Exit
                Case $Button1
                        MsgBox(0,'','好的!!')
        EndSwitch
WEnd
发表于 2012-10-3 22:07:15 | 显示全部楼层
回复 5# annybaby


上两张图看看
SKF格式的





SHE格式的

本帖子中包含更多资源

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

×
 楼主| 发表于 2012-10-3 22:21:19 | 显示全部楼层
加我QQ:334788705
发表于 2012-10-4 09:32:48 | 显示全部楼层
这个看起来满给力的
发表于 2012-10-5 07:28:30 | 显示全部楼层
要是有那张图就好了
发表于 2012-10-8 21:26:32 | 显示全部楼层

支持!是路过的,顶起来看

其实我是水蒸气 我看看就走,你们聊!


















大连哪里有孕妇装专卖?2011冬季孕妇装大连有卖么
发表于 2012-10-10 09:07:41 | 显示全部楼层
路过。。。。看看而已
发表于 2012-10-10 10:36:12 | 显示全部楼层
来学习一下先。
发表于 2012-10-10 20:00:12 | 显示全部楼层
又学到一点东东,挺好
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-26 22:47 , Processed in 0.082466 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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