【已解决】在图片GUI 上 创 建checkbox 的问题!还有个小问题!已更新
本帖最后由 laomeng 于 2013-5-13 12:21 编辑#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <winapiex.au3>
#include <GDIpProgress.au3>
#include <Thread.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=
Dim $iFlags,$ckbt1,$az,$exit,$Chip,$Audio,$Lan,$Video
If @OSLang = 0804 Then
$ckbt1 = IniRead(@ScriptDir & "\chinese.ini", "SET", "Form1", "")
$az = IniRead(@ScriptDir & "\chinese.ini", "BUT", "OK", "")
$exit = IniRead(@ScriptDir & "\chinese.ini", "BUT", "Exit", "")
$state =IniRead(@ScriptDir & "\chinese.ini", "STATE", "Ins", "")
$Chip = IniRead(@ScriptDir & "\chinese.ini", "Chip", "Chip", "")
$PATH_CHIP = IniRead(@ScriptDir & "\chinese.ini", "Chip", "PATH", "")
$Audio = IniRead(@ScriptDir & "\chinese.ini", "Audio", "Audio", "")
$PATH_AUDIO = IniRead(@ScriptDir & "\chinese.ini", "Audio", "PATH", "")
$Lan = IniRead(@ScriptDir & "\chinese.ini", "Lan", "Lan", "")
$PATH_XP = IniRead(@ScriptDir & "\chinese.ini", "Lan", "PATH_LAN_XP", "")
$Video = IniRead(@ScriptDir & "\chinese.ini", "Graphics", "Graphics", "")
Else
$ckbt1 = IniRead(@ScriptDir & "\default.ini", "SET", "Form1", "")
$az = IniRead(@ScriptDir & "\default.ini", "BUT", "OK", "")
$exit = IniRead(@ScriptDir & "\default.ini", "BUT", "Exit", "")
$state =IniRead(@ScriptDir & "\default.ini", "STATE", "Ins", "")
$Chip = IniRead(@ScriptDir & "\default.ini", "Chip", "Chip", "")
$PATH_CHIP = IniRead(@ScriptDir & "\default.ini", "Chip", "PATH", "")
$Audio = IniRead(@ScriptDir & "\default.ini", "Audio", "Audio", "")
$PATH_AUDIO = IniRead(@ScriptDir & "\default.ini", "Audio", "PATH", "")
$Lan = IniRead(@ScriptDir & "\default.ini", "Lan", "Lan", "")
$Video = IniRead(@ScriptDir & "\default.ini", "Graphics", "Graphics", "")
EndIf
$bBinary = Binary("0x33C0C20800CCCCCC")
$pDrawFocusRect = _RTGetProcAddress("User32.dll", "DrawFocusRect")
$tBinary = DllStructCreate("ubyte Code", $pDrawFocusRect)
_RTVirtualProtect($pDrawFocusRect, 8)
DllStructSetData($tBinary, "Code", $bBinary)
$image = "C:\Documents and Settings\Administrator\桌面\test.jpg"
$Theme = _WinAPI_GetThemeAppProperties()
$Form1 = GUICreate("Install", 626, 444,Default, Default, $WS_CAPTION)
GUISetFont(12, 400, 0, "宋体")
$Pic1 = GUICtrlCreatePic($image, 0, 0, 625, 441)
GUICtrlSetState(-1,$GUI_DISABLE)
_WinAPI_SetThemeAppProperties($iFlags)
$Group1 = GUICtrlCreateGroup("", 224, 64, 393, 273)
$Checkbox1 = GUICtrlCreateCheckbox($Chip, 240, 88,193, 17)
GUICtrlSetColor(-1,0xBD1AE6)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox2 = GUICtrlCreateCheckbox($Audio, 240, 144)
GUICtrlSetColor(-1,0xBD1AE6)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox3 = GUICtrlCreateCheckbox($lan, 240, 208,193, 17)
GUICtrlSetColor(-1,0xBD1AE6)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox4 = GUICtrlCreateCheckbox($Video, 240, 272,193, 17)
GUICtrlSetColor(-1,0xBD1AE6)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
If $Chip = "" Then
GUICtrlSetState($Checkbox1,$GUI_HIDE)
Else
GUICtrlSetState($Checkbox1,$GUI_CHECKED)
EndIf
If $Audio = "" Then
GUICtrlSetState($Checkbox2,$GUI_HIDE)
Else
GUICtrlSetState($Checkbox2,$GUI_CHECKED)
EndIf
If $lan = "" Then
GUICtrlSetState($Checkbox3,$GUI_HIDE)
Else
GUICtrlSetState($Checkbox3,$GUI_CHECKED)
EndIf
If $Video = "" Then
GUICtrlSetState($Checkbox4,$GUI_HIDE)
Else
GUICtrlSetState($Checkbox4,$GUI_CHECKED)
EndIf
_WinAPI_SetThemeAppProperties($Theme)
$Button1 = GUICtrlCreateButton($exit, 455, 408, 89, 25)
GUICtrlSetColor(-1,0xBD1AE6)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Button2 = GUICtrlCreateButton($az, 312, 408, 89, 25)
GUICtrlSetColor(-1,0xBD1AE6)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Exit
Case $Button2
$Progress1 = _ProgressCreate(223, 370, 393, 25)
_ProgressSetImages($Progress1, @ScriptDir & "\prgimgs\up.jpg", @ScriptDir & "\prgimgs\back.jpg")
_ProgressSetFont($Progress1, "", -1, -1, 0x0000FF)
If GUICtrlRead($Checkbox1) = 1 Then
insall1()
EndIf
If GUICtrlRead($Checkbox2) = 1 Then
insall2()
EndIf
If GUICtrlRead($Checkbox3) = 1 Then
insall3()
EndIf
If GUICtrlRead($Checkbox4) = 1 Then
insall4()
EndIf
EndSwitch
WEnd
Func insall1()
$bar = GUICtrlCreateLabel($state & $Chip ,223, 340)
GUICtrlSetColor(-1,0xF8F82A)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
_ProgressSet($Progress1, 1)
Sleep(3000)
_ProgressSet($Progress1, 2)
Sleep(2000)
_ProgressSet($Progress1, 3)
Sleep(3000)
_ProgressSet($Progress1, 4)
Sleep(2000)
_ProgressSet($Progress1, 5)
Sleep(3000)
_ProgressSet($Progress1, 6)
_ProgressSet($Progress1, 7)
Sleep(2000)
_ProgressSet($Progress1, 8)
Sleep(3000)
_ProgressSet($Progress1, 9)
EndFunc ;==>bat1
Func insall2()
$bar = GUICtrlCreateLabel($state & $Audio ,223, 340)
GUICtrlSetColor(-1,0xF8F82A)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Sleep(2000)
_ProgressSet($Progress1, 35)
EndFunc
Func insall3()
$bar = GUICtrlCreateLabel($state & $lan ,223, 340)
GUICtrlSetColor(-1,0xF8F82A)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Sleep(2000)
_ProgressSet($Progress1, 45)
EndFunc
Func insall4()
$bar = GUICtrlCreateLabel($state & $lan ,223, 340)
GUICtrlSetColor(-1,0xF8F82A)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Sleep(2000)
_ProgressSet($Progress1, 55)
EndFunc
虚线问题已经没有了 pusofalse 5行代码解决。
目前还是有点小问题 ,在GUICtrlCreateLabel 下使用了 这个 GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) 为什么就会出现图中的情况?
就是想做一个驱动自动安装 自动判断系统语言 显示相应的字符。 高手莫笑啊。
第二个问题
关于 IniWrite#include <Array.au3>
Local $regreturn,$aRecord
reg()
_ArrayDisplay($regreturn)
Func reg()
Dim $key="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI",$regreturn
For $i = 1 to 30
$var = RegEnumKey($key, $i)
if @error <> 0 Then ExitLoop
For $n=1 To 20
$subvarname=$key&"\"&$var
$subvar=RegEnumKey($subvarname,$n)
If @error <> 0 Then ExitLoop
$aaa=RegRead($subvarname&"\"&$subvar&"\","class")
$hdid=RegRead($subvarname&"\"&$subvar&"\","HardwareID")
$bb=StringSplit($hdid,@CRLF)
If UBound($bb)>5 Then
$cc=StringSplit($bb,"&")
$regre=$cc&"&"&$cc
Else
$cc=StringSplit($bb,"&")
$regre=$cc&"&"&$cc;&"&"&$cc
EndIf
_ArrayAdd($regreturn,$regre)
Next
next
Return $regreturn
EndFunc
这个是本论坛搜索的,我想使用它来获取硬件ID,把ID 写指定的INI 文件,然后 对比程序中的INI ,如果有相同的就显示安装对应的驱动(这个目前可以做到了)。
现在的问题是 如何 写入对应的INI。比如:获取了10个 PCI设备如何写入其中指定的一个ID到INI文件的CHIP段,
我写了下面的 代码 但是只能写入第一个。#include <Array.au3>
Dim $key="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI"
Dim $hdid
Dim $subvarname
For $i = 1 to 2
For $n=1 To 2
$var = RegEnumKey($key, $i)
$subvarname=$key&"\"&$var
$subvar=RegEnumKey($subvarname,$n)
$hdid=RegRead($subvarname&"\"&$subvar&"\","HardwareID")
IniWrite("c:\ID.ini","CHIP","ID",$var)
;MsgBox(0,"info","ID:" & $var)
Next
Next
Exit
大神帮帮忙上面个问题解决了 我的处女作就算完成了{:face (197):}
附件是对应的INI ,为什么 INI ==号后面 需要加引号不加就认不到 用 GUICtrlSetBkColor 函数给Checkbox设置相应的背景色 {:face (197):} 帮助里有 控件透明的 #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <winapiex.au3>
#Region ### START Koda GUI section ### Form=
$image = @Scriptdir&"\test.jpg"
$Theme = _WinAPI_GetThemeAppProperties()
$Form1 = GUICreate("Install", 626, 444,Default,Default,$WS_CAPTION)
$Pic1 = GUICtrlCreatePic($image, 0, 0, 625, 441,$WS_CLIPSIBLINGS)
GUICtrlSetState(-1,$GUI_DISABLE)
_WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT)
$Group1 = GUICtrlCreateGroup("", 224, 64, 393, 273)
$Checkbox1 = GUICtrlCreateCheckbox("Soft 1", 240, 88)
GUICtrlSetColor(-1,0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox2 = GUICtrlCreateCheckbox("Soft 2", 240, 144)
GUICtrlSetColor(-1,0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox3 = GUICtrlCreateCheckbox("Soft 3", 240, 208)
GUICtrlSetColor(-1,0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox4 = GUICtrlCreateCheckbox("Soft 4", 240, 272)
GUICtrlSetColor(-1,0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
_WinAPI_SetThemeAppProperties($Theme)
$Button1 = GUICtrlCreateButton("&Exit", 496, 384, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Exit
EndSwitch
WEnd 设置背景色为透明
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) 额,不错,跟着一起学习下。。。 用 GUICtrlSetBkColor 函数给Checkbox设置透明色 似乎看到你在其他论坛提问过,解决了吧 本帖最后由 laomeng 于 2013-5-9 15:35 编辑
回复 8# haijie1223
由于事情急 ,所以又在这边提问了
早之前在自由天空有问过那边的解决方案 也能实现, 但是代码烦琐 。。
所以采用3mile方案 回复 1# laomeng
在脚本开头,增加如下代码(代码来源,P版),应该能解决虚线问题。解决后,请共享你作品的源码。
Global Const $hAu3ThreadDll = DllOpen("Kernel32.dll");来自Thread.au3
$pDrawFocusRect = _RTGetProcAddress("User32.dll", "DrawFocusRect")
_RTVirtualProtect($pDrawFocusRect, 8)
DllStructSetData(DllStructCreate("ubyte Code", $pDrawFocusRect), "Code", Binary("0x33C0C20800CCCCCC"))
Func _RTVirtualProtect($pBaseAddress, $iSize, $iNewProtect = 0x40)
Local $iResult
$iResult = DllCall($hAu3ThreadDll, "bool", "VirtualProtect", "ptr", $pBaseAddress,"dword", $iSize, "dword", $iNewProtect, "dword*", 0)
Return SetError(_RTLastError(), $iResult, $iResult)
EndFunc ;==>_RTVirtualProtect
Func _RTGetProcAddress($vModule, $sProcedure)
Local $iResult
If IsString($vModule) Then
$vModule = _RTGetModuleHandle($vModule)
EndIf
$iResult = DllCall($hAu3ThreadDll, "ptr", "GetProcAddress", "ptr", $vModule, "str", $sProcedure)
Return SetError(_RTLastError(), $vModule, $iResult)
EndFunc ;==>_RTGetProcAddress
Func _RTLastError()
Local $iResult = DllCall($hAu3ThreadDll, "long", "GetLastError")
Return $iResult
EndFunc ;==>_RTLastError
Func _RTGetModuleHandle($sModule = "")
Local $iResult
If $sModule Then
$iResult = DllCall($hAu3ThreadDll, "ptr", "GetModuleHandle", "str", $sModule)
Else
$iResult = DllCall($hAu3ThreadDll, "ptr", "GetModuleHandle", "ptr", 0)
EndIf
Return SetError(_RTLastError(), 0, $iResult)
EndFunc ;==>_RTGetModuleHandle 回复 10# 楼上风云
不明白这段代码,能解释一下吗? 回复楼上风云
不明白这段代码,能解释一下吗?
haijie1223 发表于 2013-5-9 20:23 http://www.autoitx.com/images/common/back.gif
P版以前解释过 http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&ptid=24439&pid=298880&fromuid=7644923
巧合的是 3mile 也在该贴解答过… 回复 10# 楼上风云
好的
谢谢,明天去试试。 学习一下。。。。。。。。。。。。。 回复 12# afan
A大厉害,{:face (427):},正解。我顺便将相关函数打包到了一块,这样可以模块化引用。
页:
[1]
2