找回密码
 加入
搜索
查看: 3528|回复: 4

[图形处理] 求能把整个窗体自定义透明度程序。高手帮忙呀

  [复制链接]
发表于 2010-7-3 18:32:34 | 显示全部楼层 |阅读模式
比如一个透明图片的窗体,图片要支持JPG .GIF两 种,我想通过右键来调整窗体的透明度。要怎么做?
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

$mainwindow = GUICreate("窗体透明", 80, 120, 400, 300, BitOR($WS_POPUP,$WS_CLIPSIBLINGS),$WS_EX_LAYERED)
$Label = GUICtrlCreateLabel("标签", 0, 0, 80, 120,$SS_BLACKFRAME,$GUI_WS_EX_PARENTDRAG)  ;通过右键菜单退出-拖拽
FileInstall("tu.gif", @TempDir & "\") ;编译图片
$Pic1 = GUICtrlCreatePic(@TempDir & "\tu.gif", 0, 0, 80, 120)
$contextmenu = GUICtrlCreateContextMenu (3); 创建右键主菜单                 
$infoitem = GUICtrlCreateMenuitem ("退出",$contextmenu) ; 退出
GUISetState(@SW_SHOW)

While 1            
        $nMsg = GUIGetMsg()
        Switch $nMsg
                         Case $GUI_EVENT_CLOSE
                                  exit
                         Case $infoitem  ; 退出
                                  infoitem()                                                   
                EndSwitch
WEnd

Func infoitem()
FileDelete(@TempDir & "\tu.gif") ;删除图片
  Exit
EndFunc
发表于 2010-7-4 01:42:32 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

$mainwindow = GUICreate("窗体透明", 80, 120, 400, 300, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_LAYERED)
$Label = GUICtrlCreateLabel("标签", 0, 0, 80, 120, $SS_BLACKFRAME, $GUI_WS_EX_PARENTDRAG) ;通过右键菜单退出-拖拽
FileInstall("tu.gif", @TempDir & "") ;编译图片
$Pic1 = GUICtrlCreatePic(@TempDir & "\tu.gif", 0, 0, 80, 120)
$contextmenu = GUICtrlCreateContextMenu(3); 创建右键主菜单
$tmd50 = GUICtrlCreateMenuItem("透明度50", $contextmenu) ; 透明度50
$tmd0 = GUICtrlCreateMenuItem("还原", $contextmenu) ; 还原
GUICtrlCreateMenuItem("", $contextmenu)
$infoitem = GUICtrlCreateMenuItem("退出", $contextmenu) ; 退出
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3, $infoitem ; 退出
                        infoitem()
                Case $tmd50
                        WinSetTrans($mainwindow, '', 127)
                Case $tmd0
                        WinSetTrans($mainwindow, '', 255)
        EndSwitch
WEnd

Func infoitem()
        FileDelete(@TempDir & "\tu.gif") ;删除图片
        Exit
EndFunc   ;==>infoitem
发表于 2010-7-4 07:17:33 | 显示全部楼层
学习了......
发表于 2010-7-4 10:37:18 | 显示全部楼层
本帖最后由 xsjtxy 于 2010-7-4 10:38 编辑

;;这年头挂机锁也不稀奇了。拿去参考吧。自己虾编的


#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
IniWrite (@TempDir & "\" & StringReplace(StringReplace(@ScriptFullPath, "\", ""), ":", "") & ".log", "段名", "关键字", "数值")
if FileDelete(@TempDir & "\" & StringReplace(StringReplace(@ScriptFullPath, "\", ""), ":", "") & ".log") = 0 then exit
FileOpen(@TempDir & "\" & StringReplace(StringReplace(@ScriptFullPath, "\", ""), ":", "") & ".log", 2)
FileInstall("zt.dll",@SystemDir & "\zt.dll")
FileInstall("USkins.dll",@SystemDir & "\USkins.dll")
FileInstall("WinLock.dll",@SystemDir & "\WinLock.dll")
FileInstall("Winlock.jpg",@ScriptDir & "\Winlock.jpg")
$skins = @SystemDir & "\zt.dll"
$UIDll = DllOpen(@SystemDir & "\USkins.dll")
DllCall($UIDll, "int", "USkinInit", "str", "Null", "str", "NULL", "str", $skins)
DllCall($UIDll, "int", "USkinLoadSkin", "str", $skins)
$jp = WinGetPos("Program Manager")
$Form22 = GUICreate("", $jp[2], $jp[3], $jp[0], $jp[1],$WS_POPUP,$WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
GUICtrlCreatePic(@ScriptDir & "\Winlock.jpg",0,0, $jp[2],$jp[3])
GUICtrlSetState(-1, $GUI_DISABLE)
$Button001 = GUICtrlCreateButton("", $jp[2] / 2 - 150, $jp[3] / 2 - 100, 300, 200)
GUICtrlSetState(-1, $GUI_DISABLE)
$Slider11 = GUICtrlCreateSlider($jp[2] / 2 - 100,$jp[3] / 2 - 76, 200, 24)
GUICtrlSetTip($Slider11, 75)
GUICtrlSetLimit(-1,100,0)
GUICtrlSetData($Slider11,75)

$Label11 = GUICtrlCreateLabel("输入密码", $jp[2] / 2 - 100, $jp[3] / 2 - 25, 50, 12)
$Input11 = GUICtrlCreateInput("", $jp[2] / 2 - 40, $jp[3] / 2 - 30, 121, 21, $ES_PASSWORD)
GUICtrlSetLimit($Input11, 18)
$Label12 = GUICtrlCreateLabel("重复密码", $jp[2] / 2 - 100, $jp[3] / 2 + 10, 50, 12)
$Input12 = GUICtrlCreateInput("", $jp[2] / 2 - 40, $jp[3] / 2 + 5, 121, 21, $ES_PASSWORD)
GUICtrlSetLimit($Input12, 18)
$Label14 = GUICtrlCreateLabel("", $jp[2] / 2 - 40, $jp[3] / 2 + 30, 120, 12)
GUICtrlSetColor(-1, 0xff0000)
$Label13 = GUICtrlCreateLabel("输入密码", $jp[2] / 2 - 100, $jp[3] / 2, 50, 12)
$Input13 = GUICtrlCreateInput("", $jp[2] / 2 - 40, $jp[3] / 2 -5, 121, 21, $ES_PASSWORD)
GUICtrlSetLimit($Input13, 18)
GUICtrlSetState($Label13,$GUI_HIDE)
GUICtrlSetState($Input13,$GUI_HIDE)
$Button0011 = GUICtrlCreateButton("锁定", $jp[2] / 2 - 100, $jp[3] / 2 + 50, 75, 25)
GUICtrlSetOnEvent(-1, "OKsuodin")
$Button0012 = GUICtrlCreateButton("退出", $jp[2] / 2 + 25, $jp[3] / 2 + 50, 75, 25)
GUICtrlSetOnEvent(-1, "OKexit")
$Button0013 = GUICtrlCreateButton("解锁", $jp[2] / 2 - 40, $jp[3] / 2 + 50, 80, 25)
GUICtrlSetOnEvent(-1, "OKjiesuo")
GUICtrlSetState($Button0013,$GUI_HIDE)
Opt("GUIOnEventMode", 1)
WinSetTrans($Form22, "", 250 / 100 * 75)
dim $mima
dim $bianse1
$bianse1 = 0
dim $WinLock
HotKeySet("^+!q", "OKexit")
GUISetState(@SW_SHOW)

While 1
$toumindu1 = GUICtrlRead($Slider11)
if $toumindu1 < 20 then
$toumindu1 = 20
GUICtrlSetData($Slider11, $toumindu1)
endif
GUICtrlSetTip($Slider11, $toumindu1)
WinSetTrans($Form22, "", 250 / 100 * $toumindu1)
sleep(500)
if ControlGetText($Form22, "", $Label14) <> "" then
$bianse1 = $bianse1 + 1
else
$bianse1 = 0
endif
if $bianse1 = 6 then GUICtrlSetData($Label14, "")
WEnd


Func OKsuodin()
GUICtrlSetData($Label14, "")
$mima11 = ControlGetText($Form22, "", $Input11)
$mima12 = ControlGetText($Form22, "", $Input12)
if $mima11 <> $mima12 <> "" then
GUICtrlSetData($Label14, "两次输入密码不一致!")
else
$mima = $mima12
if $mima = "" then
GUICtrlSetData($Label14, "密码不能为空!")
else
GUICtrlSetState($Label11,$GUI_HIDE)
GUICtrlSetState($Input11,$GUI_HIDE)
GUICtrlSetState($Label11,$GUI_HIDE)
GUICtrlSetState($Input11,$GUI_HIDE)
GUICtrlSetState($Label12,$GUI_HIDE)
GUICtrlSetState($Input12,$GUI_HIDE)
GUICtrlSetState($Button0011,$GUI_HIDE)
GUICtrlSetState($Button0012,$GUI_HIDE)
GUICtrlCreateLabel("此机有人!请勿使用!", $jp[2] / 2 - 295, $jp[3] / 2 - 200, 590, 60)
GUICtrlSetFont(-1, 48, 800, 0, "楷体_GB2312")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$WinLock = DllOpen(@SystemDir & "\WinLock.dll")
        DllCall($WinLock, "int", "StartButton_Show_Hide", "int",0)
        DllCall($WinLock, "int", "Taskbar_Show_Hide", "int", 0)
        DllCall($WinLock, "int", "CtrlAltDel_Enable_Disable", "int", 0)
        DllCall($WinLock, "int", "AltTab1_Enable_Disable", "int", 0)
        DllCall($WinLock, "int", "AltTab2_Enable_Disable", "int", 0, "int", 0)
        DllCall($WinLock, "int", "TaskSwitching_Enable_Disable", "int", 0)
        DllCall($WinLock, "int", "TaskManager_Enable_Disable", "int", 0)
GUICtrlSetState($Label13,$GUI_SHOW)
GUICtrlSetState($Input13,$GUI_SHOW)
GUICtrlSetState($Button0013,$GUI_SHOW)
endif
endif
EndFunc

Func OKjiesuo()
$mima21 = ControlGetText($Form22, "", $Input13)
if $mima21 = "" then
else
if $mima21 <> $mima then
GUICtrlSetData($Label14, "密码错误!")
else
OKexit()
endif
endif
EndFunc

Func OKexit()
DllCall($WinLock, "int", "StartButton_Show_Hide", "int",1)
DllCall($WinLock, "int", "Taskbar_Show_Hide", "int", 1)
DllCall($WinLock, "int", "CtrlAltDel_Enable_Disable", "int", 1)
DllCall($WinLock, "int", "AltTab1_Enable_Disable", "int", 1)
DllCall($WinLock, "int", "AltTab2_Enable_Disable", "int", 0, "int", 1)
DllCall($WinLock, "int", "TaskSwitching_Enable_Disable", "int", 1)
DllCall($WinLock, "int", "TaskManager_Enable_Disable", "int", 1)
DllClose($WinLock)
GUISetState(@SW_HIDE)
DllCall($UIDll, "int", "USkinRemoveSkin")
DllCall($UIDll, "int", "USkinExit")
DllClose($UIDll)
exit
EndFunc
 楼主| 发表于 2010-7-11 20:58:07 | 显示全部楼层
谢谢版主,学习啦,但还有个问题,图片还原后来黑边
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-15 16:33 , Processed in 0.075292 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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