AutoHotkey Community

It is currently May 26th, 2012, 9:14 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: July 5th, 2009, 10:20 am 
or: http://www.autohotkey.com/forum/topic39033.html


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 1:51 pm 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
Thanks for your attempt. That A_Ping thing gives me error and da other one is not working ;(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 2:36 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 7:38 pm 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
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 ;(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 9:43 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 11:26 pm 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
hey mate, thanks a lottt. after upgrading to the latest version, its working fine :D 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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2009, 12:21 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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. :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2009, 7:17 am 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
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 ;(
Code:
#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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2009, 7:20 am 
say, did you try to write at least one line of code yourself?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2009, 9:43 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Here, try this (untested):
Code:
#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:

Code:
[...]
   DllCall("GetSystemPowerStatus", "UInt", &sps)
   if !NumGet(sps, 0, "char")
     SetTimer, ShowMsgBox, -10
[...]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2009, 11:57 am 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
wow, just amazing, thanks a lot Drugwash, u have done it!!!! :D now my mission is to combine them both to make a single .exe file :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2009, 10:07 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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! ;)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2009, 11:57 pm 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
trying :cry: ;'(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2009, 12:00 am 
Offline

Joined: April 4th, 2008, 8:15 pm
Posts: 538
Location: Canada
Hope your teacher doesn't ask for a fully commented script :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2009, 12:29 am 
Offline

Joined: May 29th, 2009, 8:05 am
Posts: 17
errm.... dont scare me nemore ;@@ i m already enuff stressed abt dis ;( jus wana get over it anyhow


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Exabot [Bot], krajan, patgenn123, wolverineks and 62 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group