AutoHotkey Community

It is currently May 27th, 2012, 1:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: SysInfo in Task bar v3.0
PostPosted: February 13th, 2006, 11:34 pm 
Offline

Joined: February 13th, 2006, 10:40 pm
Posts: 389
Location: Utah
SysInfo in Task Bar v3.0

Show the Processor Load, Battery Level, Volume Level, and Memory Usage right on your TaskBar!
Major Features:
+ Use of Goyyahs BMPGradient function for cool looking bars!
+ Tooltip that displays cpu usage, battery stats, sound, and ram usage when you hover any part of the module
+ Unfortunately, i have yet to update the Config_sysinfo app, and since it does not work with v3 it is not included.
+ Many thanks to Laszlo for some serious code compression, and some new tricks i've learned thanks to it.
+ Many thanks to PhiLho, Laszlo, and antonyb for their help with the DllCall to GlobalMemoryStatus.

Image

Download SysInfo v3.0

(Download v2.0)

Code:
/*
 *~~~~~Sys Info in Task Bar~~~~~~~
 *           v3.0
 * Made by Michael Peters (aka Veovis)
 * With segments of code from:
 * Rajats volume OSD   http://www.autohotkey.com/forum/viewtopic.php?t=88
 * Laszlos Taskbar Clock/Calendar with Processor and Memory Load bars   http://www.autohotkey.com/forum/viewtopic.php?t=6290
 * PhiLho, Laszlo, and antonyb for helping with the DllCall, byte addresses etc.
 * Thankyou!
 *
 * Major Changes
 *  - Changed the progress bars to BMPGradients (many thanks to Goyyah)
 *  - Added a tooltip with all kinds of info in it
 *TODO Recreate Config app for the Gradients, for now just use the Sysinfo.ini
 *  - Second script to config the placement, colors, update speed, etc.
 *  - Fixed Bug: If you had this program in startup sometimes it would load before the taskbar did, causing the module to be placed relative to the screen.  Reloading script would solve. 
 *  - Right clicking on any of the pictures will bring the GuiContextMenu
 *  - Alot of condensed and smarter code (many thanks to Laszlo)
 *  - Setting in the config to attach the script to a toolbar. (many thanks to jonib)
 */
;-----Read Info from the ini file---------

Loop Read, SysInfo.ini
{
   StringSplit x, A_LoopReadLine, =
   %x1% = %x2%
}

;-----------------CODE STARTS HERE----------------
#singleinstance force
#notrayicon
WinWait, ahk_class Shell_TrayWnd        ;Wiat for the TaskBar to exist incase this script is in startup
if ToolbarName <>                       ;ToolbarName is not blank, so find that toolbar
   hw_tray := FindToolbar(ToolbarName)  ;mod by jonib
else                                    ;otherwise, attach to the task bar (with the start button at 0,0)
   hw_tray := DllCall( "FindWindowEx", "uint",0, "uint",0, "str","Shell_TrayWnd", "uint",0 )
menu sysinfomenu, add, Exit, quitsysinfo
menu sysinfomenu, add, Reload, Reload   ;create the context menu

;---draw pics
PicShow("Proc", 1, "processor")
PicShow("Batt", 2, "battery")
PicShow("Sound",3, "sndvol32")
PicShow("Ram",  4, "ram")

;---draw bars
BarShow("Proc", 11)
BarShow("Batt", 12)
BarShow("Sound",13)
BarShow("Ram",  14)

;---load dll into library
hModule := DllCall("LoadLibrary", "str", "cmdret.dll","UInt")

;---start by updating all bars (so you dont have to wait for the SetTimer durations for the first update)
gosub, procupdate
gosub, battupdate
gosub, soundupdate
gosub, ramupdate
settimer,tooltip,200
return   ;----End of AutoExecute Section---

guicontextmenu:     ;if you right click on any of the pics or bars
2guicontextmenu:    ;show the context menu
3guicontextmenu:
4guicontextmenu:
11guicontextmenu:
12guicontextmenu:
13guicontextmenu:
14guicontextmenu:
   menu sysinfomenu, show
