AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HDD Activity Monitoring LED
Goto page 1, 2, 3, 4  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Mar 31, 2007 2:38 am    Post subject: HDD Activity Monitoring LED Reply with quote

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.


Last edited by Sean on Wed Aug 22, 2007 6:09 am; edited 1 time in total
Back to top
View user's profile Send private message
Skippy



Joined: 12 Dec 2006
Posts: 10
Location: Florida

PostPosted: Sat Mar 31, 2007 3:44 am    Post subject: Reply with quote

Nicely done.

I'm for anything that makes blinky lights.

Thanks
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
IVG



Joined: 21 Mar 2007
Posts: 20
Location: Lithuania

PostPosted: Sat Mar 31, 2007 9:06 am    Post subject: Reply with quote

Real nice Cool
Back to top
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Sat Mar 31, 2007 11:26 am    Post subject: Reply with quote

it doesn't work here.. mayb microsoft natural keyboard...
_________________
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Mar 31, 2007 12:08 pm    Post subject: Reply with quote

majkinetor wrote:
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.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Sat Mar 31, 2007 2:01 pm    Post subject: Reply with quote

Quote:
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.
_________________
Back to top
View user's profile Send private message
Timothy
Guest





PostPosted: Sat Mar 31, 2007 7:53 pm    Post subject: Reply with quote

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?
Back to top
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Mar 31, 2007 10:46 pm    Post subject: Reply with quote

Timothy wrote:
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).

Code:
ScrollLock: 1,  NumLock: 2,  CapsLock: 4

You may also combine them like 2+4 etc.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sun Apr 01, 2007 12:29 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Mon Apr 02, 2007 5:29 pm    Post subject: Reply with quote

Dear Sean, Smile

Your script is Nice & Useful.

Sean wrote:
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.

Code:
; 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. Smile
Back to top
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Mon Apr 02, 2007 6:26 pm    Post subject: Reply with quote

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

Ah, you still didn't learn, Skan..... Very Happy

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 Cool
_________________
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Tue Apr 03, 2007 12:05 am    Post subject: Reply with quote

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

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

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

Thanks for the good words.
Back to top
View user's profile Send private message
Dippy46



Joined: 06 Jul 2004
Posts: 171
Location: Manchester, England.

PostPosted: Tue Apr 03, 2007 3:00 pm    Post subject: Reply with quote

@All

Here's another take based on FloatLed

http://www.softpedia.com/get/System/Hard-Disk-Utils/FloatLED.shtml

Code:

 _= 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
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Tue Apr 03, 2007 4:03 pm    Post subject: Reply with quote

Dippy46 wrote:
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.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Tue Apr 03, 2007 5:02 pm    Post subject: Reply with quote

@majkinetor

Quote:
Ah, you still didn't learn, Skan..... Very Happy


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. Very Happy

Quote:
BTW, very nice gui.


Thanks Smile





@Sean

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


Thanks Smile





@Dippy46 : Re. DragGui()

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

Code:
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:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
Exitapp


Example taken from: How to enable Drag for a GUI without a Titlebar ?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group