Results 1 to 39 of 39

Thread: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Dear Expert,

    Anyone could help me please...I want to make a pop up message that would be appeared after my notebook battery was fully charged and also with its sound...My question is: How to create a pop up message for that with its sound please...????

    Thanks very much for your helps..

    Best Regards,

    Jennifer

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    in short, using the system info control,

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Timer1.Interval = 5000
    4.  
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8.  
    9.     If SysInfo1.BatteryLifePercent >= 100 Then
    10.         MsgBox "charged"
    11.         MediaPlayer1.FileName = App.Path & "\charged.wav"
    12.         Timer1.Enabled = False
    13.     End If
    14.  
    15. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    Thanks for your reply...sorry, I am newbie for VB 6...If you dont mind, I have several questions:

    1. What do you mean about the Systems Controls..??..
    2. With your code, you mean...I write all your code into a VB 6..??..(or in windows somewhere..??) and after wrote codes, do I need to create an exe file..??..or what..???

    What I really mean is..everytime I am charging my notebook battery, it will pop up a message to let me know that the battery was fully charged...

    Sorry for this silly questions...I just want to make sure....

    Thanks a lot for your helps...

    Jennifer
    Last edited by zach007; Jan 3rd, 2006 at 03:53 AM. Reason: something miss...

  4. #4
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    Thanks for your reply...sorry, I am newbie for VB 6...If you dont mind, I have several questions:

    1. What do you mean about the Systems Controls..??..
    2. With your code, you mean...I write all your code into a VB 6..??..(or in windows somewhere..??) and after wrote codes, do I need to create an exe file..??..or what..???

    What I really mean is..everytime I am charging my notebook battery, it will pop up a message to let me know that the battery was fully charged...

    Sorry for this silly questions...I just want to make sure....

    Thanks a lot for your helps...

    Jennifer
    1) The systems info control is an activeX (ocx) Control that should be on your computer. You right click on the toolbox, select components and look for the system info control and add it.

    2) VB 6.0 is fine. After you write your code compile it into an EXE after that you have the choice of having the program run all the time or run it when yu start charging and stop after charging is done.

    Do you have VB6.0?

  5. #5
    Lively Member
    Join Date
    Dec 2005
    Posts
    124

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Thats a great idea Jmacp, but I've got one qestion how can I find other systems info/activeX controls? they sound like great fun

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    Yes...I have VB 6....By the way...it is s good idea.."running when start charging and informing when the battery is fully charged.."....What should I do then to create that one...would you please provide me a walktrough...???..Please...??

    Thanks very much for your kind helps...

    Jennifer

  7. #7
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    Yes...I have VB 6....By the way...it is s good idea.."running when start charging and informing when the battery is fully charged.."....What should I do then to create that one...would you please provide me a walktrough...???..Please...??

    Thanks very much for your kind helps...

    Jennifer

    Maybe somebody with a laptop might write it just to double check that eveything works.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    What should I do..???..Should I start with VB 6..??..or I write somewhere in the Windows XP..???...Please let me know...I dont know what do you mean in the last post....I really need helps....

    Thanks a lot,

    Jennifer

  9. #9
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Do you have a sound file you want played when its charged, like a wav or mp3 etc..?

  10. #10
    Lively Member
    Join Date
    Dec 2005
    Posts
    92

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    What should I do..???..Should I start with VB 6..??..or I write somewhere in the Windows XP..???...Please let me know...I dont know what do you mean in the last post....I really need helps....

    Thanks a lot,

    Jennifer

    from what I understand, write
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Timer1.Interval = 5000
    4.  
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8.  
    9.     If SysInfo1.BatteryLifePercent >= 100 Then
    10.         MsgBox "charged"
    11.         MediaPlayer1.FileName = App.Path & "\charged.wav"
    12.         Timer1.Enabled = False
    13.     End If
    14.  
    15. End Sub

    in any old form you created, just place a timer, some controls (project> components) and then compile it to an .exe like he said.

    dont write this stuff somewhere in windows, you're creating a program yourself, then run it when you start charging.

    this is from what i understand, im not too good with the active X stuff

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Thank you for all your helps....Please let me try first...

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    I just follow your advice:

    Create STANDARD EXE file --> go to "Component" --> and only "System Monitor Control appeared....I could not find "System Information Control".....

    I am using VB 6...

    Please help me..

    Thanks,

    Jennifer

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi...

    I have got the Sys Info Control......however, when I follow your code...how to test it...????...would you please check into my codes..???...to see if there is something miss..???

    Thanks for your kind helps..

    Jennifer
    Attached Files Attached Files

  14. #14
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi...

    I have got the Sys Info Control......however, when I follow your code...how to test it...????...would you please check into my codes..???...to see if there is something miss..???

    Thanks for your kind helps..

    Jennifer

    You need a wav file and name it charged.wav, any wav file will do, and put it in a folder with the compiled exe, has to be in the same folder. Then compile the exe and run it. The form will popup on your screen . Then charge your battery and when the battery gets fully charged see if the mesagebox pops up and sound plays. I dont have a laptop and am just posting the code i think will work, it might need some tweaking but you can test it yourself, might take an hour or two

    You need to add the windows media player componet to your form and put an on error resume next in the timer sub.

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Timer1.Interval = 2000
    4.  
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8. On Error Resume Next
    9.  
    10.     If SysInfo1.BatteryLifePercent >= 100 Then
    11.        
    12.         MediaPlayer1.FileName = App.Path & "\charged.wav"
    13.         MsgBox "charged"
    14.        
    15.     End If
    16.  
    17. End Sub

    See if that works first of all then you can add things to it..

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    What should I change in this code in order my sound will be changed with the new one....

    VB Code:
    1. MediaPlayer1.FileName = App.Path & "\charged.wav"

    My new sound is filed in this place: C:\WINDOWS\Media\notify.wav...and I want this sound to be hear...

    Please help me..

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    What should I change in this code in order my sound will be changed with the new one....

    VB Code:
    1. MediaPlayer1.FileName = App.Path & "\charged.wav"

    My new sound is filed in this place: C:\WINDOWS\Media\notify.wav...and I want this sound to be hear...

    Please help me..
    If you want to use your own wave file, then insert the path and name of your wave file in place of the one in the example.
    VB Code:
    1. MediaPlayer1.Filename = "c:\windows\media\notify.wav"

  17. #17
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Another thing, this is just like a draft, if it works you can add to it.

    Actually you'd better put timer1.enabled = false in there.

    I've attached a project.

    Make a folder on your desktop and call it battery.

    Click start, then, find files, then type in notify.wav in the search box. When the file appears in the results list, right click it and choose copy, then paste the notify.wav into the battery folder.

    Open up the project i attached and compile it into the battery folder. If you get compile errors post back here, it will probably be to do with the media player component.

    Then double click the EXE you just made, stick in the charger and make a pot of tea.
    Attached Files Attached Files

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    It said like this:

    "Compile error: Method or data member not found."

    Yellow highlight: Private Sub Timer1_Timer()
    Blue highlight: .FileName

    Have you try it before..??

  19. #19
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    It said like this:

    "Compile error: Method or data member not found."

    Yellow highlight: Private Sub Timer1_Timer()
    Blue highlight: .FileName

    Have you try it before..??


    I've attatched a new project, this one uses a different way to play the sound using API.


    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

    follow the same steps as above.^
    Attached Files Attached Files

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    Thanks for your helps...it works....However, how to make it automatically play without double click on the .EXE file please...???...What I mean is, I would like this program runs automatically...For an example, everytime I charge my battery....this program will automatically notice me when it is fully charged...something like that....

    Would you help me please...???

    Jennifer

  21. #21
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    Thanks for your helps...it works....However, how to make it automatically play without double click on the .EXE file please...???...What I mean is, I would like this program runs automatically...For an example, everytime I charge my battery....this program will automatically notice me when it is fully charged...something like that....

    Would you help me please...???

    Jennifer
    Do do something like this you would have to execute your program every time your machine was booted. You would have to have a timer event in the program that would poll the batter every so often to check its state, but only actually do something if it is fully charged.

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi Hack,

    What do you mean by that..??..You mean that I need to click (to run the program) everytime this machine was booted..????...Is that what you mean...???

  23. #23
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    Thanks for your helps...it works....However, how to make it automatically play without double click on the .EXE file please...???...What I mean is, I would like this program runs automatically...For an example, everytime I charge my battery....this program will automatically notice me when it is fully charged...something like that....

    Would you help me please...???

    Jennifer
    hmm... well you can have it running all the time, just make a shortcut for it and put that shortcut in your startup folder or... if your nice to it might open by itself everytime you start charging and finally you could open it manually everytime you start to charge the battery. I would have it run 24/7 and see how it goes.

    Add some system tray code and have an icon for it display like the clock does in the bottom right of your screen. You can then make the form invisible.

    Its coded to show a msgbox and play a sound when the battery is fully charged but you must first test it to see if this works.

    What country are you from by the way ?

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    Thanks for your helps....it is works...but manually...I really newbie in VB 6....that is why I really need your helps...my questions are:

    How to make it open itself everytime I start charging please...???..can I have the code please...???

    By the way, I already make the form invisible.....hmmm, what country are you from anyway..???

  25. #25
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by Jmacp
    if your nice to it might open by itself everytime you start charging and finally you could open it manually everytime you start to charge the battery.
    I'm not seeing how this could happen unless you have another program that actually starts the charging. Then, it could call the other, but if all you are doing is plugging the laptop into a battery charger, then it has no way of either knowing it should start this program, and, even if it did somehow know, it wouldn't know how to start it. It is just a battery charger.

  26. #26
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Hi,

    Thanks for your helps....it is works...but manually...I really newbie in VB 6....that is why I really need your helps...my questions are:

    How to make it open itself everytime I start charging please...???..can I have the code please...???

    By the way, I already make the form invisible.....hmmm, what country are you from anyway..???

    You cant make it start evertime you start charging you need either 1) user input..i.e.. click a button or 2) have it running all the time.

    If you want it running all the time then right click the EXE and select 'create shortcut' then... right click start and choose explore that should take you to the startup folder, now right click the shortcut you just made and select cut...then paste that shortcut into the startup folder. That will have it running everytime you boot up.

  27. #27
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by Jmacp
    If you want it running all the time then right click the EXE and select 'create shortcut' then... right click start and choose explore that should take you to the startup folder, now right click the shortcut you just made and select cut...then paste that shortcut into the startup folder. That will have it running everytime you boot up.
    Exactly...and in addition to this, your program would need to contain code in a timer that would fire every X amount of time to check the existing state of the battery.

  28. #28
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by Hack
    I'm not seeing how this could happen unless you have another program that actually starts the charging. Then, it could call the other, but if all you are doing is plugging the laptop into a battery charger, then it has no way of either knowing it should start this program, and, even if it did somehow know, it wouldn't know how to start it. It is just a battery charger.

    if your nice to it might open by itself everytime you start charging
    Shouldn't have said that it was a bit of sarcasism

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    So...the conclusion...we could not make this program runs automatically ya..???

  30. #30
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    So...the conclusion...we could not make this program runs automatically ya..???
    Sure you can. You can put the path/name in the registry so it boots everytime the laptop does and just have it sit there and monitor the battery status.

    However, if you are asking if you can have it run automatically everytime the battery is being charged, the answer is no.

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by Hack
    Sure you can. You can put the path/name in the registry so it boots everytime the laptop does and just have it sit there and monitor the battery status.
    Sorry...what do you mean about this..????...Is that what you mean..when I put the path/name in the registry so my program will monitor the battery status...???...is that right...???

  32. #32
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    Sorry...what do you mean about this..????...Is that what you mean..when I put the path/name in the registry so my program will monitor the battery status...???...is that right...???
    It is so your program will start automatically at boot time. What it does when it starts depends on your code.

    Use regedit and navigate to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    Add the full path and exe name of your program to that key.

  33. #33
    Hyperactive Member Private_sub's Avatar
    Join Date
    Nov 2005
    Location
    +31
    Posts
    368

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    The battery popup doesn't work with me...

  34. #34

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    What do you mean by "add the full path" please..???..is this a folder of the program...???...or just the full path of the .EXE file...????...would you please explain by walktrough please...???...or provide me example for those..???..because, sorry...i really dont know what it means....
    Last edited by zach007; Jan 4th, 2006 at 10:12 AM.

  35. #35
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by zach007
    What do you mean by "add the full path" please..???..is this a folder of the program...???...or just the full path of the .EXE file...????
    Yes, your .Exe program resides in a folder on your hard drive. The path is where it is located. Example:

    c:\program files\laptop\ would be the path
    zach007.exe would be the program name

    so, the full path and program name would be: c:\program files\laptop\zach007.exe and that is what needs to be entered into that registry key.

  36. #36
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    I might be able to get a laptop later on today and try it out.

  37. #37

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    185

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Hi,

    Just near to finish...which one on registry "Run" should I add:

    Key, String Value, Binary Value, DWORD Value, MultiString Value, or Expandable String Value...????....

    Thanks...

  38. #38
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    Quote Originally Posted by Jmacp
    I might be able to get a laptop later on today and try it out.
    It works great. I have a company laptop and my own personal laptop and both of them have the path/exe name to my code library in that key so it gets fired up everytime I boot.

  39. #39
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: Please help me..create a pop up message (Battery is Full) with VB for Win XP...

    I just put a short cut to the exe in my startup folder and it works fine for my laptop. Didnt have to tweek a thing (besides the location of the sound file). zach007, if your still having trouble let me know. Its rather simple to do if you follow Jmacp directions.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width