Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: VBscript to get Image ip camera Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
nick7920
Senior Member
Senior Member


Joined: March 04 2008
Location: United States
Online Status: Offline
Posts: 193
Posted: September 24 2011 at 11:36 | IP Logged Quote nick7920

I have this vbscript to get the image from the ipcamera which runs fine. If I use the ph_run it works fine, but using ph_runscript_0 it seems to get the image from cache and it will get new one after long time ,seems like it left the connection open. It may be working for ph_run because when you are done, it closes the command window and that will close the connection. Can someone look at the Vb code and point me to right direction.

ph_run code
ph_run('cmd /c "c:\sendemail\vb\getcam.vbs"')

------------------------------------------------
Option Explicit
Dim DataBin
Dim HTTPGET
Set HTTPGET = CreateObject("Microsoft.XMLHTTP")
HTTPGET.Open "GET","http://XX.XX.XX.XX/snapshot.cgi?user=test&pwd=test", False
HTTPGET.Send
DataBin = HTTPGET.ResponseBody
Const adTypeBinary=1
Const adSaveCreateOverWrite=2

Dim SendBinary
Set SendBinary = CreateObject("ADODB.Stream")
SendBinary.Type = adTypeBinary
SendBinary.Open
SendBinary.Write DataBin
SendBinary.SaveToFile "c:\powerhome\web\IPsnapshot.jpg", adSaveCreateOverWrite
---------------------------------------------------------

and code for ph_runscript_0
ph_runscript_0(0, "c:\sendemail\getipsnap.vbs","sub1")

@language="vbscript"
Sub sub1()

Dim DataBin
Dim HTTPGET
Set HTTPGET = CreateObject("Microsoft.XMLHTTP")

HTTPGET.Open "GET","http://xx.xx.xx.xx/snapshot.cgi?user=test&pwd=test", False
HTTPGET.Send
DataBin = HTTPGET.ResponseBody
Const adTypeBinary=1
Const adSaveCreateOverWrite=2
Dim SendBinary
Set SendBinary = CreateObject("ADODB.Stream")
SendBinary.Type = adTypeBinary
SendBinary.Open
SendBinary.Write DataBin
SendBinary.SaveToFile "C:\powerhome\web\IPsnapshot.jpg", adSaveCreateOverWrite
     ph.usermessage("Getipsnap from vb script")

HTTPGET.abort

End Sub
-------------------------------------------------------
again it seems like more of a Vbscript command to close the connection than powerhome.


Thanks for any help
P.S. any one who has the foscam Ip camera can use this code and will to do the job, except my little short coming till the fix. right now using from Ph_run.



Back to Top View nick7920's Profile Search for other posts by nick7920
 
nick7920
Senior Member
Senior Member


Joined: March 04 2008
Location: United States
Online Status: Offline
Posts: 193
Posted: September 24 2011 at 14:51 | IP Logged Quote nick7920

I think I got it, I will test more but for now I change to

Set HTTPGET = CreateObject("MSXML2.ServerXMLHTTP") and seems to work.
Back to Top View nick7920's Profile Search for other posts by nick7920
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum