微剋多資訊

 找回密碼
 註冊

Login

Login

搜索

該用戶從未簽到

發表於 2013-2-28 13:16 | 顯示全部樓層 |閱讀模式
本帖最後由 rictirse 於 2014-12-24 08:38 編輯

很多朋友應該都用過 MemTest 這軟體來測試記憶體的穩定度,維修電腦或是超頻的好工具
但他有一個 很大的缺點,單一個檔案只能吃2GB的記憶體,所以16G的話需要開超多的個MemTest
這邊噹噹撰寫了一個檔案克服了這個問題,原始檔案在這邊:
點我進入




這一支程式主要分為三個部份,因為au不支援原生的多線
所以噹噹把程式分為三個exe檔

GUI介面的「RunMemTest Pro v1.7.au3」
  負責控制下面兩個exe,執行與開啟memtest
執行Memtest所使用的「RunMemTest.au3」

  負責啟動Memtest的視窗,以及排序以及統計數量
啟動Memtest所使用的「StartMemTest.au3」

  負責按下燒機那個按鈕

主程式原始碼

RunMemTest Pro v1.7.au3
  1. #include <GUIConstantsEx.au3>
  2. #include <WinAPI.au3>
  3. #include <ScreenCapture.au3>

  4. AutoItSetOption ( "TrayIconHide", 1)
  5. #include <Timers.au3>

  6. Opt ("GUIResizeMode", $GUI_DOCKALL)
  7. $FileName = @ScriptDir&"\memTestPro.exe"
  8. $Process = "memTestPro.exe"

  9. Global $X0 = 115
  10. Global $Y0 = 15
  11. Global $H  = 20
  12. Global $W  = 92

  13. Global $InputX = 23
  14. Global $InputY = 43
  15. Global $InputH  = 20

  16. Global $BTN_X = 20
  17. Global $BTN_Y = 70
  18. Global $InputY = 43

  19. Global  $GUI_W = 400, $GUI_H = 202
  20. Global  $GUI_W_ReSize = 615, $GUI_H_ReSize = 202

  21. Global $DISTANCE = 8
  22. Global $reg = "HKCU\Software\Dang\MenTest"
  23. Global $handle[1]
  24. Global $CompensateHandle
  25. Global $TitleName = "Run MemTest Pro Ver 1.7 CRS OC Team"
  26. RegWrite ( $reg, "TitleName", "REG_SZ", $TitleName)
  27. Global $Flag = 0,$flag2 = 0, $Updata = 1
  28. Global $slp= 0,$slp2 = 0
  29. Global $Solution_Set = 0, $RunMemtest_Set = 0, $StartMemTest_Set = 1, $CloseMemtest_Set = 0

  30. $GUI = GUICreate ( $TitleName, $GUI_W, $GUI_H)

  31. GUICtrlCreateLabel ( "(記憶體大小 X 開啟個數) = 總使用量 ; 剩餘記憶體 保留記憶體", $InputX-4, $Y0+2, 367,25)
  32.   GUICtrlSetColor ( -1, 0x1260FF)
  33.   GUICtrlSetFont ( -1, 9, 700)

  34. $Y0 = $Y0 + $H  + $DISTANCE;計算出第二個 Y座標
  35. $size = GUICtrlCreateInput ( RegRead ( $reg, "MemSize"), $InputX, $InputY, 64,$H)
  36.   GUICtrlSetColor ( -1, 0xEE7600)
  37.   GUICtrlSetFont ( -1, 10, 700)
  38. $cnt = GUICtrlCreateInput ( RegRead ( $reg, "MemCnt"), $InputX+79, $Y0, 51,$H)
  39.   GUICtrlSetColor ( -1, 0xEE7600)
  40.   GUICtrlSetFont ( -1, 10, 700)
  41. If RegRead ( $reg, "retain") = "" Or RegRead ( $reg, "retain") = 0 Then
  42.   $retainVer = 0
  43. Else
  44.   $retainVer = RegRead ( $reg, "retain")
  45. EndIf
  46. $retain = GUICtrlCreateInput ( $retainVer, $InputX+289,$Y0, 65,$H)
  47.   GUICtrlSetColor ( -1, 0xEE7600)
  48.   GUICtrlSetFont ( -1, 10, 700)

  49. $total = GUICtrlCreateLabel ( "", $InputX+148, $Y0+1, 118,$H)
  50.   GUICtrlSetFont ( -1, 10, 700)
  51.   GUICtrlSetColor ( -1, 0xEE7600)
  52. If GUICtrlRead ($cnt) = "" Or GUICtrlRead ($size) = "" Then
  53.   _Solution()
  54. Else
  55.   $mem = MemGetStats()
  56.   $TotalVer = ((GUICtrlRead ($size)*GUICtrlRead ($cnt)))
  57.   $FreeVer =(($mem[2]/2^10)-$TotalVer)
  58.   GUICtrlSetData ( $total, StringFormat ( "%dMB ; %dMB", $TotalVer, $FreeVer))
  59. EndIf

  60. $Auto = GUICtrlCreateButton ( "自動計算", $BTN_X, $BTN_Y,$W,$H+32)
  61. $run = GUICtrlCreateButton ( "啟動MemTest", $BTN_X+100, $BTN_Y,$W,$H+5)
  62. $Start = GUICtrlCreateButton ( "開始燒機", $BTN_X+100, $BTN_Y+28,$W,$H+5)
  63. $close = GUICtrlCreateButton ( "關閉MemTest", $BTN_X+200, $BTN_Y,$W,$H+5)
  64. $Stop = GUICtrlCreateButton ( "暫停MemTest", $BTN_X+200, $BTN_Y+28,$W,$H+5)
  65. $Help = GUICtrlCreateButton ( "使用說明", $BTN_X+200, $BTN_Y+28,$W,$H+5)

  66. $menu = GUICtrlCreateButton ( "→", $BTN_X+320, $BTN_Y+14, 30,$H+5)

  67. $Win_Pos = GUICtrlCreateButton ( "紀錄位置", 400, 15,$W,$H+5);紀錄位置

  68. GUICtrlSetState ( $Win_Pos, $GUI_DISABLE)
  69. GUICtrlSetState ( $Start, $GUI_DISABLE)
  70. ;~ GUICtrlSetState ( $Stop, $GUI_DISABLE)
  71. GUICtrlSetState ( $Stop, $GUI_HIDE)

  72. $Y0 = $Y0 + $H  + $DISTANCE;計算出第二個 Y座標

  73. $Group_X = 405
  74. $Group_Y = 40

  75. GUICtrlCreateGroup ( "排列方法", $Group_X, $Group_Y+5, 85, 110)
  76.   $Radio1 = GUICtrlCreateRadio ( "一般排列", $Group_X+10, $Group_Y+20,$W-25,$H+5)
  77.   $Radio2 = GUICtrlCreateRadio ( "緊密排列", $Group_X+10, $Group_Y+40,$W-25,$H+5)
  78.   $Radio3 = GUICtrlCreateRadio ( "堆疊排列", $Group_X+10, $Group_Y+60,$W-25,$H+5)
  79.   $Radio4 = GUICtrlCreateRadio ( "自定義", $Group_X+10, $Group_Y+80,$W-25,$H+5)

  80.   $Radio = RegRead ( $reg, "Radio")
  81.   If $Radio = 2 Then
  82.     GUICtrlSetState ( $Radio2, $GUI_CHECKED)
  83.   ElseIf $Radio = 3 Then
  84.     GUICtrlSetState ( $Radio3, $GUI_CHECKED)
  85.   ElseIf $Radio = 4 Then
  86.     GUICtrlSetState ( $Radio4, $GUI_CHECKED)
  87.   Else;第一個
  88.     GUICtrlSetState ( $Radio1, $GUI_CHECKED)
  89.   EndIf

  90. GUICtrlCreateGroup ( "補償延遲(秒)", 505, 17, 85, 50)
  91.   $slptime = GUICtrlCreateInput ( "", 515, 37, 64,$H)
  92.   GUICtrlSetColor ( -1, 0xEE7600)
  93.   GUICtrlSetFont ( -1, 10, 700)
  94.   If RegRead ( $reg, "slptime") = "" Then
  95.     GUICtrlSetData ( $slptime, 0);預設為0 關閉
  96.   Else
  97.     GUICtrlSetData ( $slptime, RegRead ( $reg, "slptime"))
  98.   EndIf

  99. ;-------------自動截圖-------------
  100. $prt_check = GUICtrlCreateCheckbox ("啟動截圖", 508, 75, 80, 20)
  101.   If RegRead ( $reg, "ptr_check") = 1 Then
  102.     GUICtrlSetState ( $prt_check, $GUI_CHECKED)
  103.   EndIf
  104. $prt_time = GUICtrlCreateInput ( "", 505, 100, 30, $H)
  105.   If RegRead ( $reg, "prt_time") = "" Then
  106.     GUICtrlSetData ( $prt_time, "5");預設為5分鐘
  107.   Else
  108.     GUICtrlSetData ( $prt_time, RegRead ( $reg, "prt_time"))
  109.   EndIf
  110. GUICtrlCreateLabel ( "分鐘/張", 542, 104, 80, 25)
  111. $prt_rut = GUICtrlCreateButton ( "存檔路徑", 503, 127, 80, 25)

  112. GUICtrlSetState ( $prt_time, $GUI_DISABLE)
  113. GUICtrlSetState ( $prt_rut, $GUI_DISABLE)
  114. ptr_check_set()
  115. ;-------------end 自動截圖-------------

  116. If GUICtrlRead ($cnt) = "" Or GUICtrlRead ($size) = "" Then
  117.   $RamVer = ""
  118. Else
  119.   $mem = MemGetStats()
  120.   $RamVer = StringFormat ( "總記憶體為:%d MB;可用記憶體為:%d MB", _
  121.             ($mem[1]/(2^10)),($mem[2]/(2^10)))
  122. EndIf
  123. $RAMSIZE = GUICtrlCreateLabel ( $RamVer, 20, $BTN_Y+70, 371, 60)
  124.   GUICtrlSetColor ( -1, 0x1260FF)
  125.   GUICtrlSetFont ( -1, 10, 700)

  126. WinMove ($TitleName,"",Default,Default,$GUI_W,$GUI_H)
  127. ;~ WinMove ($TitleName,"",Default,Default,$GUI_W_ReSize,$GUI_H_ReSize)
  128. WinSetOnTop ($GUI, "", 1)
  129. GUISetState()

  130. While 1
  131.   _Save( $size, "MemSize")
  132.   _Save( $cnt, "MemCnt")
  133.   _Save( $retain, "retain")
  134.   _Save( $slptime, "slptime")
  135.   _Save( $prt_time, "prt_time")

  136.   If $Solution_Set = 0 Then
  137.     HotKeySet ("{F5}","_Solution");自動計算
  138.   Else
  139.     HotKeySet ("{F5}","_nothing")
  140.   EndIf
  141.   If $RunMemtest_Set = 0 Then
  142.     HotKeySet ("{F6}","_RunMemtest");開啟Memtest
  143.   Else
  144.     HotKeySet ("{F6}","_nothing")
  145.   EndIf
  146.   If $StartMemTest_Set = 0 Then
  147.     HotKeySet ("{F7}","_StartMemTest");燒機開始
  148.   ElseIf $StartMemTest_Set = 2 Then
  149.     HotKeySet ("{F7}","_StopMemTest");暫停MemTest
  150.   Else
  151.     HotKeySet ("{F7}","_nothing")
  152.   EndIf
  153.   HotKeySet ("{F8}","_CloseMemtest");關閉MemTest

  154.   $msg = GUIGetMsg()
  155.   If $msg = $Radio1 And BitAND(GUICtrlRead ($Radio1), $GUI_CHECKED) = $GUI_CHECKED Then
  156.     RegWrite( $reg, "Radio", "REG_SZ", 1)
  157.   EndIf
  158.   If $msg = $Radio2 And BitAND(GUICtrlRead ($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then
  159.     RegWrite( $reg, "Radio", "REG_SZ", 2)
  160.   EndIf
  161.   If $msg = $Radio3 And BitAND(GUICtrlRead ($Radio3), $GUI_CHECKED) = $GUI_CHECKED Then
  162.     RegWrite( $reg, "Radio", "REG_SZ", 3)
  163.   EndIf
  164.   If $msg = $Radio4 And BitAND(GUICtrlRead ($Radio4), $GUI_CHECKED) = $GUI_CHECKED Then
  165.     If RegRead ( $reg,"MemTestPos_array") = "" Or RegRead ( $reg,"MemTestPos_array") = 0 Then
  166.       GUICtrlSetState ( $Radio1, $GUI_CHECKED)
  167.       RegWrite ( $reg, "Radio", "REG_SZ", 1)
  168.       WinSetOnTop ( $GUI, "", 0)
  169.       MsgBox ( 16, $TitleName, "尚未有自定義座標")
  170.       WinSetOnTop ( $GUI, "", 1)
  171.     Else
  172.       RegWrite ( $reg, "Radio", "REG_SZ", 4)
  173.     EndIf
  174.   EndIf
  175.   If $msg = $prt_check Then
  176.     ptr_check_set()
  177.   EndIf

  178.   $mem = MemGetStats()
  179.   $RamVer = StringFormat ( "總記憶體為:%d MB;可用記憶體為:%d MB", _
  180.           ($mem[1]/(2^10)),($mem[2]/(2^10)))
  181.   If GUICtrlRead ($RAMSIZE) <> $RamVer Then
  182.     GUICtrlSetData ( $RAMSIZE, $RamVer)
  183.   EndIf

  184.   If $Flag = 1 Then
  185.     If $Updata = 1 Then
  186.       $Updata = 0
  187.       _GetyMemTestListPid()
  188.     EndIf
  189.     Dim $_cnt = GUICtrlRead ($cnt)

  190.     For $i = 0 To $_cnt
  191.      If StringLen (ControlGetText ($handle[$i],"","Edit2")) > 17 Then
  192. ;~        ToolTip("")
  193.       _prt_sc()
  194.       _CloseMemtest()
  195.       ExitLoop
  196.      EndIf
  197.     Next
  198. ;~     $Str = StringFormat (@CRLF&" 截圖:%f秒 "&@CRLF&" 補償:%f秒 "&@CRLF&" 剩餘記憶體:%dMB"&@CRLF&" ",($slp2/1000/3),($slp/1000/3),($mem[2]/(2^10)))
  199. ;~     ToolTip ($Str)
  200.      If BitAND (GUICtrlRead ($prt_check), $GUI_CHECKED) = $GUI_CHECKED Then
  201.       $slp2 += 50
  202.       If $slp2 > (GUICtrlRead($prt_time)*1000*3*60) Then;自動截圖
  203. ;~         ToolTip("")
  204.           _prt_sc()
  205.         $slp2 = 0
  206.         If GUICtrlRead($slptime) <> 0 Then
  207.           Sleep (50)
  208.         Else
  209.           Sleep (25)
  210.         EndIf
  211.       EndIf
  212.     EndIf
  213.     If GUICtrlRead ($slptime) <> 0 Then
  214.       $slp += 50
  215.       If $slp > (GUICtrlRead ($slptime)*1000*3) Then;壓榨記憶體模式
  216.         If GUICtrlRead ($retain) < Int ($mem[2]/(2^10)) Then
  217.           $slp = 0
  218.           $i = GUICtrlRead ($cnt)
  219.           If $flag2 = 0 Then
  220.             $Memory =Int($mem[2]/(2^10))
  221.             $flag2 = 1
  222.             $CompensateHandle = WinGetHandle ("[0 errors] MemTest", "保留記憶體使用")
  223.           Else
  224.             $Memory = Int($Memory+($mem[2]/(2^10)))
  225.             ControlClick ( $CompensateHandle, "", "Button2");按暫停
  226.           EndIf
  227. ;~           winclose ($CompensateHandle)
  228.           ControlSetText ($CompensateHandle, "", "Edit1", $Memory)
  229.           ControlClick ( $CompensateHandle, "", "Button1")
  230.           If BitAND ( GUICtrlRead ($prt_check), $GUI_CHECKED) = $GUI_CHECKED Then
  231.             Sleep (50)
  232.           Else
  233.             Sleep (25)
  234.           EndIf
  235.         EndIf
  236.       EndIf
  237.     EndIf
  238.   EndIf
  239.   Switch $msg
  240.     Case $GUI_EVENT_CLOSE
  241.       Exit
  242.     Case $Auto
  243.       _Solution()
  244.     Case $run
  245.       _RunMemtest()
  246.     Case $Start
  247.       _StartMemTest()
  248.     Case $close
  249.       _CloseMemtest()
  250.     Case $Stop
  251.       _StopMemTest()
  252.     Case $Help
  253.       GUISetState (@SW_HIDE)
  254.       MsgBox ( 0, $TitleName&" 使用教學", _
  255.               "1. 自動計算公式為 ( 執行緒數量 / 總記憶體 )"&@CRLF& _
  256.               " 大於2047MB則多開一個,直到小餘2047MB。"&@CRLF&@CRLF& _
  257.               "2. 快速鍵:"&@CRLF& _
  258.               "  F5 → 自動計算"&@CRLF& _
  259.               "  F6 → 開啟MemTest"&@CRLF& _
  260.               "  F7 → 燒機"&@CRLF& _
  261.               "  F8 → 關閉全部MemTest "&@CRLF& _
  262.               "  請愛用快速鍵,反應速度比較快。"&@CRLF&@CRLF& _
  263.               "3. 燒機後 (剩餘記憶體) 大於 (保留記憶體) 會啟動 (自動補償),"&@CRLF& _
  264.               " (自動補償) 會把剩餘記憶體全部放在保留記憶體的Mem內,"&@CRLF& _
  265.               " 設定時間 0 則不啟動,預設補償時間0秒,不啟動。"&@CRLF&@CRLF& _
  266.               "4. 截圖預設路徑為桌面。"&@CRLF&@CRLF& _
  267.               "")
  268.       GUISetState (@SW_SHOW)
  269.     Case $Menu
  270.       _Menu()
  271.     Case $prt_rut
  272.       _prt_rut()
  273.     Case $Win_Pos
  274.       _Win_Pos()
  275.   EndSwitch
  276. WEnd

  277. Func _Solution()
  278.   $mem = MemGetStats()
  279.   $MemCnt = _LogicalCore()
  280.   Do
  281.     $MemSize = Int ($mem[2]/(2^10)/$MemCnt)
  282.     If $MemSize > 2047 Then
  283.       $MemCnt += 1
  284.     EndIf
  285.   Until ($MemSize <= 2047)
  286.   GUICtrlSetData ($size,$MemSize)
  287.   GUICtrlSetData ($cnt,$MemCnt)
  288. EndFunc

  289. Func _RunMemtest()
  290.   _CloseMemtest()
  291.   GUICtrlSetState ( $size, $GUI_DISABLE)
  292.   GUICtrlSetState ( $cnt, $GUI_DISABLE)
  293.   GUICtrlSetState ( $Auto, $GUI_DISABLE)
  294.   If $retain <> 0 Then;如果開啟記憶體補償
  295.     GUICtrlSetState ( $slptime, $GUI_DISABLE)
  296.   EndIf
  297.   $Solution_Set = 1
  298.   $RunMemtest_Set = 1
  299.   $StartMemTest_Set = 1

  300.   If GUICtrlRead ($cnt)  = "" Or GUICtrlRead ($size) = "" Or GUICtrlRead ($cnt)  = 0 Or GUICtrlRead ($size) = 0 Or Int (GUICtrlRead ($size)/GUICtrlRead ($cnt)) < 0 Then Return
  301.   If @error = 1 Then Return
  302.   Dim $_cnt = GUICtrlRead ($cnt)
  303.   ReDim $handle[$_cnt+1]
  304.   If BitAND(GUICtrlRead ($Radio4), $GUI_CHECKED) = $GUI_CHECKED Then;如果勾選自定義
  305.     If $_cnt > RegRead ( $reg, "MemTestPos_array") Then;如果自訂的arr 小於 開啟量則
  306.       WinSetOnTop ( $GUI, "", 0)
  307.       $nMsg = MsgBox ( 36, $TitleName, "Memtest 數量大於自定義的座標量,是否繼續執行?"&@CRLF&@CRLF&"超過的座標皆為0,0")
  308.       WinSetOnTop ( $GUI, "", 1)
  309.       If $nMsg = 7 Then Return
  310.     EndIf
  311.   EndIf

  312.   Run ("RunMemTest.exe");啟動Memtest

  313.   GUICtrlSetState ( $Win_Pos, $GUI_ENABLE)
  314.   GUICtrlSetState ( $Start, $GUI_ENABLE)
  315.   $StartMemTest_Set = 0
  316. EndFunc

  317. Func _Save( $Input, $RegName)
  318.   If GUICtrlRead ($Input) <> RegRead ( $reg, $RegName) Then
  319.     RegWrite( $reg, $RegName, "REG_SZ", GUICtrlRead($Input))
  320.     If GUICtrlRead ($size) > 2048 Then
  321.       GUICtrlSetData ( $size, 2048)
  322.       WinSetOnTop ($GUI,"",0)
  323.       MsgBox (16,"ERROR","不得大於2048", 1)
  324.       WinSetOnTop ($GUI,"",1)
  325.     EndIf
  326.     If GUICtrlRead ($Input) <> "" Then
  327.       $mem = MemGetStats()
  328.       $TotalVer = ((GUICtrlRead ($size)*GUICtrlRead ($cnt)))
  329.       $FreeVer =(($mem[2]/2^10)-$TotalVer)
  330.       $Var = StringFormat ( "%dMB ; %dMB", $TotalVer, $FreeVer)
  331.       GUICtrlSetData ( $Total, $Var)
  332.     EndIf
  333.   EndIf
  334. EndFunc

  335. Func _Win_Pos()
  336.   Dim $_cnt = GUICtrlRead ($cnt)
  337.   If GUICtrlRead ($slptime) <> 0 Then;確定開啟的數量 如果不開啟補償 少開一個
  338.     $_cnt += 1
  339.   EndIf
  340.   _GetyMemTestListPid()
  341.   For $i = 0 To ($_cnt-1)
  342.     $Pos = WinGetPos ($handle[$i])
  343.     RegWrite ( $reg, "MemTestPos_array", "REG_SZ", $_cnt)
  344.     RegWrite ( $reg, "MemTestPos["&$i&"]_X", "REG_SZ", $Pos[0])
  345.     RegWrite ( $reg, "MemTestPos["&$i&"]_Y", "REG_SZ", $Pos[1])
  346.   Next
  347.   GUISetState (@SW_HIDE)
  348.   MsgBox  ( 0, $TitleName, "紀錄完成,共"&$_cnt&"組", 1)
  349.   GUISetState (@SW_SHOW)
  350. EndFunc

  351. Func _StartMemTest()
  352.   $Solution_Set = 1
  353.   $RunMemtest_Set = 1
  354.   $StartMemTest_Set = 1
  355.   If ProcessExists ($Process) = 0 Then Return
  356.   GUICtrlSetState ( $Auto, $GUI_DISABLE)
  357.   GUICtrlSetState ( $run, $GUI_DISABLE)
  358.   GUICtrlSetState ( $Win_Pos, $GUI_DISABLE)
  359.   GUICtrlSetState ( $Start, $GUI_DISABLE)
  360.   GUICtrlSetState ( $Stop, $GUI_ENABLE)
  361.   Run ("StartMemTest.exe")
  362.   $Flag = 1
  363.   $StartMemTest_Set = 2
  364. EndFunc

  365. Func _StopMemTest()
  366.   $slp= 0
  367.   $slp2 = 0
  368.   If ProcessExists ($Process) = 0 Then Return
  369.   $StartMemTest_Set = 1
  370.   $Updata = 1
  371. ;~   Run ("StopMemTest.exe")
  372.   $Flag = 0
  373.   GUICtrlSetState ( $Start, $GUI_ENABLE)
  374.   $Solution_Set = 1
  375.   $RunMemtest_Set = 1
  376.   $StartMemTest_Set = 0
  377. EndFunc

  378. Func _CloseMemtest()
  379.   ToolTip (@CRLF&" 結束MemTest "&@CRLF&" ")
  380.   $slp= 0
  381.   $slp2 = 0
  382.   GUICtrlSetState ( $Win_Pos, $GUI_DISABLE)
  383.   GUICtrlSetState ( $Start, $GUI_DISABLE)
  384.   Do
  385.     ProcessClose ("RunMemTest.exe")
  386.   Until ProcessExists ("RunMemTest.exe") = 0
  387.   Do
  388.     ProcessClose ("StartMemTest.exe")
  389.   Until ProcessExists ("StartMemTest.exe") = 0
  390. ;~   Do
  391. ;~     ProcessClose ("StopMemTest.exe")
  392. ;~   Until ProcessExists ("StopMemTest.exe") = 0
  393.   Do
  394.     ProcessClose ($Process)
  395.   Until ProcessExists ($Process) = 0
  396.   If $retain <> 0 Then;如果開啟記憶體補償
  397.     GUICtrlSetState ( $slptime, $GUI_ENABLE)
  398.   EndIf

  399.   $Flag = 0
  400.   $flag2 = 0
  401.   $Updata = 0
  402.   $Solution_Set = 0
  403.   $RunMemtest_Set = 0
  404.   $StartMemTest_Set = 1

  405.   GUICtrlSetState ( $Auto, $GUI_ENABLE)
  406.   GUICtrlSetState ( $run, $GUI_ENABLE)
  407.   GUICtrlSetState ( $Stop, $GUI_DISABLE)
  408.   GUICtrlSetState ( $size, $GUI_ENABLE)
  409.   GUICtrlSetState ( $cnt, $GUI_ENABLE)
  410.   ToolTip ("")
  411. EndFunc

  412. Func _Menu()
  413.   If GUICtrlRead ($Menu) = "←" Then
  414.     GUICtrlSetData ( $Menu, "→")
  415.     WinMove ($TitleName,"",Default,Default,$GUI_W,$GUI_H)
  416.   Else
  417.     GUICtrlSetData ( $Menu, "←")
  418.     WinMove ($TitleName,"",Default,Default,$GUI_W_ReSize,$GUI_H_ReSize)
  419.   EndIf
  420. EndFunc

  421. Func _prt_rut()
  422.   WinSetOnTop ($GUI, "", 0)
  423.   $rut = FileSelectFolder ( "請選擇存檔目錄", @DesktopDir, 3)
  424.   RegWrite( $reg, "prt_rut", "REG_SZ", $rut)
  425.   WinSetOnTop ($GUI, "", 1)
  426. EndFunc

  427. Func ptr_check_set()
  428.   If BitAND(GUICtrlRead ($prt_check), $GUI_CHECKED) = $GUI_CHECKED Then
  429.     GUICtrlSetState ( $prt_time, $GUI_ENABLE)
  430.     GUICtrlSetState ( $prt_rut, $GUI_ENABLE)
  431.     RegWrite( $reg, "ptr_check", "REG_SZ", 1)
  432.   Else
  433.     GUICtrlSetState ( $prt_time, $GUI_DISABLE)
  434.     GUICtrlSetState ( $prt_rut, $GUI_DISABLE)
  435.     RegWrite( $reg, "ptr_check", "REG_SZ", 0)
  436.   EndIf
  437. EndFunc

  438. Func _WinWaitClick ( $Title, $TextName, $controlID)
  439.   If Not WinActivate ( $Title, $TextName) Then
  440.     WinActivate ( $Title, $TextName)
  441.     WinWaitActive ( $Title, $TextName)
  442.   EndIf
  443.   ControlClick  ( $Title, $TextName, $controlID)
  444. EndFunc

  445. Func _CPU_Utilization()
  446.   $wbemServices = ObjGet("winmgmts:\\.\root\cimv2")
  447.   $wbemObjectSet= $wbemServices.ExecQuery("Select * from Win32_Processor")
  448.   For $wbemObject In $wbemObjectSet
  449.     $dd=$wbemObject.LoadPercentage
  450.   Next
  451.   Return $dd
  452. EndFunc

  453. Func _LogicalCore()
  454.   $aSysInfo = _WinAPI_GetSystemInfo()
  455.   $PROCESS_ALL_ACCESS = 0x1F0FFF
  456.   $hProc = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, False, @AutoItPID)
  457.   $aRet = _WinAPI_GetProcessAffinityMask($hProc)
  458.   Return (Log($aRet[2] + 1) / Log(2))
  459. EndFunc

  460. Func _WinAPI_GetSystemInfo($iInformation=-1)
  461.     If $iInformation<>-1 And ($iInformation<1 Or $iInformation>10) Then Return SetError(1,0,-1)
  462.     Local $aRet,$stSystemInfo=DllStructCreate("ushort;short;dword;ptr;ptr;dword;dword;dword;dword;short;short")

  463.     $aRet=DllCall("kernel32.dll","none","GetSystemInfo","ptr",DllStructGetPtr($stSystemInfo))

  464.     If @error Or Not IsArray($aRet) Then Return SetError(2,0,-1)

  465.     If $iInformation<>-1 Then
  466.         If $iInformation==1 Then Return DllStructGetData($stSystemInfo,1)
  467.         Return DllStructGetData($stSystemInfo,$iInformation+1)
  468.     EndIf
  469.     Local $aSysInfo[10]
  470.     $aSysInfo[0]=DllStructGetData($stSystemInfo,1)
  471.     For $i=1 To 9
  472.         $aSysInfo[$i]=DllStructGetData($stSystemInfo,$i+2)
  473.     Next
  474.     Return $aSysInfo
  475. EndFunc

  476. Func _prt_sc()
  477.   If RegRead ( $reg, "prt_rut") = "" Then
  478.     $rut = @DesktopDir
  479.   Else
  480.     $rut = RegRead ( $reg, "prt_rut")
  481.   EndIf
  482.   If Not FileExists ($rut) Then
  483.     $rut = @DesktopDir
  484.   EndIf
  485.   GUISetState(@SW_HIDE)
  486.   Sleep (1000)
  487.   _ScreenCapture_Capture($rut&"\"&@YEAR&"_"&@MON&"_"&@MDAY&"_"&@HOUR&"_"&@MIN&"_"&@SEC&".png")
  488.   GUISetState(@SW_SHOW)
  489. EndFunc


  490. Func _GetyMemTestListPid()
  491.   $var = WinList()
  492.   Local $_cnt = GUICtrlRead ($cnt)

  493.   If GUICtrlRead ($slptime) <> 0 Then;確定開啟的數量 如果不開啟補償 少開一個
  494.     $_cnt += 1
  495.   EndIf
  496.   Local $j = 0

  497.   ReDim $handle[$_cnt]

  498.   For $i = 1 To $var[0][0]
  499.     If StringCompare ( $var[$i][0], "[0 errors] MemTest  ", 1) =  0 Or StringCompare ( $var[$i][0], "[0 errors] MemTest", 1) =  0 Then
  500.       $find = True
  501.     Else
  502.       $find = False
  503.     EndIf

  504.     If $find = True Then
  505.       $handle[$j] =$var[$i][1]
  506.       $j += 1
  507.       $find = False
  508.     EndIf
  509.   Next
  510. EndFunc

  511. Func _nothing()

  512. EndFunc
複製代碼

本帖子中包含更多資源

您需要 登入 才可以下載或查看,沒有帳號?註冊

x

該用戶從未簽到

 樓主| 發表於 2013-2-28 13:18 | 顯示全部樓層
本帖最後由 rictirse 於 2014-12-24 08:38 編輯

這邊是執行MemTest所使用的原始碼
RunMemTest.au3
  1. AutoItSetOption ( "TrayIconHide", 1)
  2. Global $reg = "HKCU\Software\Dang\MenTest"
  3. Global $TitleName = RegRead ( $reg, "TitleName")

  4. $FileName = @ScriptDir&"\memTestPro.exe"
  5. $Process = "memTestPro.exe"

  6. Global $MemCnt = RegRead ( $reg, "MemCnt")
  7. Global $MemSize = RegRead ( $reg, "MemSize")
  8. Global $slptime = RegRead ( $reg, "slptime")
  9. If $slptime = 0 Then;確定開啟的數量 如果不開啟補償 少開一個
  10.   $MemCnt -= 1
  11. EndIf
  12. Global $handle[1]

  13. For $i = 0 To $MemCnt
  14.   If Run ($FileName) = 0 Then
  15.     WinSetOnTop ( $TitleName, "", 0)
  16.     MsgBox ( 16, $TitleName,"找不到 "&$FileName)
  17.     WinSetOnTop ( $TitleName, "", 1)
  18.     Exit
  19.   EndIf
  20. Next

  21. _GetyMemTestListPid()
  22. $Radio = RegRead ( $reg, "Radio")

  23. For $i = 0 To $MemCnt
  24.   $pos = WinGetPos ($handle[$i])
  25.   If  $Radio = 2 Then
  26.       If $i = 0 Then
  27.         Dim $X = 0,$Y = 0
  28.         WinMove ($handle[$i],"", $X, $Y)
  29.         $X = $X+$pos[2]-110
  30.       Else
  31.         WinMove ($handle[$i],"", $X, $Y)
  32.         $X = $X+$pos[2]-110
  33.         If @DesktopWidth < $X+$pos[2]+10 Then
  34.           $X = 0
  35.           $Y = $Y+$pos[3]-148
  36.         EndIf
  37.       EndIf
  38.   ElseIf $Radio = 3 Then
  39.       If $i = 0 Then
  40.         Dim $X = 0,$Y = 0,$Z = 0
  41.         WinMove ($handle[$i],"", $X, $Y)
  42.         $X = $X+$pos[2]-110
  43.         $Y = $Y+$pos[3]-148
  44.       Else
  45.         WinMove ($handle[$i],"", $X, $Y)
  46.         If $Z = 1 Then
  47.           $X = $X-$pos[2]+110
  48.           $Y = $Y+$pos[3]-148
  49.         ElseIf $Z = 2 Then
  50.           $X = $X+$pos[2]-110
  51.           $Y = $Y-$pos[3]+148
  52.         ElseIf $Z = 3 Then
  53.           $X = $X-$pos[2]+110
  54.           $Y = $Y-$pos[3]+148
  55.         Else
  56.           $X = $X+$pos[2]-110
  57.           $Y = $Y+$pos[3]-148
  58.         EndIf
  59.         If $Y > (@DesktopHeight-$pos[3]) Then
  60.           If $Z = 0 Then
  61.             $X = @DesktopWidth-$pos[2]
  62.             $Y = 0
  63.             $Z = 1
  64.           Else
  65.             $X = 0
  66.             $Y = @DesktopHeight-$pos[3]-40
  67.             $Z = 2
  68.           EndIf
  69.         ElseIf $Y < 0 Then
  70.           $X = @DesktopWidth-$pos[2]
  71.           $Y = @DesktopHeight-$pos[3]-40
  72.           $Z = 3
  73.         EndIf
  74.       EndIf
  75.   ElseIf $Radio = 4 Then
  76.       If $i < RegRead ( $reg, "MemTestPos_array") Then
  77.         $Pos_X = RegRead ( $reg, "MemTestPos["&$i&"]_X")
  78.         $Pos_Y = RegRead ( $reg, "MemTestPos["&$i&"]_Y")
  79.         WinMove ($handle[$i],"", $Pos_X, $Pos_Y)
  80.       Else
  81.         WinMove ($handle[$i],"", 0, 0)
  82.       EndIf
  83.   Else;一般
  84.       If $i = 0 Then
  85.         Dim $X = 10,$Y = 10
  86.         WinMove ($handle[$i],"", $X, $Y)
  87.         $X = $X+$pos[2]+8
  88.       Else
  89.         WinMove ($handle[$i],"", $X, $Y)
  90.         $X = $X+$pos[2]+8
  91.         If @DesktopWidth < $X+$pos[2] Then
  92.           $X = 10
  93.           $Y = $Y+$pos[3]
  94.         EndIf
  95.       EndIf
  96.   EndIf
  97. Next

  98. Func _GetyMemTestListPid()
  99.   $var = WinList()
  100.   Local $j = 0
  101.   Do
  102.     $cnt = 0
  103.     $var = WinList()
  104.     For $i = 1 To $var[0][0]
  105.     If StringCompare ( $var[$i][0], "[0 errors] MemTest  ", 1) =  0 Then
  106.         $cnt += 1
  107.         sleep (50)
  108.       EndIf
  109.     Next
  110. ;~     ToolTip ($cnt)
  111.   Until $cnt > $MemCnt

  112.   ReDim $handle[$cnt]

  113.   For $i = 1 To $var[0][0]
  114.     If StringCompare ( $var[$i][0], "[0 errors] MemTest  ",1) =  0 Then
  115.       $find = True
  116.     Else
  117.       $find = False
  118.     EndIf

  119.     If $find = True Then
  120.       $handle[$j] =$var[$i][1]
  121.       $j += 1
  122.     EndIf
  123.   Next

  124.   For $i = 0 To $j-1
  125.     If $slptime <> 0 And  $i = ($j - 1)Then;確定開啟的數量 如果不開啟補償 少開一個
  126.       WinSetTitle ( $handle[$i], "", "[0 errors] MemTest")
  127.       ControlSetText  ( $handle[$i], "", "Button5", "保留記憶體使用")
  128.     Else
  129.       ControlSetText  ( $handle[$i], "", "Button5", $i)
  130.     EndIf
  131.     ControlMove ( $handle[$i], "", "Button5", 9999, 9999)
  132.     ControlSetText  ( $handle[$i], "", "Edit1", $MemSize)
  133.   Next
  134. EndFunc
複製代碼
回覆

使用道具 舉報

該用戶從未簽到

 樓主| 發表於 2013-2-28 13:24 | 顯示全部樓層
本帖最後由 rictirse 於 2014-12-24 08:38 編輯

這邊是執行MemTest 所用的原始碼
StartMemTest.au3
  1. #include <Array.au3>
  2. AutoItSetOption ( "TrayIconHide", 1)

  3. Global $reg = "HKCU\Software\Dang\MenTest"
  4. Global $MemCnt =RegRead ( $reg, "MemCnt")
  5. Global $slptime = RegRead ( $reg, "slptime")
  6. Global $handle[1], $BTNText[1]

  7. _GetyMemTestListPid()

  8. Func _GetyMemTestListPid()
  9.   $var = WinList()
  10.   Local $j = 0
  11.   Local $Pos

  12.   Do
  13.     $cnt = 0
  14.     $var = WinList()
  15.     For $i = 1 To $var[0][0]
  16.     If StringCompare ( $var[$i][0], "[0 errors] MemTest  ",1) =  0 Then
  17.         $cnt += 1
  18.         sleep (50)
  19.       EndIf
  20.     Next
  21. ;~     ToolTip ($cnt)
  22.   Until $cnt >= $MemCnt
  23.   ReDim $handle[$cnt]
  24.   ReDim $BTNText[$cnt]

  25.   For $i = 1 To $var[0][0]
  26.     If StringCompare ( $var[$i][0], "[0 errors] MemTest  ",1) =  0 Then
  27.       $find = True
  28.     Else
  29.       $find = False
  30.     EndIf

  31.     If $find = True Then
  32.       $handle[$j] =$var[$i][1];hwnd
  33.       $BTNText[$j]=ControlGetText ( $handle[$j], "", "Button5");get num
  34.       $j += 1
  35.     EndIf
  36.   Next
  37. ;~   MsgBox (0,"", "")
  38.   For $i=0 to UBound($BTNText)-2
  39.     $Pos = FindMinIndex ($BTNText, $i)
  40.     Swap($BTNText[$i], $BTNText[$pos])
  41.     Swap($handle[$i], $handle[$pos])
  42.   Next

  43. ;~   Display ($BTNText)

  44.   For $i = 0 To ($j-1)
  45. ;~     WinKill ($handle[$i])
  46.     ControlClick ( $handle[$i], "", "Button1")
  47.   Next

  48. ;~   If $slptime = 0 Then;確定開啟的數量 如果不開啟補償 少開一個
  49. ;~     For $i = 0 To ($j-1)
  50. ;~       ControlClick ( $handle[$i], "", "Button1")
  51. ;~     Next
  52. ;~   Else
  53. ;~     For $i = 0 To ($j-1)
  54. ;~       If $i <> ($j-1)Then
  55. ;~         ControlClick ( $handle[$i], "", "Button1")
  56. ;~       EndIf
  57. ;~     Next
  58. ;~   EndIf

  59. EndFunc

  60. Func Swap( ByRef $a, ByRef $b)
  61.   Local $Tmp = $a
  62.   $a = $b
  63.   $b = $Tmp
  64. EndFunc

  65. Func FindMaxIndex(const $arr, const $Start_Pos)
  66.   Local $Pos = $Start_Pos
  67.   For $i=$Pos+1 to UBound($arr)-1
  68.     If($arr[$i] > $arr[$Pos]) Then
  69.       $Pos=$i
  70.     EndIf
  71.   Next
  72.   return $Pos
  73. EndFunc

  74. Func FindMinIndex(const $arr, const $Start_Pos)
  75.   Local $Pos = $Start_Pos
  76.   For $i=$Pos+1 to UBound($arr)-1
  77.     If($arr[$i] < $arr[$Pos]) Then
  78.       $Pos=$i
  79.     EndIf
  80.   Next
  81.   return $Pos
  82. EndFunc

  83. Func Display(const $data)
  84.   Local $Msg=""
  85.   For $i=0 to UBound($data)-1
  86.     $Msg = $Msg & StringFormat("data[%d] = %d\n", $i, $data[$i])
  87.   Next
  88.   MsgBox(0, "Display data[10]", $Msg)
  89. EndFunc
複製代碼
  • 非常實用!!!!!

    xx910203 貢獻度 +10

回覆

使用道具 舉報

該用戶從未簽到

發表於 2013-2-28 14:58 | 顯示全部樓層
偶不會程式,看沒有,
只能佩服讚歎了~~
期待執行的檔案哦!!
回覆

使用道具 舉報

該用戶從未簽到

發表於 2013-6-10 16:19 | 顯示全部樓層
不錯不錯!

抱回去慢慢啃源碼

這種好東西在大陸那邊的autoitx可不常見
回覆

使用道具 舉報

該用戶從未簽到

發表於 2013-10-20 05:42 | 顯示全部樓層
雖然原始碼還看不太懂!

但還是支持!

回覆

使用道具 舉報

該用戶從未簽到

發表於 2013-10-20 06:19 | 顯示全部樓層
最近電腦一直藍屏,馬上來用用看是不是記憶體故障
回覆

使用道具 舉報

您需要登入後才可以回帖 登入 | 註冊

本版積分規則

小黑屋|Archiver|微剋多資訊(MicroDuo)

GMT+8, 2016-12-8 17:44

Discuz! X

© 2009-2016 Microduo

快速回覆 返回頂部 返回列表