return

Reload:             ;reload from the context menu
Reload

; ----- Update Functions ------
Tooltip:
   ;check for mouse hover
   MouseGetPos,,,Win
   WinGetTitle,win,ahk_id %win%
   If Win = %A_scriptname%
      tooltip, % allstats()
   else
      tooltip
return

ProcUpdate:                ; Laszlo's Processor load code
   IdleTime0 = %IdleTime%  ; Save previous values
   Tick0 = %Tick%
   DllCall("kernel32.dll\GetSystemTimes", "uint",&IdleTicks, "uint",0, "uint",0)
   IdleTime := *(&IdleTicks)
   Loop 7                  ; Ticks when Windows was idle
      IdleTime += *( &IdleTicks + A_Index ) << ( 8 * A_Index )
   Tick := A_TickCount     ; #Ticks all together
   load := 100 - 0.01*(IdleTime - IdleTime0)/(Tick - Tick0)
   load := (load/100) * proc_bar_w
   guicontrol 11:move,bar11, w%load%      ; Update progress bar
return

BattUpdate:
   sysget, shuttingdown, 8192   ;check whether the system is shutting down, as this causes problems
   if shuttingdown = 0          ;only continue if the system is still on
   {
      CMD := "apm"
      VarSetCapacity(StrOut, 1000)
      DllCall("lstrcpyA", "str", StrOut, "int", DllCall("cmdret.dll\RunRedirect", "str", CMD))
      StringGetPos, pos, StrOut,`%
      StringMid, val, StrOut, pos, 3, L
      ifinstring, strOut, charging
         charging = Charging
      else if val < %Batt_Bar_LowLev%   
         charging = Low
      else
         charging = Discharging
      if charging != %oldcharging% ;if charging/low state has changed, find out new state and change bar color and icon
      {
         Changebar("12","batt",charging
                  ,"Charging","battery_charge","color_charge1","color_charge2"
                  ,"Low","battery_low","color_low1","color_low2"
                  ,"Discharging","battery","color_1","color_2")
         oldcharging := charging
      }
      val := (val/100) * batt_bar_w
      guicontrol 12:move,bar12,w%val%
   }
return

SoundUpdate:
   soundget, ismuted,, mute
   if ismuted !=  %oldmute%
   {   
      Changebar("13","sound",ismuted
               ,"on","snd_muted","color_mute1","color_mute2"
               ,"off","sndvol32","color_1","color_2")   
      oldmute = %ismuted%
   }
   soundget, soundlev, master
   soundlev := (soundlev/100) * sound_bar_w
   guicontrol 13:move,bar13,w%soundlev%
return

RamUpdate:                      ;Laszlos memory usage code
   DllCall("kernel32.dll\GlobalMemoryStatus", "uint",&memorystatus)
   mem:=*(&memorystatus+4) ; LS byte is enough, mem = 0..100
   mem := (mem/100) * ram_bar_w
   guicontrol 14:move,bar14, % "w" mem
return

; ------------ Functions ----------------

Dock2TaskBar:              ; Active window to be docked to the taskbar, NEEDS hw_tray value
   Process Exist           ; PID -> ErrorLevel
   WinGet hw_gui, ID, ahk_pid %ErrorLevel%
   DllCall( "SetParent", "uint", hw_gui, "uint", hw_tray )
Return

ref(var) {
   var := %var%
   Return  var
}

PicShow(pic,i,picture) {
   Local p
   p = %pic%_Pic_
   if %p%Show
   {
      Gui %i%: +AlwaysOnTop +Owner -Caption
      Gui %i%: margin, 0,0
      Gui %i%: color, %backcolor%
      Gui %i%: add, pic, v%pic%Pict, %A_ScriptDir%/resource/%picture%.png
      Gui %i%:show, % "x"ref(p "X")" y"ref(p "Y")
      GoSub Dock2TaskBar
   }
}

BarShow(bar,i) {
   local b
   b = %bar%_Bar_
   If %b%Show
   {
      Gui %i%: +AlwaysOnTop +Owner -Caption
      Gui %i%: margin,0,0
      Gui %i%: add, pic, % "vBack" i " h"ref(b "H")" w"ref(b "W") ,% CreateBMPGradient("resource/" i "Back.bmp",barbackcolor2,barbackcolor1,1)
      Gui %i%: add, pic, % "xp yp vBar" i " h"ref(b "H")" w"ref(b "W") ,% CreateBMPGradient("resource/" i "bar.bmp",ref(b "color_2"),ref(b "color_1"),1)
      gui %i%: show, % "x"ref(b "x")" y"ref(b "y")
      GoSub Dock2TaskBar
      SetTimer %bar%Update, % ref(bar "_Update")
   }
}

Changebar(i,bar,var
         ,choice1,pic1,color1a,color1b
         ,choice2,pic2,color2a,color2b
         ,choice3=0,pic3=0,color3a=0,color3b=0)
{
   global backcolor
   loop,3
      if var = % choice%A_index%
         choice = %A_index%
   b = %bar%_Bar_
   j := i - 10
   guicontrol %j%: ,%bar%pict, % "resource/" pic%choice% ".png"
   guicontrol %i%:,bar%i%, % CreateBMPGradient("resource/" i "bar.bmp",ref(b color%choice%b),ref(b . color%choice%a),1)
   ;Gosub, Dock2TaskBar
}

FindToolbar(Name)
{   
         WinExist("ahk_class Shell_TrayWnd") ; Find Systemtray
         WinGet, Controls ,ControlList ;Get list of all controls
         Loop, Parse, Controls, `n
         {
            ControlGetText, CurControl , %A_LoopField%
            if CurControl=%Name% ;Find the toolbar we want by comparing controls Text
               ControlGet, hwnd, Hwnd,,%A_LoopField% ;Get the handle for the toolbar
         }
   return hwnd
}

