Jump to content

My first ever app :)


SparkSoft
 Share

Recommended Posts

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 :graduated: (well to me it is)

tell me anything i can improve on as im still a newbie

#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 by SparkSoft

[center]First Ever Script/App[/center][center]Simple Battery Meter[/center]

Link to comment
Share on other sites

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

You could check if the computer where the script is run has a battery.

My PC (no notebook) shows 255%.

Thanks for feedback

Im aware of the 255% thing, it does it on my desktop pc and im going to change it

Im going to add more features like colors for the power bar and custom actions when the battery gets to a certain percentage

Also 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 :graduated:

again thanks for the feedback,

Edited by SparkSoft

[center]First Ever Script/App[/center][center]Simple Battery Meter[/center]

Link to comment
Share on other sites

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 by Kalin
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...