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 

TekOS
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Elesar



Joined: 28 Jun 2007
Posts: 91

PostPosted: Thu May 08, 2008 2:12 pm    Post subject: Reply with quote

Updated my version of the TekOS to include the Run bar and system info bar at the bottom.

Run system will use standard windows "Run" if input text does not match one of the selections.

My changes are only for the Tek.ahk file, just replace with mine (Or name it something different and run it instead if you like better)

Here is what it looks like:


Code:
;<=====  System Settings  =====>
#SingleInstance Force
#NoEnv
SetTimer,CpuLoad,1000
SetFormat, Float, 0.2

;<=====  Menu  =====>
Menu, MyMenu, Add, Run, RunFile
Menu, MyMenu, Add, Remove, RemoveFile

;<=====  GUI  =====>
Gui, Color, FFFFFF
Gui -Border
Gui, Font,, Comic Sans MS Bold

Gui, Add, Text, x6 y6 w150 h20 , Welcome to TekOS REMIX

Gui, Add, ComboBox, x300 y6 w150 h20 r4 vRunText, AHK Write|ACConsole|File Manager|AHK Media Player
Gui, Add, Button, x456 y6 w60 h23 gRunCommand, Run

Gui, Add, GroupBox, x6 y30 w250 h220 , Date
Gui, Add, MonthCal, x16 y50 w230 h190 ,

Gui, Add, GroupBox, x266 y30 w250 h220 , Quick Launcher
Gui, Add, Button, x276 y50 w230 h20 gAddFile, Add file to Quick Launcher
Gui, Add, ListView, x276 y70 w230 h170 gCentral, Name|Extension|Directory

Gui, Add, GroupBox, x6 y260 w250 h140 , System
Gui, Add, Picture, x16 y280 w40 h40 , Resources\Computer.ico
Gui, Add, Button, x66 y280 w80 h20 gHibernate, Hibernate
Gui, Add, Button, x66 y310 w80 h20 gLogoff, Log Off
Gui, Add, Button, x66 y340 w80 h20 gReboot, Reboot
Gui, Add, Button, x66 y370 w80 h20 gShutdown, Shut Down
Gui, Add, Button, x156 y280 w80 h20 gGetSystemInfo, System Info
Gui, Add, Button, x156 y340 w80 h20 gEject, Eject
Gui, Add, Button, x156 y370 w80 h20 gRetract, Retract

Gui, Add, GroupBox, x266 y260 w250 h140 , Internet
Gui, Add, Picture, x276 y280 w50 h50 , Resources\Web page.ico
Gui, Add, Button, x336 y280 w110 h20 gGoogle, Google
Gui, Add, Button, x336 y310 w110 h20 gHotMail, HotMail
Gui, Add, Button, x336 y340 w110 h20 gGMail, gMail
Gui, Add, Button, x336 y370 w110 h20 gWeather, Weather

Gui, Add, StatusBar, x6 y30 w140 h20 ,

Gui, Show, xCenter yCenter h426 w522, Tek OS REMIX
SB_SetParts(100,110,150)
WinSet, Transparent, 185, Tek OS REMIX
WinGet, TekID, ID, A
Return

;<=====  System Buttons  =====>
Reboot:
  ShutDown, 2
  Return

Shutdown:
  Shutdown, 1
  Return

Logoff:
  Shutdown, 0
  Return

Hibernate:
  DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
  Return

GetSystemInfo:
  DriveGet,Capacity,Capacity,%SystemDrive%
  Drivespacefree, FreeSpace, %Systemdrive%
  If Capacity > 1024
    CapacityGB := Capacity / 1024
  CapacityGBR := Round(CapacityGB)
  If FreeSpace > 1024
    FreeSpaceGB := FreeSpace / 1024
  FreeSpaceGBR := Round(FreeSpaceGB)
  Memory := DllCall("resources\gmem.dll\GetMemStats", "str", "dwTotalPhys")
  MemoryMB := Memory / 1024 /1024
  MemoryMBR := Round(MemoryMB)
  Code (Copy):
  Runwait, %comspec% /c ver > %temp%\OSSP.txt,,Hide
  Fileread,OperatingSystem,%temp%\OSSP.txt
  Filedelete,%temp%\ver.txt
  MsgBox, 64, ,Operating System: %OperatingSystem%`nDrive: %Systemdrive%`nHolding Capacity (GB):%CapacityGBR%`nTotal Space Left (GB):%FreeSpaceGBR%`nTotal RAM (MB): %MemoryMBR%
  Return