allstats()
{
global
output =
if proc_bar_show
   output := output "Processor Load: " round(load,0) "%`n"
if batt_bar_show
   output := output "Battery Level: " round(val) "% (" charging ")`n"
if sound_bar_show
{
   if ismuted = on
      muteextra = (Muted)
   else
      muteextra =
   output := output "Volume: " round(soundlev) "%  " muteextra "`n"
}
if ram_bar_show
{
   VarSetCapacity(memorystatus, 4+4+4+4+4+4+4+4)
   success := DllCall("kernel32.dll\GlobalMemoryStatus", "uint", &memorystatus)
   total := Round(ReadInteger(&memorystatus,8,4, false)/1024/1024)
   used := total - Round(ReadInteger(&memorystatus,12,4, false)/1024/1024)
   output := output "Memory: " round(mem) "%    " used "/" total "mb"
}
return output
}

ReadInteger( p_address, p_offset, p_size, p_hex=true )
{
  value = 0
  old_FormatInteger := a_FormatInteger
  if ( p_hex )
    SetFormat, integer, hex
  else
    SetFormat, integer, dec
  loop, %p_size%
    value := value+( *( ( p_address+p_offset )+( a_Index-1 ) ) << ( 8* ( a_Index-1 ) ) )
  SetFormat, integer, %old_FormatInteger%
  return, value
}

;---------when application quits:
quitsysinfo:
guiclose:
onexit:
   DllCall("FreeLibrary", "UInt", hModule)
   exitapp

; -----------------Goyyahs BitmapGradient.ahk File--------------------
;   Visit http://www.autohotkey.com/forum/viewtopic.php?p=61081#61081

