Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

HDD Activity Monitoring LED


  • Please log in to reply
51 replies to this topic
Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
This script monitors the (first) hard disk drive activity and shows it using ScrollLock LED.

PS. Don't forget to run "diskperf.exe -y" once to enable the HDD monitoring.

DOWNLOAD HDDMonitor.ahk.

Skippy
  • Members
  • 10 posts
  • Last active: Dec 03 2009 09:44 PM
  • Joined: 12 Dec 2006
Nicely done.

I'm for anything that makes blinky lights.

Thanks

IVG
  • Members
  • 20 posts
  • Last active: Mar 02 2009 12:58 AM
  • Joined: 21 Mar 2007
Real nice 8)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
it doesn't work here.. mayb microsoft natural keyboard...
Posted Image

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

it doesn't work here.. mayb microsoft natural keyboard...

Yes, someone once told me that the keyboard indicator function didn't work with MS natural keyboard. I found it rather ironic, the one which broke their provided functionality was thier own product... but I'm afraid it's not unusual with MS.

My original version was using GUI, a small box sitting at the top left corner and changing the background color accordingly. Apparently, however, it seemed not possible to change in real time the background color of AHK's GUI, unless using controls. Instead of digging into it, as I'm usually impatient with GUI stuffs, I chose to use the keyboard indicators. Maybe later, unless someone else does the GUI thing before.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006

Apparently, however, it seemed not possible to change in real time the background color of AHK's GUI, unless using controls.

You can always text the text color of statics.
Posted Image

Timothy
  • Guests
  • Last active:
  • Joined: --
My laptop doesn't have a scroll lock LED. How do you change it so it uses the caps lock or num lock LED instead?

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

My laptop doesn't have a scroll lock LED. How do you change it so it uses the caps lock or num lock LED instead?

Oh, I forgot to say about it. There are two '1 << 16' in the script. Just replace 1 with 2 or 4 (or, equivalently, 16 to 17 or 18 leaving 1 as it is).

ScrollLock: 1,  NumLock: 2,  CapsLock: 4
You may also combine them like 2+4 etc.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
And, I forgot another one to mention. Currently, it sets the indicators constantly every 500ms, no matter what the situations are. For example, even when HDD remains with no activity a while, the script tries to constantly set the indicators, although there appear no change at all to the user. So, if worried about it, may introduce a flag like bScroll to tell the previous state and so decide to set new status or not.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear Sean, :)

Your script is Nice & Useful.

My original version was using GUI, a small box sitting at the top left corner and changing the background color accordingly. Apparently, however, it seemed not possible to change in real time the background color of AHK's GUI, unless using controls. Instead of digging into it, as I'm usually impatient with GUI stuffs, I chose to use the keyboard indicators. Maybe later, unless someone else does the GUI thing before.


Here is my attempt, just a starter, < 45 lines.

; Posted at http://www.autohotkey.com/forum/viewtopic.php?p=113890#113890

#SingleInstance, Force
Process, Priority,, High
OnExit, Quit 
oRC := 0, oWC := 0

; Run, diskperf.exe -y   ; Execute it once to enable Disk Performance monitoring. 

SetTimer, HDD_Monitor, ;500

hDrv := DllCall( "CreateFile", Str,"\\.\PhysicalDrive0", Uint,0 ,Uint,3, Uint,0, Uint,3
                , Uint,0, Uint,0 )

Gui, -Caption +Border +AlwaysOnTop +ToolWindow
Gui, Color, EEAA99  
Gui, +LastFound  
WinSet, TransColor, EEAA99  
Gui, Add, Progress,     w60 h9 cGreen -0x1 vRead
Gui, Add, Progress, x+5 w60 h9 cRed   -0x1 vWrite
Gui, Show, x780 y3 , HDD Monitor                 ; Adjust X & Y to suit your screen res
Return

HDD_Monitor:
  VarSetCapacity(dp, 88)
  DllCall( "DeviceIoControl", Uint,hDrv, Uint,0x00070020, Uint,0, Uint,0, Uint, &dp
          , Uint,88, UintP,nReturn, Uint,0 ) 

  nRC := *(&dp+40) | *(&dp+41) << 8 | *(&dp+42) << 16 | *(&dp+43) << 24
  nWC := *(&dp+44) | *(&dp+45) << 8 | *(&dp+46) << 16 | *(&dp+47) << 24

  RC := Round(100-(100*(1/(1+(nRC-oRC)))))  ,  WC := Round(100-(100*(1/(1+(nWC-oWC)))))

  GuiControl,, Read , %RC%
  GuiControl,, Write, %WC%
  oRC := nRC ,  oWC := nWC