;<=====  Internet Buttons  =====>
Google:
  Run, www.google.com
  Return

HotMail:
  Run, www.hotmail.com
  Return

GMail:
  Run, www.gmail.com
  Return

Weather:
  Run, www.weather.com
  Return

Eject:
  Drive, Eject,,
  Return

Retract:
  Drive, Eject,, 1
  Return

;<=====  Run System  =====>
RunCommand:
  Gui, Submit, NoHide
  If RunText = AHK Write
    Run, Resources\AHKWrite.ahk
  Else If RunText = ACConsole
    Run, Resources\ACConsole.ahk
  Else If RunText = File Manager
    Run, Resources\FileManager.ahk
  Else If RunText = AHK Media Player
    Run, Resources\AHK Media Player.ahk
  Else
    Run, %RunText%
  Return

;<=====  Quick Launcher  =====>
AddFile:
  Gui, +OwnDialogs
  FileSelectFile,FilesToAdd,M3,,Select  File,
  If (!FilesToAdd)
    {
      MsgBox, No File(s) Selected
      Return
    }
  Loop, parse, FilestoAdd, `n
    {
      If (a_index != 1)
        {
          SplitPath,A_loopField,,,FileExt
          LV_Add("",a_loopfield,FileExt,dir)
        }
      Else
        {
          Dir:=a_loopField
        }
    }
  LV_ModifyCol()
  Return

Central:
  Remove = %A_EventInfo%
  LV_GetText(name, A_EventInfo, 1)
  LV_GetText(dir, A_EventInfo, 3)
  ToRun = %dir%\%name%
  If A_GuiEvent = DoubleClick
    GoSub, RunFile
  If A_GuiEvent = RightClick
    Menu, MyMenu, Show
  Return

RunFile:
  Run, %ToRun%
  Return

RemoveFile:
  LV_Delete(Remove)
  Return

;<=====  CPU Load  =====>
CpuLoad:
  Load := GetSystemTimes()
  SB_SetText("CPU Load: " Load `%,2)
  d = `n
  s := 4096
  l =
  Process, Exist
  h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel)
  DllCall("Advapi32.dll\OpenProcessToken", "UInt", h, "UInt", 32, "UIntP", t)
  VarSetCapacity(ti, 16, 0)  ; structure of privileges
  NumPut(1, ti, 0, 4)  ; one entry in the privileges array...
  DllCall("Advapi32.dll\LookupPrivilegeValueA", "UInt", 0, "Str", "SeDebugPrivilege", "UIntP", luid)
  NumPut(luid, ti, 4, 8)
  NumPut(2, ti, 12, 4)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
  DllCall("Advapi32.dll\AdjustTokenPrivileges", "UInt", t, "Int", false, "UInt", &ti, "UInt", 0, "UInt", 0, "UInt", 0)
  DllCall("CloseHandle", "UInt", h)  ; close this process handle to save memory
  hModule := DllCall("LoadLibrary", "Str", "Psapi.dll")  ; increase performance by preloading the libaray
  s := VarSetCapacity(a, s)  ; an array that receives the list of process identifiers:
  DllCall("Psapi.dll\EnumProcesses", "UInt", &a, "UInt", s, "UIntP", r)
  Loop, % r // 4  ; parse array for identifiers as DWORDs (32 bits):
    {
      id := NumGet(a, A_Index * 4)
      ; Open process with: PROCESS_VM_READ (0x0010) | PROCESS_QUERY_INFORMATION (0x0400)
      h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id)
      VarSetCapacity(m, s)  ; an array that receives the list of module handles:
      DllCall("Psapi.dll\EnumProcessModules", "UInt", h, "UInt", &m, "UInt", s, "UIntP", r)
      VarSetCapacity(n, s, 0)  ; a buffer that receives the base name of the module:
      e := DllCall("Psapi.dll\GetModuleBaseNameA", "UInt", h, "UInt", m, "Str", n, "Chr", s)
      DllCall("CloseHandle", "UInt", h)  ; close process handle to save memory
      If n  ; if image is not null add to list:
      l = %l%%n%%d%
    }
  DllCall("FreeLibrary", "UInt", hModule)  ; unload the library to free memory
  ; Remove the first and last items in the list (possibly ASCII signitures)
  StringMid, l, l, InStr(l, d) + 1, InStr(l, d, false, 0) - 2 - InStr(l, d)
  StringReplace, l, l, %d%, %d%, UseErrorLevel  ; gets the number of processes

  ;Sort, l, C  ; uncomment this line to sort the list alphabetically
  SB_SetText("Processes: " Errorlevel)

  varsetcapacity(memorystatus,512)
  DllCall("kernel32.dll\GlobalMemoryStatus", "uint",&memorystatus)
  mem:=*(&memorystatus+4) ; LS byte is enough, mem = 0..100
  mem := (mem/100)
  SB_SetText("Memory Usage: " mem `%,3)
  Return