CreateBMPGradient(File, RGB1, RGB2, Vertical=1) {

   If (BGR(RGB1)="" OR BGR(RGB2)="")
      Return Null

   Hs1:="424d3e00000000000000360000002800000"
   Hs3:="001001800000000000800000000000000000000000000000000000000"

   If Vertical {
     Hs2:="0010000000200000"
     HexString:= Hs1 Hs2 Hs3 BGR(RGB1) "00" BGR(RGB2) "00" 
   }
   Else {
     Hs2:="0020000000100000"
     HexString:= Hs1 Hs2 Hs3 BGR(RGB1) BGR(RGB2) "0000"
   }

   Handle:= DllCall("CreateFile","str",file,"Uint",0x40000000
                ,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0)

   Loop 62 {
     StringLeft, Hex, HexString, 2         
     StringTrimLeft, HexString, HexString, 2 
     Hex = 0x%Hex%
     DllCall("WriteFile","UInt", Handle,"UChar *", Hex
     ,"UInt",1,"UInt *",UnusedVariable,"UInt",0)
    }
 
   DllCall("CloseHandle", "Uint", Handle)

Return File
}

BGR(RGB) {

  If (StrLen(RGB)<>6)
     Return Null

  Loop, Parse, RGB
     If A_LoopField not in 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
       Return Null

  StringMid,R,RGB,1,2
  StringMid,G,RGB,3,2
  StringMid,B,RGB,5,2

Return B G R
}

RandomHexColor(Range1=0,Range2=255) {

 Random, _RGB1, %Range1%, %Range2%
 Random, _RGB2, %Range1%, %Range2%
 Random, _RGB3, %Range1%, %Range2%

 SetFormat, Integer, Hex
 _RGB1+=0
 _RGB2+=0
 _RGB3+=0

 If StrLen(_RGB1) = 3
    _RGB1= 0%_RGB1%

 If StrLen(_RGB2) = 3
    _RGB2= 0%_RGB2%

 If StrLen(_RGB3) = 3
    _RGB3= 0%_RGB3%

 SetFormat, Integer, D
 HEXString = % _RGB1 _RGB2 _RGB3
 StringReplace, HEXString, HEXString,0x,,All
 StringUpper, HEXString, HEXString

Return HexString
}

_________________
Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."


Last edited by Veovis on June 21st, 2006, 5:37 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2006, 1:01 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Nicely laid out! I don't find your code ugly, at all!
- Have you tried adding your own toolbar as a placeholder (right-click in the taskbar, Toolbars / New Toolbar...)? That way the quicklaunch toolbar (shifted right) could remain functional.
- You might not need the gosubs under "load dlls into library". The timers are already running.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2006, 1:26 am 
Offline

Joined: February 13th, 2006, 10:40 pm
Posts: 389
Location: Utah
Thanks, i didnt know you could make a new toolbar like that! That makes things nicer.

The reason i put the gosubs is to help make the script 'initialize' faster, otherwise some of the progress bars wont show up for 2-5 seconds.

One thing i want to change is this: when i moved this script to my home computer, the battery bar was still there so i had to go do a little bit of code changing to make it look nice with only three bars. I want some kind of gui to customize it but i dont know how. Would i have have the customizer write an .ini? or is there a better way that doesnt involve using 20 or more ini reads to get the program loaded?

_________________
Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2006, 4:51 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
When you read a key from an ini file, the first few disk blocks (512 ... 4KB each) are read into a disk buffer. Subsequent ini reads are virtually instantaneous, accessing only RAM. Reading one or twenty keys from the ini file does not make a noticeable difference. So, don't be afraid of storing many settings in an ini file, like the positions, the sizes and the number of progress bars, their colors, their associated icons, etc.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2006, 12:19 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Laszlo wrote:
...
- Have you tried adding your own toolbar as a placeholder (right-click in the taskbar, Toolbars / New Toolbar...)? That way the quicklaunch toolbar (shifted right) could remain functional.
...


this script is quite cool, never thought manipulating the taskbar would be so easy ;)

@Lazlo: how would i talk to the "new toolbar" i have added. Get it by Window-Title ? how does AHK find my "manually" added window ? ( i think about using it in DeskMan, as a dock is a kind of taskbar-replacement )

