Please login or register.

Login with username, password and session length
Pages: [1] 2

Author Topic: Super Simple VB6 script for triggering?  (Read 26165 times)

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Super Simple VB6 script for triggering?
« on: September 14, 2008, 08:01:08 PM »

Been looking through the forum for how to make a simple X-10 trigger that is a form compiled to .exe, that when launched sends a single command and then closes.

I am posting this thread and see that I have left the code I started to work on ...on a pen drive that I can't get back till tuesday.... so I will have to post later....but what I had is maybe 5 lines of code.

If anybody has an example please post it would be great ..... or wait and I can show what I had done so far. Reference library has been made the calls that I believe are right are being done...but I get error...must be somthing simple I am thinking

Thanks!
« Last Edit: September 14, 2008, 08:02:46 PM by kyleg »
Logged

Elvis666

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 20
  • X10 Beginner - Computer Old-Timer
Re: Super Simple VB6 script for triggering?
« Reply #1 on: September 15, 2008, 03:28:50 PM »

Why not just create a one line batch file?
Logged
Coding since 1979

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #2 on: September 16, 2008, 08:34:49 PM »

wanted to actually choose the icon for the trigger as well. Also may want to detect a motion detector and trigger a module later on after getting a good feel for it...so what to try and get the simple VB script to work. I will look at the batch method.

Here is what I have so far as the script



Option Explicit
Dim WithEvents ActiveHomeObj As ActiveHomeScriptLib.ActiveHome


Private Sub Form_Load()
    Set ActiveHomeObj = New ActiveHome
    ActiveHomeObj.SendAction("sendplc", "a1 off")
    Application.Exit()
End Sub





Thanks
« Last Edit: September 16, 2008, 08:44:40 PM by kyleg »
Logged

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #3 on: September 28, 2008, 03:03:46 PM »

Anyone have a simple example in VB6 for the simple triggers described in this thread?

just want to call a command for starters

want to have it go right after the form loads and then close down imediately after. Examples shown so far through out the forum seem to be much more in depth...want to just get a feel for a simple command from VB6 first.

Rabbit, do you have any examples of a few lines of code for this? I see some of your work in VB6 and will try to break it down and see if I can get my hands on it...but any pasted code or source files that other more knowledgable VB6 users may have,  would be greatly appreciated.

Thanks
Logged

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: Super Simple VB6 script for triggering?
« Reply #4 on: September 29, 2008, 07:55:21 PM »

If you upgrade to VB express 2008, I can give you lots of VB code snipets.

Many VB6 projects will convert automatically when you try and open them in VB 2008 express, so your old projects may work with minimal hassles.

Once in a while I find VB6 code on the net and then try and open it in VB 2008 express.
Sometimes the conversion goes without a hitch and sometimes it fails.
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #5 on: September 30, 2008, 06:20:24 PM »

EL34,

Any code would be appreciated even if it is VB08. I think a buddy has it I can try or maybe see if I can figure out the VB6 equiv.

Sounds like they are very different?....To be honest have not used 08 version, but I am sure it has advantages...Heard it as more of a true OOP but have not gone advanced on a lot of things yet with VB in general.

...well let me know if you can post some code and I can try to see if I have better luck.

Rabbit, I did play around with your cm15_exerciser (for VB6) and its nice but would you happen to have the source file I could see what I am doing wrong?

Thanks to all replying
Kyle
Logged

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: Super Simple VB6 script for triggering?
« Reply #6 on: October 01, 2008, 05:27:23 AM »

Imports ActiveHomeScriptLib

