找回密码
 加入
搜索
查看: 10313|回复: 30

独立的几个部分代码如何同时执行

  [复制链接]
发表于 2008-8-19 23:48:22 | 显示全部楼层 |阅读模式
既能同时显示时间,也能同时监测CPU及内存的使用量,不知是如何做到的?
如下图:
问题在解决中,结帖算了。

[ 本帖最后由 redapple2008 于 2008-8-23 20:42 编辑 ]

本帖子中包含更多资源

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

×
 楼主| 发表于 2008-8-19 23:50:59 | 显示全部楼层
时间函数:
$Group1 = GUICtrlCreateGroup("计时器", 5, 16, 300, 97)
$t=GUICtrlCreateLabel("00:00", 64,50,200,60)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$timer = TimerInit()

Func Timer()
  _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
  Local $sTime = $Time  ; save current time to be able to test and avoid flicker..
  $Time = StringFormat("%02i:%02i", $Mins, $Secs)
  If $sTime <> $Time Then GUICtrlSetData($t, $Time)
EndFunc  ;==>Timer
 楼主| 发表于 2008-8-19 23:52:22 | 显示全部楼层
内存函数:
GUICtrlCreateLabel("使用内存:", 10, 155, 75, 20)
$label11 = GUICtrlCreateLabel("100%", 245, 155, 30)
GUICtrlCreateGraphic(85, 150, 150, 15)
GUICtrlSetColor(-1, 0x000000)
$progress11 = GUICtrlCreateGraphic(86, 155, 0, 13)
GUICtrlSetColor($progress11, 0x000000)
GUICtrlSetBkColor($progress11, 0x0FB1FF)
GUICtrlCreateLabel("空闲内存:", 10, 210, 75, 20)
$label12 = GUICtrlCreateLabel("100%", 245, 210, 30)
GUICtrlCreateGraphic(85, 210, 150, 15)
GUICtrlSetColor(-1, 0x000000)
$progress12 = GUICtrlCreateGraphic(86, 210, 0, 13)
GUICtrlSetColor($progress12, 0x000000)
GUICtrlSetBkColor($progress12, 0x0FB1FF)
_API_SetLayeredWindowAttributes($Form1 , 0xABCDEF)

Func memcontrol()
        $i = 100
        While 1
                $i = $i + 10
                If $i > 100 And $fUpdateMeminfo Then
                        $memstats = MemGetStats()
                        $RamF = Round(100 * ($memstats[1] - $memstats[2]) / $memstats[1], 1)
                        GUICtrlSetPos($progress11, 86, 150, $RamF * 1.49, 13)
                        GUICtrlSetData($label11, $RamF & "%")
                        $RamF = Round(100 * ($memstats[2] / $memstats[1]), 1)
                        If $RamF < 1 Then
                                GUICtrlSetPos($progress12, 86, 210, 1, 13)
                        Else
                                GUICtrlSetPos($progress12, 86, 210, $RamF * 1.49, 13)
                        EndIf
                        GUICtrlSetData($label12, $RamF & "%")
                        $RamF = $memstats[1] - $memstats[2]
                        $i = 0
                        ExitLoop
                EndIf
        WEnd
EndFunc

 楼主| 发表于 2008-8-19 23:56:12 | 显示全部楼层
进度条函数

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("WinTitleMatchMode", 2)
$AForm2 = GUICreate("AForm1", 400,100,40,@DesktopHeight-50,$WS_POPUP, $WS_EX_LAYERED+$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
GUISetBkColor(0xABCDEF)
for $i=0 to 9
$w=15
$pro= GUICtrlCreateLabel("□",40+$w*$i, 20, 135, 10)
GUICtrlSetBkColor($pro, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($pro, 0xffffff)
Next
GUISetState(@SW_SHOW)
AdlibEnable("xh",3300)
Func xh()
$h=15
$i=0
Do
$i = $i + 1
$pro= GUICtrlCreateLabel("■",40+$h*($i-1), 20, 10, 10)
GUICtrlSetColor(-1, 0x00ff00)
Sleep(300)
GUICtrlDelete($pro)
if $i=10 Then ExitLoop
Until $i>=10
EndFunc
_API_SetLayeredWindowAttributes($AForm2, 0xABCDEF)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exitloop
        EndSwitch
WEnd


[ 本帖最后由 redapple2008 于 2008-8-20 00:01 编辑 ]
 楼主| 发表于 2008-8-20 00:02:15 | 显示全部楼层
希望有人能帮助解决这个问题,多线程我试过,不行。谢谢
 楼主| 发表于 2008-8-20 08:41:34 | 显示全部楼层
希望有人能解答,谢谢!
 楼主| 发表于 2008-8-20 13:49:46 | 显示全部楼层
期待回复,在线等。。。。。。。。。。。。
发表于 2008-8-20 14:03:53 | 显示全部楼层
你这是完整的原代码吗?
 楼主| 发表于 2008-8-20 16:09:14 | 显示全部楼层
没有完整代码。我的意思是把这些代码拼起来,正常运行就行了。
 楼主| 发表于 2008-8-20 19:19:11 | 显示全部楼层
看来没人我研究这个问题。
慢慢等了。
发表于 2008-8-20 23:05:29 | 显示全部楼层
定时去刷新一下不就可以了?
 楼主| 发表于 2008-8-20 23:59:37 | 显示全部楼层
主要是进度条哪个延迟时间问题,没有延迟时间的话就不会出错的。
 楼主| 发表于 2008-8-21 18:56:15 | 显示全部楼层

置顶,期待高手出现。
发表于 2008-8-21 20:19:54 | 显示全部楼层
你的进度条函数产生的进度图形根本不是楼顶你那个图的进度条。西拼东凑的吧?

本帖子中包含更多资源

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

×
 楼主| 发表于 2008-8-21 20:27:54 | 显示全部楼层
原帖由 顽固不化 于 2008-8-21 20:19 发表
你的进度条函数产生的进度图形根本不是楼顶你那个图的进度条。西拼东凑的吧?




我只是抓了一部分图
所以没有出现进度条,只是想完成这样的效果。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-25 15:10 , Processed in 0.076130 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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