@Veovis: i think your sysinfos are quite useful, or in other words they show me how to consolidate some tray-icon-apps (for cpu-load/mem/battery/cpu-mhz/volume etc) into one.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2006, 12:41 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
holomind wrote:
how would i talk to the "new toolbar" i have added
I thought it to be a placeholder, that you can cover with your own GUI window. Its only task is to make sure nothing important gets under your taskbar window.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2006, 12:47 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
@Lazlo: would it be possible to "reuse" this manually added toolbar, or is this hard with AHK ? As much as i understand, you suggest this "placeholder" only prevents other windows from using this space ? my question/suggestion is that if you could reuse this manual taskbar it would be nice for resize as you could read the size of this toolbar etc. and make your content addopt to the size. Eg. especially the taskbar is "moving" and some people use them on top, left, right or bottom and the position nothing but predictable.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2006, 12:54 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I think you can only add a folder or an Internet shortcut this way, but manipulating the title of the folder might be possible, to put, e.g. your resizeable clock there. Beyond that you need a Windows Guru, like Shimanov, to help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2006, 12:55 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
veovis wrote:
Note that i had to turn on my quickluanch and delete all the icons in it so it wouldnt cover things up.


Perhaps i am on the wrong track, you only meant to replace the "reused quicklaunch-toolbar" with a "new one". but perhaps this gives something to discuss.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 4:40 pm 
Offline

Joined: May 9th, 2006, 6:22 pm
Posts: 75
Hi

I found a way to attach this Sysinfo script to a custom toolbar.

Just make a new toolbar attach it to a folder called "Sysinfo" and change this:
Code:
hw_tray := DllCall( "FindWindowEx", "uint",0, "uint",0,"str","Shell_TrayWnd", "uint",0 )

To this:
Code:
WinExist("ahk_class Shell_TrayWnd")
WinGet, OutputVar ,ControlList
Loop, Parse, OutputVar, `n
{
   ControlGetText, OutputVar1 , %A_LoopField%
   if OutputVar1=Sysinfo
   {
      ControlGet, hw_tray, Hwnd ,, %A_LoopField%
   }
}


The toolbar can have any name just change "if OutputVar1=Sysinfo" to the new name.

Hope this is useful.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 6:53 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Could you post the whole script? The changes above do not work for me. Maybe, you have made another mod, too?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 7:03 pm 
Offline

Joined: May 9th, 2006, 6:22 pm
Posts: 75
Laszlo wrote:
Could you post the whole script? The changes above do not work for me. Maybe, you have made another mod, too?

Sorry I changed moduleX and moduleY, and the new toolbar can't be to small.
Code:
moduleX = 101      ;x and y **FROM TOP LEFT OF START BUTTON!!***
moduleY = 2   

To:
Code:
moduleX = 0      ;x and y **FROM TOP LEFT OF START BUTTON!!***
moduleY = 0


Here is the changed script.
Code:
;~~~~~Sys Info in Task Bar~~~~~~~
;            v1.0
;Made by Michael Peters
;With segments of code from:
;   Rajats volume OSD   http://www.autohotkey.com/forum/viewtopic.php?t=88
;   Laszlos Taskbar Clock/Calendar with Processor and Memory Load bars   http://www.autohotkey.com/forum/viewtopic.php?t=6290
;  Thankyou!


;-------Basic Config---------
barsW = 100      ;width of proc, batt, sound BARS etc
;moduleX = 101      ;x and y **FROM TOP LEFT OF START BUTTON!!***
moduleX = 0      ;x and y **FROM TOP LEFT OF START BUTTON!!***
;moduleY = 2   
moduleY = 0
barsX := moduleX+ 18     ; bars x location (module x + 18ish) you can modify each bar independantly below

updateProc = 1000      ; how fast to update proc, bat, sound, etc. 1000 = 1 sec
updateBatt = 3000
updateSound = 100
updateRam = 5000


;   use this area to costomize each bar individually

ProcBarH = 10      ; height
ProcBarColor = blue      ;color
ProcBarY := moduleY + 1   ;y location    (so you can modify it is you want
ProcBarX = %BarsX%   ;x location    (barsx appears above, change this if you dont want all 4 next to each other)

BattBarH = 9
BattBarColor = ff6600
BattBarColorCharging = green      ;color of battery bar when charging
BattBarColorLow = red      ;color of battery bar when below:
BattWarning = 20 ; percent when battery bar turns (color above) and icon changes
BattBarY := ProcBarY + ProcBarH + 5
BattBarX = %BarsX%

SoundBarH = 9
SoundBarColor = navy      ;color of sound bar when not muted
SoundBarColorMuted= gray      ;color of sound bar when muted
SoundBarY := BattBarY + BattBarH + 6
SoundBarX = %BarsX%

RamBarH = 9
RamBarcolor = 004400
RamBarY := SoundBarY + SoundBarH + 6
RamBarX = %BarsX%

;--------------------CODE STARTS HERE----------------
#singleinstance force
#notrayicon
;hw_tray := DllCall( "FindWindowEx", "uint",0, "uint",0, "str","Shell_TrayWnd", "uint",0 )
;Mod by jonib
WinExist("ahk_class Shell_TrayWnd")
WinGet, OutputVar ,ControlList
Loop, Parse, OutputVar, `n
{
   ControlGetText, OutputVar1 , %A_LoopField%
   if OutputVar1=Sysinfo
   {
      ControlGet, hw_tray, Hwnd ,, %A_LoopField%
   }
}
;Mod by jonib
menu sysinfomenu, add, Exit, quitsysinfo


