Running script issue

Me again :smile: I seem to be having an issue with having a set of scripts run before and after an event. What my goal is to slew to the flat box position and take flats and then “unpark”. Below is the vbs script:

set scope = CreateObject(“Celestron.Telescope”)
scope.Connected = true
scope.Tracking = false
scope.Connected = false

My initial thought here at work away from the scope is that I only need the scope.tracking and scope.slewtoaltaz lines since I am already connected to the mount in SGP via the Celestron ASCOM driver. The “unpark” script simply sets the scope.tracking = true, but with the set scope, scope.connected statements wrapping it.

I went through the SGP debug logs at lunch and it shows nothing out of the ordinary, but looking at my flats, it is of the object (M51) I was imaging, so I know it did not work. On the bright side, the park command worked perfect and the end of the sequence and my scope was sitting there parked, waiting for me to hibernate it.

Scripts are kicked off in their own process. Therefore they have no idea or access to anything in SGP.

Does your script behave like you would like if you run it on it’s own?


For whatever reason, the script does not work on its own. I could of swore it did. Regardless, it seems to be the problem here. Hoping to find some info why the latest Celestron ASCOM driver is not liking the SlewToAltAz command.

Just a quick update. I did sort out my script issues and now it will go to the position I need it to and then stop tracking by running the vbs file. But when I use the same script file in the SGP sequence as mentioned above, it does nothing. Just goes to running the flats in whatever position it currently is in. Is there anything I can do now to further diagnosis this?

If you can send me the script I can debug it and see if something isn’t happening. You can also add some logging to your script to see if it’s getting executed or maybe add some exception handling to it to see if it’s throwing an exception.


Jared, I attached my vbs script(had to zip it to upload). I am for sure not a programmer, though a network admin, so debugging code is not my strongest suit! But like I said, it now works when run alone. Any insight would be greatly appreciated.

Pete (240 Bytes)

I can take a look this evening. One thing that stands out is that you’ll likely need to block the script. For instance your script will exit almost immediately. I think you want to wait until after the slew is complete. You’ll need to do something like:

while( tel.IsSlewing )

Normally do/while loops are considered bad programming but in this case you likely want to sleep for a tad bit and then check as the scope might take a little bit to say it’s slewing.

This will keep your script alive until the scope has stopped moving.

So I guess what is happening? Does the scope start to slew? Or does nothing happen?


I cannot detect the scope moving, I even put my NexRemote into get-Axis mode to watch the Alt/AZ readings to make sure it was stopping the tracking before it moved via the SlewToAltAz. Running the script standalone, it works, but in SGP I cannot see anything happening. But like you mentioned earlier, some logging in the script to see it is going through each line of code would be helpful.

There’s a SlewToAltAzAsync(alt, azm) command that will wait until the slew has finished before returning.

That doesn’t help with why the script isn’t doing anything from SGP.

Try having SGP running and run the script independently.
Or show a message box at the start of the script so confirm that it’s actually running.

BTW the Celestron driver will accept multiple connections.

I am pretty sure I had SGP connected and going when I ran the script independently. But I will do that again this evening to make sure. The message box is a great idea, I will add that to the script.

Ok, I have been trying a few things out as suggested above. First off the with SGP running and connected to everything, the script will run as intended. I added a msg prompt into the script also that works correctly running it standalone. When I use this script in SGP for my 2nd event (flats) as a Pre-Event option (run script) (box is checked), nothing happens. No msg prompt either.

So next I create a new script called test.vbs and add just one line for a msg prompt: MsgBox (“Hello world!”). Then I test it standalone, it works. I put it in SGP and nothing happens. Below are the three lines in the SGP log file centered on the script:

[6/6/2014 7:49:05 PM] [DEBUG] [Sequence Thread] Running event related script…
[6/6/2014 7:49:05 PM] [DEBUG] [Sequence Thread] RunVbScript: Running script: C:\Users\user\Desktop\Software\Mount stuff\test.vbs
[6/6/2014 7:49:05 PM] [DEBUG] [Sequence Thread] Running capture event…

I really do not think SGP is running it at this point. I also tried running SGP in administrator mode to rule that possibility out. I guess my next question is if anyone does have vbscripts that work as pre/post events as I am attempting. (for any purpose)

Seems to be working here. I changed your script to use the sim and tested it with the latest SGP release.

I tested Pre and Post event. Can you send me an SGF and I can try to duplicate?

You need to have the check box checked as well as the script populated.


Jared, I have attached the SGF file I was using (M51) all zipped up. I verified that the check box is checked. I went as far this morning to uninstall SGP, reboot, download the latest version again, and reinstall. Same results, it just does not want to run any scripts for me. So now I am trying to figure what could be different between us.

My observatory computer is a high-end desktop running Win7 x64, i5 processor 10GB RAM. I am pretty careful what I put on there, so the odds of some weird program or something is low.

When I write these scripts, I simple use notepad and save as {filename}.vbs, so not sure if that is right way. Do I have to run SGP in admin mode? I checked all the event logs and nothing looks wrong there. (7.6 KB)

I believe I have figured this out. It seems that the script file has to be in the directory that is defined in the “target data” area. Once I moved my test script to the “d:\data\sgp” from a folder on my desktop where I was keeping the scripts, it worked perfectly. Tonight is suppose to be clear, so I will try it with the real scripts, but I am expecting them to work.

Hm, that shouldn’t be the case…but I think the issue may have been that the path had a space in it. I’ll check that out.


I thought it was strange. So I just tried putting a test script into a subfolder in my “d:\data\sgp” directory and it did not work. For sure it has to be in that declared directory. I double checked the original problem sequence and there are no spacing in it to throw it off. Unless you are talking about something under the hood.

Update: I did a complete test of the sequence with everything connected (camera, wheel, scope, light box) with the 2 scripts in the “correct” directory and it worked great. After a quick “light frame”, the next event was flats with a pre-event script to move the scope to the lightbox position and “park”, this worked. After the flats were completed, the post-event script ran and unparked the scope. Next event was a simple bias with a post-event park, which worked. Then finally some darks were taken.

So long story short, putting the scripts in the Target Data “Directory” listed in the sequence fixed my problem of the script not being executed.

Jared, if you don’t mind me jumping in here, how would you recommend I proceed to learn enough of VB to be able to write simple scripts? I was fairly proficient with BASIC back in the dark ages, and having downloaded and installed VB, I see nothing too intimidating. But I’m not sure how to dive into it.