Public Class X10

    ' load form
    Private Sub motion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ActiveHomeObj = New ActiveHome


    'send your x10 command here and then exit program

            ' module name example would be a16 or g9, etc
            ' action variable  example = a1 off
            Action = Modulename & " off"
            Action = Modulename & " on"
 

        'This command will turn on or off X10 devices using action variable contents
        ActiveHomeObj.SendAction("sendplc", Action)


        Exit application

    End Sub




    ' nifty code snippet
    'This is an X10 traffic event handler. It will montor x10 traffic and print the results in a textbox
    Sub ActiveHomeTrafficAction(ByVal bszRecv As Object _
                            , ByVal vParm1 As Object _
                            , ByVal vParm2 As Object _
                            , ByVal vParm3 As Object _
                            , ByVal vParm4 As Object _
                            , ByVal vParm5 As Object _
                            , ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction

        ActiveHomeTraffic = (bszRecv & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5)
        AHEvents = bszRecv & " - " & vParm1 & " - " & vParm2
        AHEvents = AHEvents & vbCrLf

        ' Print X10 events in a textbox
        TextBox1.AppendText(AHEvents)
    End Sub
« Last Edit: October 01, 2008, 05:38:53 AM by EL34 »
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #7 on: October 02, 2008, 09:26:13 PM »

thanks el34,


I'll give these a try
Logged

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #8 on: October 03, 2008, 05:34:12 PM »

EL34,

I tried your code for both VB6 and VB2008 and have no luck. This

issue is with the Activehomeobj and getting it to initiate. I am

I am thinking this should be similar to calling the phigit library for the phigits electronics that you can program for

The method looks the same.

Here is the order I use

1. reference the SDK library
2. create an instance of it
3. use the instance in a command line to call the house code

Please excuse my verbage of terms as I use differnt languages and VB is the most new.

All I want to have happen now is load a forum, run the on command instantly.

your code references the library as a class? Does the class that references the library need to be made as a serperate class file? or

is this all in the same form? Does the class need a end class line? or was that meant to be a comment?

part of me thinks it is the way I call the library and object that I have wrong.


If I hardcode the housecode and use your script, I am thinking it would be this:

Public Class X10

    ' load form
    Private Sub motion_Load(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles MyBase.Load
        ActiveHomeObj = New ActiveHome

        ActiveHomeObj.SendAction("sendplc", "A1 on"))

    End Sub

I also tried what I was doing before ......but then again neither work:



    ' load form
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles MyBase.Load
        ActiveHomeObj = New ActiveHome

        ActiveHomeObj.SendAction("sendplc", "A1 on")

    End Sub

what is motion_load that you used in yours?


In looking through these forums under VB stuff, there is so many different versions of the send command I am not sure which is the right one I have seen

ActiveHome.SendAction
ActiveHome1.SendAction
ActiveHomeObj.SendAction

maybe the naming of the object/instance matters? I thought I saw someone say it had to be ActiveHome1 to work?

Thanks in advance for all who replay. I really appreciate it. This should be a 50 sec. thing I am thinking, but unfortunately I have been fooling around with it for about 5 hours over now the course of a week.... uhhhhh!!..pretty frustrating really cause this has to be so simple.

I almost wish I could see an actual project file that works so I can see what is missing.

Would anybody reading this, happen to have a project file VB6 or VB08 with its acconpaning form files that I could see?

Regards
Kyle




« Last Edit: October 05, 2008, 10:02:16 PM by kyleg »
Logged

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #9 on: October 07, 2008, 08:35:54 PM »

Anyone able to shed some light on the October 3 post?
Logged

hkactive

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 50
Re: Super Simple VB6 script for triggering?
« Reply #10 on: October 12, 2008, 08:19:37 PM »

You'll need to load the Reference to ActiveHomeScript 1.0 type library
This is what I do in VB6 and it works for me.

You could also drop the ActiveHome Control on the form: you have to add it with the components first, though. That's probably what that guy meant when he said to use the ActiveHome1: that's the name it's automatically given if it's dropped on the form. The control works in much the same way as just using a reference. The following code is using the reference to the library.

Code: [Select]
Option Explicit
Private WithEvents myActiveHome as ActiveHome

Private Sub Form_Load ()
  On error goto ActiveHome_ERROR
  Dim lngReturn as long 
  set myActiveHome = New ActiveHome
 
  lngReturn = myActiveHome.queryplc ("a1 on")
 
  If lngReturn = 1 then
    myActiveHome.sendaction "sendplc", "a1 off"
  Else
    myActiveHome.sendaction "sendplc", "a1 on"
  EndIf
  Exit sub
ActiveHome_ERROR:
  msgbox err.description, vbInformation, "Error"

End Sub

Private Sub myActiveHome_RecvAction(ByVal bszAction As Variant, ByVal bszParm1 As Variant, _
   ByVal bszParm2 As Variant, ByVal bszParm3 As Variant, ByVal bszParm4 As Variant, ByVal bszParm5 As Variant, ByVal bszReserved As Variant)
 
  ' the bszAction should be recvplc, recvrf, etc.
  ' the bszParm1 should be the House Address: e.g. a1, b12, etc.
  ' bszParm2 should be the state: e.g. on, off, etc.
  ' You can figure out the others
  Debug.Print bszAction, bszParm1, bszParm2, bszParm3, bszParm4, bszParm5, bszReserved
End Sub
« Last Edit: October 12, 2008, 09:01:02 PM by hkactive »
Logged

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: Super Simple VB6 script for triggering?
« Reply #11 on: October 13, 2008, 06:43:33 AM »

The code below does work, I tested it
I zipped up the 2008 VB express project and attached it to this post as testx10.zip.txt
The forum does not allow .zip extentions, so I added .txt to the end

It's a simple example that displays x10 traffic in a textbox
If you have a cm15a on the same computer and you generate x10 traffic, it should display in the textbox.

I attached a screen shot of the program running.

Quote
Imports ActiveHomeScriptLib
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ActiveHomeObj = New ActiveHome
    End Sub


    'This is an X10 traffic event handler for the receive action
    Sub ActiveHomeTrafficAction(ByVal bszRecv As Object _
                            , ByVal vParm1 As Object _
                            , ByVal vParm2 As Object _
                            , ByVal vParm3 As Object _
                            , ByVal vParm4 As Object _
                            , ByVal vParm5 As Object _
                            , ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction

        ActiveHomeTraffic = (bszRecv & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5)
        AHEvents = DateString & " - " & TimeString & " - " & bszRecv & " - " & vParm1 & " - " & vParm2
        AHEvents = AHEvents & vbCrLf
        TextBox1.AppendText(AHEvents)

    End Sub


    Dim WithEvents ActiveHomeObj As ActiveHomeScriptLib.ActiveHome
    Dim ActiveHomeTraffic
    Dim AHEvents As String

End Class
« Last Edit: October 13, 2008, 06:49:43 AM by EL34 »
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: Super Simple VB6 script for triggering?
« Reply #12 on: October 14, 2008, 10:02:13 PM »

thanks guys....I'll give these a shot
Logged

parag0n

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 8
Re: Super Simple VB6 script for triggering?
« Reply #13 on: October 24, 2008, 07:53:34 PM »

How are you coming with this?  I'm pretty good at VB6.
Logged

jrwhit

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 39
Re: Super Simple VB6 script for triggering?
« Reply #14 on: November 19, 2008, 02:53:47 AM »

Thanks for the code EL34. I have installed VB Express 2008 and was able to run your code and view some X10 Pro commands after sending. Does your offer to share some more code still stand? I have dabbled in VB but am interested in learning more about controllling X10 modules with it. Look foward to more posts.
Logged
Pages: [1] 2
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.