GetSystemTimes()    ; Total CPU Load
  {
    Static oldIdleTime, oldKrnlTime, oldUserTime
    Static newIdleTime, newKrnlTime, newUserTime

    oldIdleTime := newIdleTime
    oldKrnlTime := newKrnlTime
    oldUserTime := newUserTime

    DllCall("GetSystemTimes", "int64P", newIdleTime, "int64P", newKrnlTime, "int64P", newUserTime)
    Return (1 - (newIdleTime-oldIdleTime)/(newKrnlTime-oldKrnlTime + newUserTime-oldUserTime)) * 100
  }

;<=====  Show/Hide  =====>
HideTek:
  If TekID <> -1
    {
      WinHide, ahk_id %TekID%
    }
  Return

ShowTek:
  If TekID <> -1
    {
      WinShow, ahk_id %TekID%
      WinActivate, ahk_id %TekID%
      ControlFocus, Edit1, ahk_id %TekID%
    }
  Return

^!x:: ;Change this to Show/Hide with desired hotkey.
  IFWinExist, ahk_id %TekID%
    {
      GoSub, HideTek
      Return
    }
    DetectHiddenWindows, ON
    IFWinExist, ahk_id %TekID%
      GoSub, ShowTek
    DetectHiddenWindows, OFF
  Return


EDIT:
Added picture.
Back to top
View user's profile Send private message
Elesar



Joined: 28 Jun 2007
Posts: 91

PostPosted: Fri May 09, 2008 5:53 am    Post subject: Reply with quote

Redid the included AHK Media Player to match the theme that I did for the TekOS.

Also used the sound icon for the tray icon for the media player, used the pinion icon for the TekOS tray icon.

Added the AHK logo by kweso to both windows (The origional b/w one with uniform caps)

Here is a screen of the media player:


and the code..

AHK Media Player:
Code:
;<=====  System Settings  =====>
#SingleInstance Force
#NoEnv
FileInstall, SoundFunctions.ahk, SoundFunctions.ahk, 0
FileInstall, Filter.ini, Filter.ini, 0
SetBatchLines -1
SetTimer, UpdateSound,5000
SetTimer, UpdateTime,100
SetTimer,UpdateProgress,1000
SetTimer,CheckStatus,100
SoundGet, MV
RSound := Round(MV)
playing = 0
IniRead, Filter, Filter.ini, Config, F
SetTitleMatchMode, 3
#Include Resources\SoundFunctions.ahk

;<=====  GUI  =====>
Menu, Tray, Icon, Resources\sound.ico

Gui, Color, FFFFFF
Gui -Border
Gui, Font,, Comic Sans MS Bold
Gui, Add, Picture, x215 y3 ,Resources\AHKLogo.jpg

