SparkSoft Posted November 26, 2010 Share Posted November 26, 2010 (edited) Ive just finished my first app Its just a simple battery bar that shows your percentage of battery with a progress bar and label I plan on making it better, but its a start right Its my first ever useful script (well to me it is) tell me anything i can improve on as im still a newbie expandcollapse popup#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $INIFile = @ScriptDir & "\Options.ini" If FileExists($INIFile) = 0 Then IniWrite($INIFile, "UIOptions", "Refresh Rate", "500") $RefreshRate = IniRead($INIFile, "UIOptions", "Refresh Rate", "500") Opt("GUIOnEventMode", 1) Global $BatteryPercent = "Please Wait... " Global $BatteryStatus = "Please Wait... " $FormWidth = 410 $FormHeight = 100 $Form1 = GUICreate("BattBar v.0.1", 386, 17, @DesktopWidth - $FormWidth, @DesktopHeight - $FormHeight);width height left top GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp") GUISetBkColor(0xC0C0C0) $Progress1 = GUICtrlCreateProgress(0, 0, 358, 17, BitOR($PBS_SMOOTH, $WS_BORDER)) GUICtrlSetColor(-1, 0x0000FF) $Progress1context = GUICtrlCreateContextMenu($Progress1) $PMenuItem1 = GUICtrlCreateMenuItem("Options", $Progress1context) GUICtrlSetOnEvent($PMenuItem1, "OptionsWindow") $PMenuItem2 = GUICtrlCreateMenu("Close...", $Progress1context) $PMenuItem3 = GUICtrlCreateMenuItem("...To Tray", $PMenuItem2) $PMenuItem4 = GUICtrlCreateMenuItem("...And Exit", $PMenuItem2) GUICtrlSetOnEvent($PMenuItem4, "ExitApp") $Label1 = GUICtrlCreateLabel("", 358, 0, 28, 17, $WS_BORDER);left top width height $Label1context = GUICtrlCreateContextMenu($Label1) $MenuItem1 = GUICtrlCreateMenuItem("Options", $Label1context) $MenuItem2 = GUICtrlCreateMenu("Close...", $Label1context) $MenuItem3 = GUICtrlCreateMenuItem("...To Tray", $MenuItem2) $MenuItem4 = GUICtrlCreateMenuItem("...And Exit", $MenuItem2) GUICtrlSetOnEvent($MenuItem4, "ExitApp") GUISetState(@SW_SHOW) While 1 $SYSTEM_POWER_STATUS = DllStructCreate("byte;byte;byte;byte;int;int") $test = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", _ "ptr", DllStructGetPtr($SYSTEM_POWER_STATUS)) $BatteryStatus = DllStructGetData($SYSTEM_POWER_STATUS, 1) If $BatteryStatus = "1" Then $BatteryStatus = "Charging" If $BatteryStatus = "0" Then $BatteryStatus = "Discharging" $BatteryPercent = DllStructGetData($SYSTEM_POWER_STATUS, 3) GUICtrlSetData($Progress1, $BatteryPercent) GUICtrlSetData($Label1, $BatteryPercent & "%") Sleep($RefreshRate) WEnd Func ExitApp() Exit EndFunc ;==>ExitApp Func OptionsWindow() ;going to do this later EndFunc ;==>OptionsWindow You can choose the refresh rate with the ini file thats created But You need to exit the xcript and start it again Edited November 26, 2010 by SparkSoft [center]First Ever Script/App[/center][center]Simple Battery Meter[/center] Link to comment Share on other sites More sharing options...
guinness Posted November 26, 2010 Share Posted November 26, 2010 Nice, it has potential. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
water Posted November 26, 2010 Share Posted November 26, 2010 You could check if the computer where the script is run has a battery. My PC (no notebook) shows 255%. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SparkSoft Posted November 26, 2010 Author Share Posted November 26, 2010 (edited) You could check if the computer where the script is run has a battery.My PC (no notebook) shows 255%.Thanks for feedbackIm aware of the 255% thing, it does it on my desktop pc and im going to change itIm going to add more features like colors for the power bar and custom actions when the battery gets to a certain percentageAlso a little tip:Compile the script and If your running vista or windows 7, change visual compatibility setting to disable visual themes, this will turn the battery bar blue again thanks for the feedback, Edited December 1, 2010 by SparkSoft [center]First Ever Script/App[/center][center]Simple Battery Meter[/center] Link to comment Share on other sites More sharing options...
Kalin Posted December 4, 2010 Share Posted December 4, 2010 (edited) - Double posting delete - Edited December 4, 2010 by Kalin Link to comment Share on other sites More sharing options...
Kalin Posted December 4, 2010 Share Posted December 4, 2010 (edited) Well... This is rather... Interesting? Also most of the function that you included in that script doesn't apply when I use it. All it does is open and automatically is set to 255%, and then creates a .ini file. And yes, I tried to compile it lol. But nice for a first app. : ) Edited December 4, 2010 by Kalin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now