;---draw progress bars
progress 1:b x%ProcBarX% y%ProcBary% zx0 zy0 h%ProcBarH% w%barsW% CB%ProcBarcolor%
GoSub Dock2TaskBar
progress 2:b x%BattBarX% y%BattBary% zx0 zy0 h%BattBarh% w%barsW% CB%BattBarcolor%
GoSub Dock2TaskBar
progress 3:b x%SoundBarX% y%SoundBary% zx0 zy0 h%SoundBarH% w%barsW% CB%SoundBarcolor%
GoSub Dock2TaskBar
progress 4:b x%RamBarX% y%RamBary% zx0 zy0 h%RamBarh% w%barsW% CB%RamBarcolor%
GoSub Dock2TaskBar

;---draw gui and picts


gui, -caption toolwindow
gui, color, silver
gui, +lastfound
gui, margin, 0,0
gui, add, pic,, processor.png
gui, add, pic,yp+14 vBattPict, battery.png
gui, add, pic,yp+15 vSoundPict, sndvol32.png
gui, add, pic,yp+15, ram.png
gui, show, x%moduleX% y%moduleY%, SysInfo

WinActivate SysInfo
GoSub Dock2TaskBar

SetTimer ProcUpdate, %updateproc%
SetTimer BattUpdate, %updatebatt%
SetTimer SoundUpdate, %updatesound%
SetTimer RamUpdate, %updateram%

;load dlls into library
hModule := DllCall("LoadLibrary", "str", "cmdret.dll","UInt")
gosub, procupdate
gosub, battupdate
gosub, soundupdate
gosub, ramupdate
return

guicontextmenu:
   menu sysinfomenu, show
return


ProcUpdate:
   ;-----Get Processor------
   IdleTime0 = %IdleTime%  ; Save previous values
   Tick0 = %Tick%
   DllCall("kernel32.dll\GetSystemTimes", "uint",&IdleTicks, "uint",0, "uint",0)
   IdleTime := *(&IdleTicks)
      Loop 7                  ; Ticks when Windows was idle
   IdleTime += *( &IdleTicks + A_Index ) << ( 8 * A_Index )
   Tick := A_TickCount     ; #Ticks all together
   load := 100 - 0.01*(IdleTime - IdleTime0)/(Tick - Tick0)
   Progress 1:%load%       ; Update progress bar
return