Return

Quit:
  DllCall("CloseHandle", "Uint", hDrv) 
  ExitApp 
Return

I find your posts more & more useful. Keep up the good work.

Thanks. :)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006

Here is my attempt, just a starter, < 45 lines.

Ah, you still didn't learn, Skan..... :D

BTW, very nice gui.

BTW2, I see that you are interested in algorythm performance. DOn't number of lines misslead you, it has not 1 single thing to do with the speed, and its usualy contrary, that longer code is quicker then shorter.

If you are interested in theory, you will have to know differential equations pretty much, (in)finite sums and logarithms. The speed of algorythm can be proved mathematicaly. I have my books about this on Serbian only, but if you want to know more I can find you relevant articles and your guru most definitely can provide some help about the topic 8)
Posted Image

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Here is my attempt, just a starter, < 45 lines.

Thanks for this excellent GUI. I knew that you could do it better than me. :)
BTW, you separated the read/write counter. I almost thought that you had a psychic power. ;)

I find your posts more & more useful. Keep up the good work.

Thanks for the good words.

Dippy46
  • Members
  • 171 posts
  • Last active: Aug 17 2007 06:53 AM
  • Joined: 06 Jul 2004
@All

Here's another take based on FloatLed

<!-- m -->http://www.softpedia... ... tLED.shtml<!-- m -->

 _= 2007 04 03 Ver 1.0.46.10
 _= ESC to exit program !
 ; add ini to remember last screen pos 
 #NoEnv
 #Persistent
 #SingleInstance, Force
 SetBatchLines, -1

 Gui,Color,0x0
 Gui -Caption +Owner +AlwaysOnTop 
 Gui,Font,s10 w700, Courier New

 OnMessage(0x219, "NotifyChange")
 ;; include code to re-evaluate when
 ;; hidden drive is activated during
 ;; Pseudo raid !

