0

I need to position the popup boxes towards the top right corner but just below the close minimize and maximize buttons.

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

Do

   set oLocator = CreateObject("WbemScripting.SWbemLocator")
set oServices = oLocator.ConnectServer(".","root\wmi")
set oResults = oServices.ExecQuery("select * from batteryfullchargedcapacity")
for each oResult in oResults
   iFull = oResult.FullChargedCapacity
next

while (1)
  set oResults = oServices.ExecQuery("select * from batterystatus")
  for each oResult in oResults
    iRemaining = oResult.RemainingCapacity
    bCharging = oResult.Charging
  next
  iPercent = ((iRemaining / iFull) * 100) mod 100
  if bCharging and (iPercent > 80) Then msgbox "Battery is charged now more than 80%. Please stop charging for optimal battery life."
  if bCharging and (iPercent < 20) Then msgbox "Battery is discharging and is below 20%. Please switch on charging immediately."

if bcharging then
CreateObject("WScript.Shell").Popup "Charging", 1, "Charging status"
else
end if
if not bcharging then
CreateObject("WScript.Shell").Popup "Not charging", 1, "Charging status"
end if
wend
WScript.Quit 1
    WScript.Sleep 0
Loop



I've tried testing different scripts to position it, but they never work.

1 Answers1

0

The script needs to be written as an HTA in order to have a display that remains on screen, in a desired position, and updates on an interval.

See Battery.hta for an example.

LesFerch
  • 1,540
  • 2
  • 5
  • 21