找回密码
 加入
搜索
查看: 11930|回复: 29

[GUI管理] 难度效果:如何让窗口内容变得象壁纸那样?

 火.. [复制链接]
发表于 2011-1-8 16:50:39 | 显示全部楼层 |阅读模式
本帖最后由 tisiem 于 2011-1-11 00:13 编辑

我想写一个小的便利功能,实现类似备忘的功能。于是我创建了一个窗口来互动。

现在我想实现这样的功能:当我输入完备忘事件之类了之后,我就希望这个窗口象桌面壁纸图片一样的显示在桌面上,此时它只是静静地在那显示着备忘,我的日常操作对它不产生影响,而这个窗口也不对我的操作产生任何影响,就象它是一个桌面壁纸图片一样,我可以在它上面点右键弹出桌面快捷菜单,也可以将桌面图标拖放在它的上面,一切就当它不存在,除了显示着那些窗口里的内容(这些内容可能是动态的,比如,倒计时还是会走动显示,所以不能真做成图片变成桌面。),直到我用热键唤醒这个窗口。

我在linux下见到地这样的功能,那人家是显示CPU啊,内存啊之类的系统信息,除了可以看到这些信息外,它不影响其它的任何操作。

如何来实现这样的功能呢?


2011/1/11日,补充一下我想要的效果图,这是用图像处理做出来的:

本帖子中包含更多资源

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

×
发表于 2011-1-8 17:07:16 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 625, 445)
DllCall("user32.dll", "uint", "SetWindowLong", "hWnd", $Form1, "int", "-20", "uint", BitOR(DllCall("user32.dll", "uint", "GetWindowLong", "hWnd", $Form1, "int", "-20"), 0x80000, 0x20))
DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hWnd", $Form1, "int", 0, "int", 255, "int", 0x2)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
 
除了图标不能放在上面,其他均符合要求,代码来自78391493 的http://www.autoitx.com/forum.php ... hlight=%B4%A9%CD%B8

评分

参与人数 1金钱 +50 收起 理由
kodin + 50 感谢分享。

查看全部评分

 楼主| 发表于 2011-1-8 17:33:25 | 显示全部楼层
本帖最后由 tisiem 于 2011-1-8 17:56 编辑

谢谢楼上,真是神速啊,呵呵。给的代码也很好,只是没能实现图标放上面。看看有没高手继续发威!
发表于 2011-1-8 17:51:08 | 显示全部楼层
2楼的代码不错,收藏了
 楼主| 发表于 2011-1-8 18:06:40 | 显示全部楼层
楼上相当于帮我顶贴了,呵,谢谢啊。2楼的代码确实是高。如果2楼能给个讲解那就太美好了。
发表于 2011-1-8 19:21:24 | 显示全部楼层
2楼的代码确实是高。如果2楼能给个讲解那就太美好了
发表于 2011-1-8 20:08:57 | 显示全部楼层
放在图标下面你见过没有?
发表于 2011-1-8 20:21:04 | 显示全部楼层
强大,可以加图标,测试完毕!谢谢分享。
发表于 2011-1-8 20:47:36 | 显示全部楼层
代码和测试程序在这,有需要的下载,用的是动态图标。

本帖子中包含更多资源

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

×
 楼主| 发表于 2011-1-9 23:32:24 | 显示全部楼层
本帖最后由 tisiem 于 2011-1-9 23:41 编辑

回复 7# tryhi


   就是在linux下见过那种效果,还有在windows下也有见过,就比如那些播放软件使用“桌面播放”功能,有的就是那样的效果:象壁纸一样,图标和窗口都会在其上面。
 楼主| 发表于 2011-1-9 23:32:52 | 显示全部楼层
本帖最后由 tisiem 于 2011-1-9 23:36 编辑

回复 9# kodin


    谢谢。
效果很好。不过因为我不懂原理,还不知道变通。
如果我是要在桌面上显示,桌面图标在其下面,但是我打开的应用程序窗口不会受到影响(还是我主贴中说的那样:就好象桌面背景似的),这样应该如何改?
发表于 2011-1-10 10:12:47 | 显示全部楼层
回复 9# kodin
貌似不能将图标放在上面,你这个是自己弄的,楼主是想将桌面图标放到上面,在XP上我真的没见过
发表于 2011-1-10 10:16:12 | 显示全部楼层
回复 11# tisiem
#NoTrayIcon

#AutoIt3Wrapper_Res_LegalCopyright=Any

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Timers.au3>
#include <Date.au3>

Global $timer, $Secs, $Mins, $Hour
Dim $IniPath
Dim $G3name, $G3F5, $G3F6, $G3F7, $G3RF5, $G3RF6, $G3RF7, $GameVisibel
Dim $TransType, $Trans, $Side, $letop

$IniPath = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 3) & "ini"
$G3name = IniRead($IniPath, "Game", "GameName", "休闲游戏")
$G3F5 = IniRead($IniPath, "Game", "GameName1", "扫雷")
$G3F6 = IniRead($IniPath, "Game", "GameName2", "纸牌")
$G3F7 = IniRead($IniPath, "Game", "GameName3", "空当接龙")
$G3RF5 = IniRead($IniPath, "Game", "GamePath1", "C:\Windows\system32\winmine.exe")
$G3RF6 = IniRead($IniPath, "Game", "GamePath2", "C:\Windows\system32\sol.exe")
$G3RF7 = IniRead($IniPath, "Game", "GamePath3", "C:\Windows\system32\freecell.exe")
$GameVisibel = IniRead($IniPath, "Game", "GameVisibel", "1")
$TransType = IniRead($IniPath, "Other", "TransType", "1")
$Side = IniRead($IniPath, "Other", "Side", "Right")