Gui, Add, Text, x6 y6 w150 h20, AHK Media Player REMIX

Gui, Add, Button, x6 y30 w150 h20 gOpenMF, Select Media File
Gui, Add, Button, x6 y50 w50 h20 gStopF, Stop
Gui, Add, Button, x56 y50 w50 h20 gPauseF, Pause
Gui, Add, Button, x106 y50 w50 h20 gResumeF, Resume

Gui, Add, Button, x269 y30 w150 h20 gAddC, Add File to Collection
Gui, Add, Button, x269 y50 w150 h20 gEC, Empty Collection

Gui, Add, Text, x435 y6 w50 h20 +Center, Volume
Gui, Add, Slider, x450 y26 w30 h225 Vertical Invert vVSlider Range0-100 gVolumeC AltSubmit, %MV%
Gui, Add, Text, x440 y250 w40 h20 +Center vVText, %RSound%

Gui, Add, Progress, x6 y80 w300 h30 cBlue vProgress Range1-100 vProgress, 0
Gui, Add, Text, x316 y75 w100 r2 vSongTime, 0:0:0`n0:0:0

Gui, Add, StatusBar, x176 y70 w290 h30 , Not Playing A File

Gui, Add, ListView, x6 y120 w425 h150 gPlayLV vLV, Name|Type|Dir

Gui, Show, xCenter yCenter h300 w487, AHK Media Player
Return

GuiClose:
  ExitApp
  Return

;<=====  Sound Controls  =====>
UpdateSound:
  Gui, Submit, NoHide
  SoundGet, MVU
  RSound := Round(MVU)
  Guicontrol,,VSlider,%MVU%
  GuiControl,,VText,%RSound%
  Return

VolumeC:
  Gui, Submit, NoHide
  SoundSet,%VSlider%,master
  GuiControl,, VText,%VSlider%
  Return

OpenMF:
  CheckSong := Sound_Status(hSound)
  If CheckSong = playing
    {
      Sound_Stop(hSound)
      playing = 0
    }
  Gui, +OwnDialogs
  FileSelectFile, Filetoplay, 3, , Select Media File,Audio %Filter%
  If Filetoplay =
    MsgBox,No File Selected
  filename=
  sleep 100
  SplitPath, Filetoplay, filename
  sleep 100
  hSound := Sound_Open(Filetoplay)
  If Not hSound
    Return
  playing = 1
  Sound_Play(hSound)
  Guicontrol,,Progress,0
  Guicontrol,% "+Range1-" Sound_Length(hSound) / 1000,Progress
  SplitPath, Filetoplay, filename
  SB_SetText("Now Playing " filename)
  Return

StopF:
  Sound_Stop(hSound)
  playing = 0
  Guicontrol,,Progress,0
  GuiControl,,SongTime,0:0:0`n0:0:0
  SB_SetText("Not Playing A File")
  Return

PauseF:
  Sound_Pause(hSound)
  Return

ResumeF:
  Sound_Resume(hSound)
  Return

UpdateTime:
  If playing = 0
    Return
  If(Sound_Pos(hSound) = Sound_Length(hSound))
    Return
  GuiControl,,SongTime,% Tohhmmss(Sound_Pos(hSound)) .  "`n"  . Tohhmmss(Sound_Length(hSound))
  Return

UpdateProgress:
  If playing = 0
    Return
  If(Sound_Pos(hSound) = Sound_Length(hSound))
    Return
  Guicontrol,,Progress,% (Sound_Pos(hSound) / 1000)
  Return