BattUpdate:
   sysget, isshuttingdown, 8192
   if isshuttingdown = 0
   {
   ;------Get Battery Level--------
      CMD := "apm"
      VarSetCapacity(StrOut, 1000)
      DllCall("lstrcpyA", "str", StrOut, "int", DllCall("cmdret.dll\RunRedirect", "str", CMD))
      StringGetPos, pos, StrOut,`%
      StringMid, val, StrOut, pos, 3, L
      ifinstring, strOut, charging
         charging = yes
      else if val < %battWarning%   
         charging = low
      else
         charging = no
      if charging != %oldcharging% ;if charging/low state has changed, find out new state and change bar color and icon
      {
         if charging = yes
         {
            guicontrol, ,battpict, battery_charge.png
            gui, show
            progress 2:b x%barsX% y%BattBary% zx0 zy0 h%BattBarh% w%barsW% CB%BattBarColorCharging%
         }
         if charging = no
         {
            guicontrol, ,battpict, battery.png
            gui, show
            progress 2:b x%barsX% y%BattBary% zx0 zy0 h%BattBarh% w%barsW% CB%BattBarcolor%
         }
         if charging = low
         {
            guicontrol, ,battpict, battery_low.png
            gui, show
            progress 2:b x%barsX% y%BattBary% zx0 zy0 h%BattBarh% w%barsW% CB%BattBarcolorLow%
         }
         GoSub Dock2TaskBar
         oldcharging := charging
         gosub, BattUpdate
      }
      Progress 2:%val% ;set bar to charge percent
   }
return

SoundUpdate:
   ;-----Get Sound Level------
   soundget, ismuted,, mute
   if ismuted !=  %oldmute%
   {      
      if ismuted = on
      {
         guicontrol, ,soundpict, snd_muted.png
         gui, show
         progress 3:b x%barsX% y%SoundBary% zx0 zy0 h%SoundBarH% w%barsW% CB%SoundBarcolorMuted%
      }
      if ismuted = off
      {
         guicontrol, ,soundpict, sndvol32.png
         gui, show
         progress 3:b x%barsX% y%SoundBary% zx0 zy0 h%SoundBarH% w%barsW% CB%SoundBarcolor%
      }
      GoSub Dock2TaskBar
      oldmute = %ismuted%
   }
   soundget, soundlev, master
   Progress 3:%soundlev%

return

RamUpdate:
   ;------Get Ram level--------
   DllCall("kernel32.dll\GlobalMemoryStatus", "uint",&memorystatus)
   mem:=*(&memorystatus+4) ; LS byte is enough, mem = 0..100
   Progress 4:%mem%        ; Update progress bar 
return


Dock2TaskBar:              ; Active window to be docked to the taskbar, NEEDS hw_tray value
   Process Exist           ; PID -> ErrorLevel
   WinGet hw_gui, ID, ahk_pid %ErrorLevel%
   DllCall( "SetParent", "uint", hw_gui, "uint", hw_tray )
Return


;---------when application quits:
quitsysinfo:
   DllCall("FreeLibrary", "UInt", hModule)
   exitapp
guiclose:
   DllCall("FreeLibrary", "UInt", hModule)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 7:21 pm 
Offline

Joined: May 9th, 2006, 6:22 pm
Posts: 75
Same mod with same comments
Code:
WinExist("ahk_class Shell_TrayWnd") ; Find Systemtray
WinGet, OutputVar ,ControlList ;Get list of all controls in systray
Loop, Parse, OutputVar, `n
{
   ControlGetText, OutputVar1 , %A_LoopField%
   if OutputVar1=Sysinfo ;Find the toolbar we want by comparing controls Text
   {
      ControlGet, hw_tray, Hwnd ,, %A_LoopField% ;Get the handle for the toolbar
   }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 7:49 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Could you explain it a little more? I thought with the empty Sysinfo directory, as a toolbar, you reserved space. You need to find its location and put the Gui there, but the Gui still has to be docked to the Taskbar (tray window), to remain visible.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 8:15 pm 
Offline

Joined: May 9th, 2006, 6:22 pm
Posts: 75
Laszlo wrote:
Could you explain it a little more? I thought with the empty Sysinfo directory, as a toolbar, you reserved space. You need to find its location and put the Gui there, but the Gui still has to be docked to the Taskbar (tray window), to remain visible.


My code identifies the windows handle of the Sysinfo toolbar and then the "SetParent" dll call attaches the Sysinfo script to the Sysinfo toolbar, and now you can move the toolbar within the systemtray and the Sysinfo script moves with it.

Did you test my modified version? did it work for you?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, sks and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group