/*
 Run, diskperf.exe -y   ; Execute it once to enable Disk Performance monitoring.
 Not required for Xp +
 In Windows 2000 this IOCTL is handled by the filter driver diskperf.
 In Windows XP and later operating systems, 
 the partition manager handles this request for disks and 
 ftdisk.sys and dmio.sys handle this request for volumes.
*/

 SetTimer,ScanDrv,50

 _= Enumerate Available Drives (Fixed)

 DriveGet,aDrives,List,FIXED 
   Loop,Parse,aDrives
   {
   DrvCount ++
   Drv%A_Index% := a_Loopfield
   CurDrv:= "\\.\" Drv%A_Index% ":"
   hDrv%A_Index% := DllCall("CreateFile",Str,CurDrv,Uint,0,Uint,3,Uint,0,Uint,3,Uint,0,Uint,0)
   }

 _= Build Quick+Dirty Gui to fit

 x=2
   Loop,% DrvCount
   {
   Gui,Add,Text,x%x% y-5 w09 h12 c0x00FF00 vx%A_Index%,
   Gui,Add,Text,x%x% y6  w09 h12 c0xFFFFFF ,% Drv%A_Index%
   Gui,Add,Text,x%x% y18 w09 h10 c0xFF8800 vy%A_Index%, 
   x+=17
   }

 x-=8
 Gui,Show, x100 y100 w%x% h30 ,win
 ; WinSet, TransColor,0x0 225 ,win 
 Return

 GuiEscape: 
 GuiClose:
 ExitApp

 Return

 ScanDrv:
 SetTimer,ScanDrv,Off
   Loop,% DrvCount
   {
   VarSetCapacity(dp%A_Index%,88)
   DllCall("DeviceIoControl",Uint,hDrv%A_Index%,Uint,0x00070020,Uint,0,Uint,0
                            ,Uint,&dp%A_Index%,Uint,88,UintP,nReturn,Uint,0)

   nReadCount%A_Index%  := DecodeInteger(&dp%A_Index% + 40)
   nWriteCount%A_Index% := DecodeInteger(&dp%A_Index% + 44)

 _= Case Writing @ y%A_Index%
     If (nWriteCount%A_Index% <> _nWriteCount_%A_Index%) 
     {
     _nWriteCount_%A_Index% := nWriteCount%A_Index%
     GuiControl,,y%A_Index%,=
     }
     Else  guicontrol,,y%A_Index%,

 _= Case Reading @ x%A_Index%
     If (nReadCount%A_Index% <> _nReadCount_%A_Index%)
     {
     _nReadCount_%A_Index%  := nReadCount%A_Index%
     GuiControl,,x%A_Index%,=     
     }
     Else  guicontrol,,x%A_Index%, 
   }

 SetTimer,ScanDrv,On
 Return

 DecodeInteger(ptr)
 {
   Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
 }

 ~LButton::DragGui("win") 

 _=========================================================================
 _== FUNCTION :     DragGui(WinTitle)                                    == 
 _== Author   :     Chris Mallett                                        == 
 _== Updated  :     Converted to FUNCTION By Dave Perrée Jun 2006        == 
 _== Usage    :     ~LButton::DragScreen("WinTitle")                     == 
 _=========================================================================

 DragGui(_WinTitlePart) 
 { 
 STATIC _GuiID,_MouseStartX,_MouseStartY 
 WinGet,_GuiID, ID,% _WinTitlePart 
 CoordMode,Mouse 
 MouseGetPos,_MouseStartX,_MouseStartY,_MouseWin 
    If _MouseWin <> %_GuiID% 
    Return 
 SetTimer,_WatchMouse,5 
 Return 
 _WatchMouse: 
 GetKeyState,_LButtonState,LButton,P 
    If _LButtonState=U 
    { 
    SetTimer,_WatchMouse,Off 
    Return 
    } 
 CoordMode,Mouse 
 MouseGetPos,_MouseX,_MouseY 
 _DeltaX:=_MouseX 
 _DeltaX-=%_MouseStartX% 
 _DeltaY:=_MouseY 
 _DeltaY-=%_MouseStartY% 
 _MouseStartX:=_MouseX 
 _MouseStartY:=_MouseY 
 WinGetPos,_GuiX,_GuiY,,,ahk_id%_GuiID% 
 _GuiX+=%_DeltaX% 
 _GuiY+=%_DeltaY% 
 SetWinDelay,-1 
 WinMove,ahk_id %_GuiID%,,%_GuiX%,%_GuiY% 
 RETURN 
 } 

 NotifyChange()
 {
 ; do nothing yet
 Return
 }


Have Fun
Simple ideas lie within reach, only of complex minds

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Here's another take based on FloatLed

Nice. BTW, there seems to be a confusion in the comment. I don't think diskperf.exe has anything to do with diskperf.sys which is indeed missing in XP. diskperf.exe controls the enableness of the corresponding counter. To see this, execute diskperf -n. So, it's still needed in XP.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
@majkinetor

Ah, you still didn't learn, Skan..... :D


IMHO, the beauty of AHK is lies in the fact that one can write really short ( ( I refer to the lines ) & yet powerful scripts. Ofcourse, techies like you and others have pointed out the various limitations of the language. Still, I admire AHK very much mainly for its simple syntax and the powerful GUI capabilities. I am glad that I do not have to be a powerful programmer to use AHK. :D

BTW, very nice gui.


Thanks :)





@Sean

Thanks for this excellent GUI. I knew that you could do it better than me. :)
BTW, you separated the read/write counter. I almost thought that you had a psychic power. ;)


Thanks :)





@Dippy46 : Re. DragGui()

Nice script Sir :). BTW, The drag can be enabled for a captionless GUI with a simple postmessage. Example:

Gui, -Caption +ToolWindow +0x400000 
Gui, Font, S14 Bold, Verdana 
Gui, Add, Text, w200 h27 Border Center GuiMove, Click Here `&& Drag 
Gui, Show, AutoSize 
Return 

uiMove: 
[color=red]PostMessage, 0xA1, 2,,, A [/color]
Return 

GuiEscape: 
Exitapp

Example taken from: How to enable Drag for a GUI without a Titlebar ?