CheckStatus:
  Status := Sound_Status(hSound)
  If Status = stopped
    {
      sleep 1500
      Guicontrol,,Progress,0
      Guicontrol,,SongTime,0:0:0`n0:0:0
      SB_SetText("Not Playing A File")
    }
  Return

PlayLV:
  LV_GetText(name, A_EventInfo, 1)
  LV_GetText(dir, A_EventInfo, 3)
  ToPlay = %dir%\%name%
  CheckSong := Sound_Status(hSound)
  If CheckSong = playing
    {
      Sound_Stop(hSound)
      playing = 0
    }
  hSound := Sound_Open(ToPlay)
  If Not hSound
    Return
  playing = 1
  Sound_Play(hSound)
  Guicontrol,,Progress,0
  Guicontrol,% "+Range1-" Sound_Length(hSound) / 1000,Progress
  SB_SetText("Now Playing " name)
  Return

UpdateLV:
  Gui, Submit, NoHide
  LV_Delete()
  Loop, %Directory%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeMB, A_LoopFileExt,A_LoopFileFullPath)
  LV_ModifyCol()
  LV_ModifyCol(2,"Integer")
  Return

AddC:
  If hSound =
    GoSub CAM
  Else
    {
      CheckSong := Sound_Status(hSound)
      If CheckSong = playing
        {
          Sound_Pause(hSound)
          playing = 0
          GoSub CAM
        }
    }
  Return

CAM:
  Critical
  Gui, +OwnDialogs
  Thread,NoTimers
  Sleep,200 ; Ensure No timers start
  FileSelectFile,FilesToAdd,M3,,Select Media File,Audio %Filter%
  Thread,Notimers,False
  If (!FilesToAdd)
    {
      Return
    }
  Loop, parse, FilestoAdd, `n
    {
      If (a_index != 1)
        {
          SplitPath,A_loopField,,,FileExt
          LV_Add("",a_loopfield,FileExt,dir)
        }
      Else
        {
          Dir:=a_loopField
        }
    }
  If hSound =
    Return
  LV_ModifyCol()
  Sound_Resume(hSound)
  Return

EC:
  LV_Delete()
  Return

^h::
  IfWinExist, AHK Media Player
    WinHide, AHK Media Player
  Else
    WinShow, AHK Media Player
  Return


TekOS:
Code:

;<=====  System Settings  =====>
#SingleInstance Force
#NoEnv
SetTimer,CpuLoad,1000
SetFormat, Float, 0.2

;<=====  Menu  =====>
Menu, Tray, Icon, Resources\Pinion.ico
Menu, MyMenu, Add, Run, RunFile
Menu, MyMenu, Add, Remove, RemoveFile

;<=====  GUI  =====>
Gui, Color, FFFFFF
Gui -Border
Gui, Font,, Comic Sans MS Bold

Gui, Add, Picture, x215 y3 ,Resources\AHKLogo.jpg

Gui, Add, Text, x6 y6 w150 h20 , Welcome to TekOS REMIX

Gui, Add, ComboBox, x300 y6 w150 h20 r4 vRunText, AHK Write|ACConsole|File Manager|AHK Media Player
Gui, Add, Button, x456 y6 w60 h23 gRunCommand, Run

Gui, Add, GroupBox, x6 y30 w250 h220 , Date
Gui, Add, MonthCal, x16 y50 w230 h190 ,

Gui, Add, GroupBox, x266 y30 w250 h220 , Quick Launcher
Gui, Add, Button, x276 y50 w230 h20 gAddFile, Add file to Quick Launcher
Gui, Add, ListView, x276 y70 w230 h170 gCentral, Name|Extension|Directory

Gui, Add, GroupBox, x6 y260 w250 h140 , System
Gui, Add, Picture, x16 y280 w40 h40 , Resources\Computer.ico
Gui, Add, Button, x66 y280 w80 h20 gHibernate, Hibernate
Gui, Add, Button, x66 y310 w80 h20 gLogoff, Log Off
Gui, Add, Button, x66 y340 w80 h20 gReboot, Reboot
Gui, Add, Button, x66 y370 w80 h20 gShutdown, Shut Down
Gui, Add, Button, x156 y280 w80 h20 gGetSystemInfo, System Info
Gui, Add, Button, x156 y340 w80 h20 gEject, Eject
Gui, Add, Button, x156 y370 w80 h20 gRetract, Retract

Gui, Add, GroupBox, x266 y260 w250 h140 , Internet
Gui, Add, Picture, x276 y280 w50 h50 , Resources\Web page.ico
Gui, Add, Button, x336 y280 w110 h20 gGoogle, Google
Gui, Add, Button, x336 y310 w110 h20 gHotMail, HotMail
Gui, Add, Button, x336 y340 w110 h20 gGMail, gMail
Gui, Add, Button, x336 y370 w110 h20 gWeather, Weather

Gui, Add, StatusBar, x6 y30 w140 h20 ,

Gui, Show, xCenter yCenter h426 w522, Tek OS REMIX
SB_SetParts(100,110,150)
WinSet, Transparent, 185, Tek OS REMIX
WinGet, TekID, ID, A
Return

;<=====  System Buttons  =====>
Reboot:
  ShutDown, 2
  Return

Shutdown:
  Shutdown, 1
  Return

Logoff:
  Shutdown, 0
  Return

Hibernate:
  DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
  Return

GetSystemInfo:
  DriveGet,Capacity,Capacity,%SystemDrive%
  Drivespacefree, FreeSpace, %Systemdrive%
  If Capacity > 1024
    CapacityGB := Capacity / 1024
  CapacityGBR := Round(CapacityGB)
  If FreeSpace > 1024
    FreeSpaceGB := FreeSpace / 1024
  FreeSpaceGBR := Round(FreeSpaceGB)
  Memory := DllCall("resources\gmem.dll\GetMemStats", "str", "dwTotalPhys")
  MemoryMB := Memory / 1024 /1024
  MemoryMBR := Round(MemoryMB)
  Code (Copy):
  Runwait, %comspec% /c ver > %temp%\OSSP.txt,,Hide
  Fileread,OperatingSystem,%temp%\OSSP.txt
  Filedelete,%temp%\ver.txt
  MsgBox, 64, ,Operating System: %OperatingSystem%`nDrive: %Systemdrive%`nHolding Capacity (GB):%CapacityGBR%`nTotal Space Left (GB):%FreeSpaceGBR%`nTotal RAM (MB): %MemoryMBR%
  Return

;<=====  Internet Buttons  =====>
Google:
  Run, www.google.com
  Return

HotMail:
  Run, www.hotmail.com
  Return

GMail:
  Run, www.gmail.com
  Return

Weather:
  Run, www.weather.com
  Return

Eject:
  Drive, Eject,,
  Return

Retract:
  Drive, Eject,, 1
  Return

;<=====  Run System  =====>
RunCommand:
  Gui, Submit, NoHide
  If RunText = AHK Write
    Run, Resources\AHKWrite.ahk
  Else If RunText = ACConsole
    Run, Resources\ACConsole.ahk
  Else If RunText = File Manager
    Run, Resources\FileManager.ahk
  Else If RunText = AHK Media Player
    Run, Resources\AHK Media Player.ahk
  Else
    Run, %RunText%
  Return

;<=====  Quick Launcher  =====>
AddFile:
  Gui, +OwnDialogs
  FileSelectFile,FilesToAdd,M3,,Select  File,
  If (!FilesToAdd)
    {
      MsgBox, No File(s) Selected
      Return
    }
  Loop, parse, FilestoAdd, `n
    {
      If (a_index != 1)
        {
          SplitPath,A_loopField,,,FileExt
          LV_Add("",a_loopfield,FileExt,dir)
        }
      Else
        {
          Dir:=a_loopField
        }
    }
  LV_ModifyCol()
  Return

Central:
  Remove = %A_EventInfo%
  LV_GetText(name, A_EventInfo, 1)
  LV_GetText(dir, A_EventInfo, 3)
  ToRun = %dir%\%name%
  If A_GuiEvent = DoubleClick
    GoSub, RunFile
  If A_GuiEvent = RightClick
    Menu, MyMenu, Show
  Return

RunFile:
  Run, %ToRun%
  Return

RemoveFile:
  LV_Delete(Remove)
  Return

;<=====  CPU Load  =====>
CpuLoad:
  Load := GetSystemTimes()
  SB_SetText("CPU Load: " Load `%,2)
  d = `n
  s := 4096
  l =
  Process, Exist
  h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel)
  DllCall("Advapi32.dll\OpenProcessToken", "UInt", h, "UInt", 32, "UIntP", t)
  VarSetCapacity(ti, 16, 0)  ; structure of privileges
  NumPut(1, ti, 0, 4)  ; one entry in the privileges array...
  DllCall("Advapi32.dll\LookupPrivilegeValueA", "UInt", 0, "Str", "SeDebugPrivilege", "UIntP", luid)
  NumPut(luid, ti, 4, 8)
  NumPut(2, ti, 12, 4)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
  DllCall("Advapi32.dll\AdjustTokenPrivileges", "UInt", t, "Int", false, "UInt", &ti, "UInt", 0, "UInt", 0, "UInt", 0)
  DllCall("CloseHandle", "UInt", h)  ; close this process handle to save memory
  hModule := DllCall("LoadLibrary", "Str", "Psapi.dll")  ; increase performance by preloading the libaray
  s := VarSetCapacity(a, s)  ; an array that receives the list of process identifiers:
  DllCall("Psapi.dll\EnumProcesses", "UInt", &a, "UInt", s, "UIntP", r)
  Loop, % r // 4  ; parse array for identifiers as DWORDs (32 bits):
    {
      id := NumGet(a, A_Index * 4)
      ; Open process with: PROCESS_VM_READ (0x0010) | PROCESS_QUERY_INFORMATION (0x0400)
      h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id)
      VarSetCapacity(m, s)  ; an array that receives the list of module handles:
      DllCall("Psapi.dll\EnumProcessModules", "UInt", h, "UInt", &m, "UInt", s, "UIntP", r)
      VarSetCapacity(n, s, 0)  ; a buffer that receives the base name of the module:
      e := DllCall("Psapi.dll\GetModuleBaseNameA", "UInt", h, "UInt", m, "Str", n, "Chr", s)
      DllCall("CloseHandle", "UInt", h)  ; close process handle to save memory
      If n  ; if image is not null add to list:
      l = %l%%n%%d%
    }
  DllCall("FreeLibrary", "UInt", hModule)  ; unload the library to free memory
  ; Remove the first and last items in the list (possibly ASCII signitures)
  StringMid, l, l, InStr(l, d) + 1, InStr(l, d, false, 0) - 2 - InStr(l, d)
  StringReplace, l, l, %d%, %d%, UseErrorLevel  ; gets the number of processes

  ;Sort, l, C  ; uncomment this line to sort the list alphabetically
  SB_SetText("Processes: " Errorlevel)

  varsetcapacity(memorystatus,512)
  DllCall("kernel32.dll\GlobalMemoryStatus", "uint",&memorystatus)
  mem:=*(&memorystatus+4) ; LS byte is enough, mem = 0..100
  mem := (mem/100)
  SB_SetText("Memory Usage: " mem `%,3)
  Return

