or: http://www.autohotke...topic39033.html
Alert when power/network cable is plugged off
Started by
Maria-
, May 26 2009 03:00 PM
59 replies to this topic
#46
-
Posted 05 July 2009 - 09:20 AM
Thanks for your attempt. That A_Ping thing gives me error and da other one is not working ;(
#47
-
Posted 05 July 2009 - 12:51 PM
What error exactly do you get with A_Ping() ? I think you have not read the first post carefully: it requires the COM library to be present in the AutoHotkey\lib folder. See the bottom of the NetCon Alert script; uncomment the last #include line once you placed COM.ahk in the lib folder.
Also, for the speech anouncement you must have a working TTS engine installed. It works with SAPI4 in Win9x and SAPI5 in Win9x and later.
Does the compiled exe in the archive work at all for you? What is your operating system?
Also, for the speech anouncement you must have a working TTS engine installed. It works with SAPI4 in Win9x and SAPI5 in Win9x and later.
Does the compiled exe in the archive work at all for you? What is your operating system?
#48
-
Posted 05 July 2009 - 01:36 PM
Complied .exe file works fine for me with voice alert. but source files aint working. when I run A_ping.ahk, it gives me this error:
Error: parameter #1 invalid.
Specifically: integerFast
Line#
..
...
This program will exit.
netcon alert.ahk also shows this error with additional another error ;(
Error: parameter #1 invalid.
Specifically: integerFast
Line#
..
...
This program will exit.
netcon alert.ahk also shows this error with additional another error ;(
#49
-
Posted 05 July 2009 - 06:38 PM
Please make sure you have latest AutoHotkey version installed. The IntegerFast and FloatFast parameters have been introduced with 1.0.48.x.
Also please make sure the function is being called correctly; the example should be pretty straightforward in this regard.
Also please make sure the function is being called correctly; the example should be pretty straightforward in this regard.
#50
-
Posted 05 July 2009 - 08:43 PM
hey mate, thanks a lottt. after upgrading to the latest version, its working fine can you help me a bit more abt power status issue? i jus need a simple sound alert [ like da one u set for network cable] only when power cable is unplugged.
#51
-
Posted 05 July 2009 - 10:26 PM
Unfortunately I do not have access to a laptop to test such script but it shouldn't be hard to patch into the speech routine of the NetCon Alert script. You'll have to rely on someone else's help on this matter though. Sorry.
#52
-
Posted 05 July 2009 - 11:21 PM
Hiyaaa
i m kinda stuck wid dis part of da program. can anyone edit it so dat it alerts only when power cable is unplugged , right now its giving alert always witch current battery status ;(
i m kinda stuck wid dis part of da program. can anyone edit it so dat it alerts only when power cable is unplugged , right now its giving alert always witch current battery status ;(
#Persistent DetectHiddenWindows, on MainID := WinExist("Ahk_PID " . DllCall("GetCurrentProcessId")) OnMessage(0x218, "WM_POWERBROADCAST") return WM_POWERBROADCAST(wparam, lparam, msg, hwnd) { Local sps If (hwnd != MainID) return VarSetCapacity(sps, 12, 0) DllCall("GetSystemPowerStatus", "UInt", &sps) ACLineStatus := NumGet(sps, 0, "char") BatteryFlag := NumGet(sps, 1, "char") BatteryLifePercent := NumGet(sps, 2, "char") BatteryLifeTime := NumGet(sps, 4, "int") BatteryFullLifeTime := NumGet(sps, 8, "int") SetTimer, ShowMsgBox, -10 } ShowMsgBox: powersource := ACLineStatus ? "AC power" : "battery power" batterystate := BatteryFlag & 8 ? "charging" : (ACLineStatus ? "fully charged" : "draining") msgbox, ( ltrim The computer is currently powered by %powersource%. The Battery is now at %BatteryLifePercent%`% and is %batterystate%. ) return
#53
-
Posted 07 July 2009 - 06:17 AM
say, did you try to write at least one line of code yourself?
#54
-
Posted 07 July 2009 - 06:20 AM
Here, try this (untested):
Of course, the code could be shortened a bit by losing the ACLineStatus variable:
#Persistent DetectHiddenWindows, on MainID := WinExist("Ahk_PID " . DllCall("GetCurrentProcessId")) OnMessage(0x218, "WM_POWERBROADCAST") return WM_POWERBROADCAST(wparam, lparam, msg, hwnd) { Local sps If (hwnd != MainID) return VarSetCapacity(sps, 12, 0) DllCall("GetSystemPowerStatus", "UInt", &sps) ACLineStatus := NumGet(sps, 0, "char") if !ACLineStatus SetTimer, ShowMsgBox, -10 } ShowMsgBox: msgbox, 0x1030, Warning!, The power cable has been unplugged! return
Of course, the code could be shortened a bit by losing the ACLineStatus variable:
[...] DllCall("GetSystemPowerStatus", "UInt", &sps) if !NumGet(sps, 0, "char") SetTimer, ShowMsgBox, -10 [...]
#55
-
Posted 07 July 2009 - 08:43 AM
wow, just amazing, thanks a lot Drugwash, u have done it!!!! now my mission is to combine them both to make a single .exe file :roll:
#56
-
Posted 07 July 2009 - 10:57 AM
My friendly advice would be for you to try your best to understand what all this is about. The way the whole world works, you're likely to stumble into this stuff sooner or later and it's best you learn something about it all.
Good luck anyways!
Good luck anyways!
#57
-
Posted 08 July 2009 - 09:07 PM
Hope your teacher doesn't ask for a fully commented script :roll:
#59
-
Posted 08 July 2009 - 11:00 PM
errm.... dont scare me nemore ;@@ i m already enuff stressed abt dis ;( jus wana get over it anyhow
#60
-
Posted 08 July 2009 - 11:29 PM