If $Side = "Right" Then
        $letop = @DesktopWidth - 167
Else
        $letop = 0
EndIf

$Form1 = GUICreate("Anycrane", 167, @DesktopHeight, $letop, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xFFFBF0)
If $TransType = 1 Then
        $Trans = 255
        _API_SetLayeredWindowAttributes($Form1, 0xFFFBF0)
Else
        $Trans = IniRead($IniPath, "Other", "Trans", "150")
        _API_SetLayeredWindowAttributes($Form1, 0xFFFFFF)
EndIf

$Group1 = GUICtrlCreateGroup("时间", 0, 0, 165, 121, $BS_CENTER, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor($Group1, $GUI_BKCOLOR_TRANSPARENT)
$Label1 = GUICtrlCreateLabel("系统日期:", 8, 23, 64, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel("系统时间:", 8, 55, 64, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label3 = GUICtrlCreateLabel("已用时间:", 8, 87, 64, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label4 = GUICtrlCreateLabel(@YEAR & "-" & @MON & "-" & @MDAY, 72, 23, 80, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label5 = GUICtrlCreateLabel(StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 73, 55, 80, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label6 = GUICtrlCreateLabel("00 分 00 秒", 72, 87, 80, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xff0000)
GUICtrlSetFont(-1, 9, 600)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("系统资源", 0, 128, 165, 137, $BS_CENTER, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label7 = GUICtrlCreateLabel("CPU使用率:", 8, 160, 74, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label8 = GUICtrlCreateLabel("内存使用率:", 8, 208, 76, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Progress1 = GUICtrlCreateProgress(8, 184, 145, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Progress2 = GUICtrlCreateProgress(8, 232, 145, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label9 = GUICtrlCreateLabel("", 112, 160, 36, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label10 = GUICtrlCreateLabel("", 112, 208, 42, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
If $GameVisibel = 1 Then
        $Group3 = GUICtrlCreateGroup($G3name, 0, 272, 165, 100, $BS_CENTER, $WS_EX_TRANSPARENT)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Label11 = GUICtrlCreateLabel("F5:" & $G3F5, 16, 298, 76, 17)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Label12 = GUICtrlCreateLabel("F6:" & $G3F6, 16, 323, 76, 17)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Label13 = GUICtrlCreateLabel("F7:" & $G3F7, 16, 347, 76, 17)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
EndIf
GUISetState()
WinSetOnTop("Anycrane", "", 1)
$timer = TimerInit()
AdlibRegister("CpuRamRate", 500)
_Timer_SetTimer($Form1, 100, "_UpdateClock")

HotKeySet("{Esc}", "quit")
HotKeySet("{F5}", "game1")
HotKeySet("{F6}", "game2")
HotKeySet("{F7}", "game3")


While 1
        Sleep(100)
WEnd

Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = $Trans, $isColorRef = False)

        Local Const $AC_SRC_ALPHA = 1
        Local Const $ULW_ALPHA = 2
        Local Const $LWA_ALPHA = 0x2
        Local Const $LWA_COLORKEY = 0x1
        If Not $isColorRef Then
                $i_transcolor = Hex(String($i_transcolor), 6)
                $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
        EndIf
        Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
        Select
                Case @error
                        Return SetError(@error, 0, 0)
                Case $Ret[0] = 0
                        Return SetError(4, 0, 0)
                Case Else
                        Return 1
        EndSelect
EndFunc   ;==>_API_SetLayeredWindowAttributes

Func _UpdateClock($hwnd, $Msg, $iIDTimer, $dwTime)
        _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs)
        GUICtrlSetData($Label5, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC))
        GUICtrlSetData($Label6, StringFormat("%02i 分 %02i 秒", $Mins, $Secs))
        GUICtrlSetData($Label4, @YEAR & "-" & @MON & "-" & @MDAY)
EndFunc   ;==>_UpdateClock


Func CpuRamRate()

        Local $rCPU, $rRAM
        $rCPU = CurrentCPURate()
        $rRAM = CurrentRAMRate()
        GUICtrlSetData($Progress1, $rCPU)
        GUICtrlSetData($Label9, $rCPU & "%")
        GUICtrlSetData($Progress2, $rRAM)
        GUICtrlSetData($Label10, $rRAM & "%")
EndFunc   ;==>CpuRamRate


Func CurrentCPURate()
        $wbemServices = ObjGet("winmgmts:\\.\root\cimv2")
        $wbemObjectSet = $wbemServices.ExecQuery("Select * from Win32_Processor")
        For $wbemObject In $wbemObjectSet
                $dd = $wbemObject.LoadPercentage
        Next
        Return $dd
EndFunc   ;==>CurrentCPURate

Func CurrentRAMRate()
        Local $Array[7]
        $Array = MemGetStats()
        Return $Array[0]
EndFunc   ;==>CurrentRAMRate

Func game1()
        Run($G3RF5)
EndFunc   ;==>game1

Func game2()
        Run($G3RF6)
EndFunc   ;==>game2

Func game3()
        Run($G3RF7)
EndFunc   ;==>game3

Func quit()
        Exit 0
EndFunc   ;==>quit
发表于 2011-1-10 11:55:01 | 显示全部楼层
楼上的这个不过是透明而已,如果不透明,上面的这个甚至连鼠标也没有穿透.
发表于 2011-1-10 21:06:50 | 显示全部楼层
大概意思我理解了,果然高难度动作,正好蛋疼,琢磨搞搞看...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-23 16:50 , Processed in 0.094662 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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