GetSystemTimes()    ; Total CPU Load
  {
    Static oldIdleTime, oldKrnlTime, oldUserTime
    Static newIdleTime, newKrnlTime, newUserTime

    oldIdleTime := newIdleTime
    oldKrnlTime := newKrnlTime
    oldUserTime := newUserTime

    DllCall("GetSystemTimes", "int64P", newIdleTime, "int64P", newKrnlTime, "int64P", newUserTime)
    Return (1 - (newIdleTime-oldIdleTime)/(newKrnlTime-oldKrnlTime + newUserTime-oldUserTime)) * 100
  }

;<=====  Show/Hide  =====>
HideTek:
  If TekID <> -1
    {
      WinHide, ahk_id %TekID%
    }
  Return

ShowTek:
  If TekID <> -1
    {
      WinShow, ahk_id %TekID%
      WinActivate, ahk_id %TekID%
      ControlFocus, Edit1, ahk_id %TekID%
    }
  Return

^!x:: ;Change this to Show/Hide with desired hotkey.
  IFWinExist, ahk_id %TekID%
    {
      GoSub, HideTek
      Return
    }
    DetectHiddenWindows, ON
    IFWinExist, ahk_id %TekID%
      GoSub, ShowTek
    DetectHiddenWindows, OFF
  Return


And the AHKLogo (add to the Resources folder)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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