Announcement

Collapse
No announcement yet.

Remote Script Gallery

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Remote Script Gallery

    This thread is meant to present (not discuss) some of the remote scripts installed with the Script Connector plugin, and any user contributed script you may have created.
    Last edited by stipus; September 5, 2007, 02:32 AM.
    --
    stipus

    #2
    Change a Device String from a Remote Computer

    Here is a very simple script that can run on the Remote Script Client:
    Code:
    Sub Main( param as Object )
        hs.SetDeviceString( "A1", "Hello from a remote computer" )
    End Sub
    The same script, using the parameter object as the device string:
    Code:
    Sub Main( param as Object )
        hs.SetDeviceString( "A1", param )
    End Sub
    If you run from the Windows Command Line (CMD.EXE) the following command on a remote computer, A1 device string will be set to Hello ! on your HomeSeer server:
    HSSCRIPT name_of_script.vb Hello !

    Another more complex script :

    When you run this script, it displays a dialogbox on the remote computer (By the way, don't forget that if you don't have a remote computer, you can also run the HsScript.exe client on your main HomeSeer server...)

    On this dialog box, you can choose an HomeSeer device, type a device string, and click the Change Device String button...


    Code:
    #IMPORT System.Windows.Forms,System.Windows.Forms.dll
    #IMPORT System.Drawing,System.Drawing.dll
     
    Sub Main( param as Object )
        Dim MainForm as new Form1()
        Application.Run(MainForm)
    End Sub
    
    Public Class Form1
        Inherits System.Windows.Forms.Form
     
        Public Sub New()
     
            Me.Label1 = New System.Windows.Forms.Label
            Me.Button1 = New System.Windows.Forms.Button
            Me.TextBox1 = New System.Windows.Forms.TextBox
            Me.ComboBox1 = New System.Windows.Forms.ComboBox
            Me.Label2 = New System.Windows.Forms.Label
            Me.SuspendLayout()
            '
            'Label1
            '
            Me.Label1.AutoSize = True
            Me.Label1.Location = New System.Drawing.Point(31, 18)
            Me.Label1.Name = "Label1"
            Me.Label1.Size = New System.Drawing.Size(142, 13)
            Me.Label1.TabIndex = 0
            Me.Label1.Text = "Choose HomeSeer Device : "
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(80, 103)
            Me.Button1.Name = "Button1"
            Me.Button1.Size = New System.Drawing.Size(167, 23)
            Me.Button1.TabIndex = 1
            Me.Button1.Text = "Change device string"
            Me.Button1.UseVisualStyleBackColor = True
            '
            'TextBox1
            '
            Me.TextBox1.Location = New System.Drawing.Point(191, 56)
            Me.TextBox1.Name = "TextBox1"
            Me.TextBox1.Size = New System.Drawing.Size(121, 20)
            Me.TextBox1.TabIndex = 2
            '
            'ComboBox1
            '
            Me.ComboBox1.FormattingEnabled = True
            Me.ComboBox1.Items.AddRange(New Object() {"A1", "A2", "A3", "A4", "A5"})
            Me.ComboBox1.Location = New System.Drawing.Point(191, 13)
            Me.ComboBox1.Name = "ComboBox1"
            Me.ComboBox1.Size = New System.Drawing.Size(121, 21)
            Me.ComboBox1.TabIndex = 3
            '
            'Label2
            '
            Me.Label2.AutoSize = True
            Me.Label2.Location = New System.Drawing.Point(31, 59)
            Me.Label2.Name = "Label2"
            Me.Label2.Size = New System.Drawing.Size(136, 13)
            Me.Label2.TabIndex = 4
            Me.Label2.Text = "Type a new Device String :"
            '
            'Form1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(338, 157)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.ComboBox1)
            Me.Controls.Add(Me.TextBox1)
            Me.Controls.Add(Me.Button1)
            Me.Controls.Add(Me.Label1)
            Me.MaximizeBox = False
            Me.Name = "Form1"
            Me.Text = "HomeSeer Device Strings"
            Me.ResumeLayout(False)
            Me.PerformLayout()
        End Sub
    
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents Button1 As System.Windows.Forms.Button
        Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
        Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
        Friend WithEvents Label2 As System.Windows.Forms.Label
     
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            hs.SetDeviceString( ComboBox1.Text, TextBox1.Text )
        End Sub
     
    End Class
    You can also run this script from the remote computer, using the HsScript.exe command line:
    --> HsScript remote_devicestring.vb
    Last edited by stipus; September 15, 2007, 06:46 PM.
    --
    stipus

    Comment


      #3
      Easy Device Action from a Remote Computer



      Code:
      #IMPORT System.Windows.Forms,System.Windows.Forms.dll
      #IMPORT System.Drawing,System.Drawing.dll
       
      Sub Main( param as Object )
          Dim MainForm as new Form1()
          Application.Run(MainForm)
      End Sub
      Public Class Form1
          Inherits System.Windows.Forms.Form
       
          Public Sub New()
              Me.Label1 = New System.Windows.Forms.Label
              Me.DeviceTextBox = New System.Windows.Forms.TextBox
              Me.OnButton = New System.Windows.Forms.Button
              Me.OffButton = New System.Windows.Forms.Button
              Me.SuspendLayout()
              '
              'Label1
              '
              Me.Label1.AutoSize = True
              Me.Label1.Location = New System.Drawing.Point(20, 17)
              Me.Label1.Name = "Label1"
              Me.Label1.Size = New System.Drawing.Size(47, 13)
              Me.Label1.TabIndex = 0
              Me.Label1.Text = "Device :"
              '
              'DeviceTextBox
              '
              Me.DeviceTextBox.Location = New System.Drawing.Point(81, 14)
              Me.DeviceTextBox.Name = "DeviceTextBox"
              Me.DeviceTextBox.Size = New System.Drawing.Size(52, 20)
              Me.DeviceTextBox.TabIndex = 1
              Me.DeviceTextBox.Text = "A1"
              '
              'OnButton
              '
              Me.OnButton.Location = New System.Drawing.Point(12, 50)
              Me.OnButton.Name = "OnButton"
              Me.OnButton.Size = New System.Drawing.Size(55, 23)
              Me.OnButton.TabIndex = 2
              Me.OnButton.Text = "ON"
              Me.OnButton.UseVisualStyleBackColor = True
              '
              'OffButton
              '
              Me.OffButton.Location = New System.Drawing.Point(87, 50)
              Me.OffButton.Name = "OffButton"
              Me.OffButton.Size = New System.Drawing.Size(55, 23)
              Me.OffButton.TabIndex = 2
              Me.OffButton.Text = "OFF"
              Me.OffButton.UseVisualStyleBackColor = True
              '
              'Form1
              '
              Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
              Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
              Me.ClientSize = New System.Drawing.Size(156, 87)
              Me.Controls.Add(Me.OffButton)
              Me.Controls.Add(Me.OnButton)
              Me.Controls.Add(Me.DeviceTextBox)
              Me.Controls.Add(Me.Label1)
              Me.MaximizeBox = False
              Me.Name = "Form1"
              Me.Text = "Device Action"
              Me.ResumeLayout(False)
              Me.PerformLayout()
          End Sub
          Friend WithEvents Label1 As System.Windows.Forms.Label
          Friend WithEvents DeviceTextBox As System.Windows.Forms.TextBox
          Friend WithEvents OnButton As System.Windows.Forms.Button
          Friend WithEvents OffButton As System.Windows.Forms.Button
       
          Private Sub OnButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnButton.Click
            If hs.DeviceExists( DeviceTextBox.Text ) <> -1 Then
              hs.ExecX10( DeviceTextBox.Text, "On" )
            End If
          End Sub
       
          Private Sub OffButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OffButton.Click
            If hs.DeviceExists( DeviceTextBox.Text ) <> -1 Then
              hs.ExecX10( DeviceTextBox.Text, "Off" )
            End If
          End Sub
      End Class
      Last edited by stipus; September 9, 2007, 09:32 AM.
      --
      stipus

      Comment


        #4
        Remote Device Status and Action from a remote Computer

        This Script is installed as remote_mini_control.vb when you install the plugin.



        - You can choose a X10 House Code, then you get X10 device status for all devices.
        - If you click any of the small icons, the status for the device is changed (X10 command is really sent).
        - The device status is updated every 10 seconds.

        If you run this on a remote computer, you must make sure the images exist in HomeSeer 2/html/Images/HomeSeer (You can copy the images there from your main HS Server, if they are not present)

        - disabled.gif
        - on.gif
        - off.gif
        - dim.gif

        Notes:

        - You can run this script on the HomeSeer server, if you run the HsScript client on the server
        - You can launch this script from a HomeSeer event (choose Exec Remote Script event action)
        - You can launch this script from another HomeSeer script using the plugin API
        - You can launch this script from the remote computer, using the HsScript.exe command line:
        --> HsScript remote_mini_control.vb
        --
        stipus

        Comment


          #5
          Popup a remote marquee on a Remote Computer

          This script is installed with the plugin as remote_marquee.cs

          The remote_marquee.cs sample script shows a large scrolling message on the target computer. Click on the message to close it.

          HSSCRIPT remote_marquee.cs Hello from HomeSeer



          You can popup a scrolling message on a remote computer from any HomeSeer event:
          - Choose the Exec Remote Script Event action
          - Type the computer name (Remote Script Client name) in the target text box
          - Type the script name remote_marquee.cs in the Script text box.
          - Type the text to be shown in the parameter text box.
          - Apply changes and test your event !
          --
          stipus

          Comment


            #6
            Send Post-It to remote computers from HomeSeer

            This script is installed with the plugin as remote_postit.cs

            The post-it auto-sizes to the content you type as the script parameter.



            Here is the remote_postit.cs script:

            Code:
            #IMPORT System.Windows.Forms,System.Windows.Forms.dll
            #IMPORT System.Drawing,System.Drawing.dll
            void Main( object param )
            {
                PostItForm postItForm = new PostItForm( param.ToString() );
                Application.Run( postItForm );
            }
            public class PostItForm : System.Windows.Forms.Form
            {
                private Label postItLabel;
                public PostItForm( string textString )
                {
                  postItLabel = new Label();
                  postItLabel.Dock = DockStyle.Fill;
                  postItLabel.Font = new System.Drawing.Font("Verdana", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
                  postItLabel.ForeColor = System.Drawing.Color.Navy;
                  postItLabel.BackColor = System.Drawing.Color.FromArgb( 255, 255, 128 );
                  postItLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                  postItLabel.Text = textString;
                  System.Drawing.Graphics graphics = postItLabel.CreateGraphics();
                  System.Drawing.SizeF size = graphics.MeasureString(textString, postItLabel.Font);
                  int width = Convert.ToInt32( size.Width ) + 10;
                  int height = Convert.ToInt32( size.Height ) + 30;
                  while( width > 2 * height )
                  {
                    width = width / 2;
                    height = height * 2;
                  }
                  this.Width = width;
                  this.Height = height;
                  this.Text = "HomeSeer Post-It";
                  this.MaximizeBox = false;
                  this.MinimizeBox = true;
                  this.TopMost = true;
                  this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
                  this.Controls.Add( postItLabel );
                }
            }
            As usual, you can popup a post-it message on a remote computer from any HomeSeer event:

            - Choose the Exec Remote Script Event action
            - Type the computer name (Remote Script Client name) in the target text box
            - Type the script name remote_postit.cs in the Script text box.
            - Type the text to be shown in the parameter text box.
            - Apply changes and test your event !
            --
            stipus

            Comment


              #7
              Send a HomeSeer SMS From a remote Computer

              This is the first user contributed remote script by board user psampson. Many thanks to you ! Your script is very usefull !

              Here is my first remote script based heavilly on Stipus remote_devicecontrol.
              The script should work with either skype plugin (tested) or themax74 depricated .NET SMS Plugin (tested).

              remote_sendsms.vb Instructions:

              1. Copy code as script remote_sendsms.vb to homeseer 2/scripts directory on client machine.

              2. Edit 2 sections in script marked ****** to (a) set favourite destination SMS skype names or SMS numbers and (b) uncomment skype or SMS plugin line for the desired SMS method.

              3. Copy hspi_skype.dll and/or hspi_SMS.dll from HS server to the client homeseer 2 directory.

              4. Use this direct script command in a HS server trigger to pop-up SMS screen on client (substitute your own client name for Notebook):
              &hs.plugin("Script Connector").ExecScript "Notebook", "remote_sendsms.vb","dummy"

              5. You can also easily create a windows shortcut to run the SMS script from your remote computer.
              Right click on your desktop, choose New - Shortcut
              Then type the following as the shortcut target, and apply.
              "C:\Program Files\HomeSeer 2\HsScript.exe" remote_sendsms.vb
              (thanks to Stipus - this is the best way to start the SMS script)

              Note: with the SMS plugin, it takes some time (30 secs) to respond back to the client and may timeout on the client. It will send the SMS though. I Don't know how to set the timeout on the script channel to the client yet.

              cheers,
              Phil

              Code:
              #IMPORT System.Windows.Forms,System.Windows.Forms.dll
              #IMPORT System.Drawing,System.Drawing.dll
              Sub Main()
                  Dim MainForm as new Form1()
                  Application.Run(MainForm)
              End Sub
              
              Public Class Form1
                  Inherits System.Windows.Forms.Form
              
                  Public Sub New()
                      Me.Label1 = New System.Windows.Forms.Label
                      Me.Button1 = New System.Windows.Forms.Button
                      Me.TextBox1 = New System.Windows.Forms.TextBox
                      Me.ComboBox1 = New System.Windows.Forms.ComboBox
                      Me.Label2 = New System.Windows.Forms.Label
                      Me.SuspendLayout()
                      '
                      'Label1
                      '
                      Me.Label1.AutoSize = True
                      Me.Label1.Location = New System.Drawing.Point(31, 18)
                      Me.Label1.Name = "Label1"
                      Me.Label1.Size = New System.Drawing.Size(142, 13)
                      Me.Label1.TabIndex = 0
                      Me.Label1.Text = "Enter Phone Number : "
                      '
                      'Button1
                      '
                      Me.Button1.Location = New System.Drawing.Point(80, 103)
                      Me.Button1.Name = "Button1"
                      Me.Button1.Size = New System.Drawing.Size(167, 23)
                      Me.Button1.TabIndex = 1
                      Me.Button1.Text = "Send SMS Now"
                      Me.Button1.UseVisualStyleBackColor = True
                      '
                      'TextBox1
                      '
                      Me.TextBox1.Location = New System.Drawing.Point(191, 56)
                      Me.TextBox1.Name = "TextBox1"
                      Me.TextBox1.Size = New System.Drawing.Size(121, 20)
                      Me.TextBox1.TabIndex = 2
                      '
                      'ComboBox1
                      '
                      ' ******
                      ' ****** Replace "My Number 1" ..5  with your favourite outgoing SMS numbers to appear in the pulldown list.
                      ' ******
                      Me.ComboBox1.FormattingEnabled = True
                      Me.ComboBox1.Items.AddRange(New Object() {"My Number 1", "My Number 2", "My Number 3", "My Number 4", "My Number 5"})
                      Me.ComboBox1.Location = New System.Drawing.Point(191, 13)
                      Me.ComboBox1.Name = "ComboBox1"
                      Me.ComboBox1.Size = New System.Drawing.Size(121, 21)
                      Me.ComboBox1.TabIndex = 3
                      '
                      'Label2
                      '
                      Me.Label2.AutoSize = True
                      Me.Label2.Location = New System.Drawing.Point(31, 59)
                      Me.Label2.Name = "Label2"
                      Me.Label2.Size = New System.Drawing.Size(136, 13)
                      Me.Label2.TabIndex = 4
                      Me.Label2.Text = "Type SMS String to send :"
                      '
                      'Form1
                      '
                      Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
                      Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
                      Me.ClientSize = New System.Drawing.Size(338, 157)
                      Me.Controls.Add(Me.Label2)
                      Me.Controls.Add(Me.ComboBox1)
                      Me.Controls.Add(Me.TextBox1)
                      Me.Controls.Add(Me.Button1)
                      Me.Controls.Add(Me.Label1)
                      Me.MaximizeBox = False
                      Me.Name = "Form1"
                      Me.Text = "HomeSeer Send SMS"
                      Me.ResumeLayout(False)
                      Me.PerformLayout()
                  End Sub
                  Friend WithEvents Label1 As System.Windows.Forms.Label
                  Friend WithEvents Button1 As System.Windows.Forms.Button
                  Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
                  Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
                  Friend WithEvents Label2 As System.Windows.Forms.Label
              
                  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                  End Sub
                  ' ******
                  ' ****** Uncomment the plugin you are using.. either .NET Skype (hspi_skype.dll) or .NET SMS plugin (hspi_sms.dll)
                  ' ****** When using the SMS plugin, specify your SMS plugin hardware device name here (eg T68USB for me)
                  ' ******
                  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                      'hs.Plugin("Skype Connector").SendSms( ComboBox1.Text, TextBox1.Text )
                      'hs.plugin("SMS Plugin").SendSMS( ComboBox1.Text, TextBox1.Text, "T68USB")
                  End Sub
              End Class
              Attached Files
              Last edited by stipus; September 9, 2007, 11:13 AM.
              --
              stipus

              Comment


                #8
                Control individual Light Devices from a Remote Computer

                This script is installed with the plugin as remote_light.cs

                It shows a semi-transparent slider with light status. If you click the small light icon, the light is switched on/off. If you move the slider, the corresponding DIM or BRIGHT command is sent. A tooltip showing location + name is shown if you leave the cursor over the slider.




                You can run several simultaneous remote light scripts. You select the device by passing device house code + device code as the script parameter.

                Note:
                You have to make sure the following picture files are present on the remote computer (you may copy the files from your main HS server)

                - HomeSeer 2\html\Images\HomeSeer\on.gif
                - HomeSeer 2\html\Images\HomeSeer\off.gif
                - HomeSeer 2\html\Images\HomeSeer\dim.gif
                - HomeSeer 2\html\Images\HomeSeer\disabled.gif
                Last edited by stipus; September 6, 2007, 03:49 PM.
                --
                stipus

                Comment


                  #9
                  HomeSeer Thermostat Control from a Remote Computer

                  This script is installed with plugin V0.6.2.2 +



                  By default the Thermostat it's running in simulated mode. You can edit the code to switch from Celcius to Fahrenheit, or use a decimal point if your thermostat uses decimals.

                  The code starts with a user editable section you can change to interface with most thermostats. All the code needed to interface with a thermostat using the HomeSeer thermostat API is commented in this section.

                  As usual, you can run this script easily from the remote computer by creating a windows shortcut on your Desktop. Set the shortcut target to:
                  "c:\Program Files\HomeSeer 2\HsScript.exe" remote_thermostat.cs
                  Last edited by stipus; September 9, 2007, 09:31 AM.
                  --
                  stipus

                  Comment


                    #10
                    Control several lights from a remote computer

                    This script is installed with plugin V0.6.2.2 +

                    It shows a dynamic sized window with status for all device codes you pass to the script using the script parameter.
                    You can click the small light icon to switch the light on/off

                    The script window shows Device Location + Device Name for each device.
                    A tooltip appears with the device code if you leave the mouse over a label.

                    Last edited by stipus; September 9, 2007, 09:31 AM.
                    --
                    stipus

                    Comment


                      #11
                      Control Media on any Computer from any Computer

                      The HomeSeer Distributed Media Player scripts are installed with plugin V0.7.2.2 +. The scripts are in the Scripts/media directory

                      From any computer with the Script Client running, you can launch the Distributed Media Player Control script: HSSCRIPT.exe media/control.cs
                      You should create a desktop shortcut to run it easily.

                      From the control window, you can browse other computers media files, and remotely play those files on the remote computers. This means you can use any computer as a remote to control video and audio playback on other computers.





                      The scripts installed withe the plugin require VLC Media player 0.8.6 installed on remote computers. Alternatively, you can install one of the control packs for Winamp 2, Winamp 5, Windows Media Player, Media Player Classic or Foobar2000.

                      You can edit the GetVideoDirectory.cs and GetMusicDirectory.cs scripts to change initial media directories on each remote computers (these directories default to Documents/My Music and My Videos).




                      WinAmp 2.x Control pack

                      Prerequisite:
                      - WinAmp 2.x Installed (Tested with WinAmp 2.95)
                      - Winamp plugin WinAmpCom 1.30 must be installed (download from winamp plugin site)

                      Install procedure:
                      - Download and unzip WINAMP2_Control.zip
                      - Copy Interop.WINAMPCOMLib.dll to the HomeSeer 2 directory
                      - Copy WINAMP2_Control.cs to HomeSeer 2\Scripts\media
                      - Edit HomeSeer 2\Scripts\media\GetMusicPlayerType.cs to return the string "WINAMP2"


                      WinAmp 5.x Control pack

                      Prerequisite:
                      - WinAmp 5.x Installed (Tested with WinAmp 5.35)
                      - Winamp plugin ActiveWinAmp must be installed (download from winamp plugin site)

                      Install procedure:
                      - Download and unzip WINAMP5_Control.zip
                      - Copy Interop.ActiveWinamp.dll to the HomeSeer 2 directory
                      - Copy WINAMP5_Control.cs to HomeSeer 2\Scripts\media
                      - Edit HomeSeer 2\Scripts\media\GetMusicPlayerType.cs to return the string "WINAMP5"


                      Windows Media Player Control pack (Audio only)
                      - Download and unzip WMPAUDIO_Control.zip
                      - Copy Interop.WMPLib.dll to the HomeSeer 2 directory if it's not already there
                      - Copy WMPAUDIO_Control.cs to HomeSeer 2\Scripts\media
                      - Edit HomeSeer 2\Scripts\media\GetMusicPlayerType.cs to return the string "WMPAUDIO"


                      Media Player Classic Control pack

                      - Download and unzip MPC_Control.zip
                      - Copy MPC_Control.cs to HomeSeer 2\Scripts\media
                      - For Media Player Classic remote Audio, edit HomeSeer 2\Scripts\media\GetMusicPlayerType.cs to return the string "MPC"
                      - For Media Player Classic remote Video, edit HomeSeer 2\Scripts\media\GetVideoPlayerType.cs to return the string "MPC"

                      Run Media Player Classic once on the remote computer, and activate the WINLIRC option:
                      Menu View / Options - Player / Keys. Check the WINLIRC checkbox. The textbox should show "127.0.0.1:8765"


                      Foobar 2000 Control pack

                      - Download and unzip FOOBAR_Control.zip
                      - Copy FOOBAR_Control.cs to HomeSeer 2\Scripts\media
                      - Edit HomeSeer 2\Scripts\media\GetMusicPlayerType.cs to return the string "FOOBAR"


                      You can also use the Distributed Media Player features from any standard HomeSeer Script or Event. Ask me for more info.
                      Attached Files
                      Last edited by stipus; September 16, 2007, 07:29 PM.
                      --
                      stipus

                      Comment


                        #12
                        Announcing Unread emails on remote computers

                        The following script uses HomeSeer to speak the number of unread emails on a remote computer Outlook or Outlook Express email account.

                        Save this code snippet as remote_announce_mail.cs in the HomeSeer 2\Scripts directory on the remote computer.
                        Code:
                        #USING Microsoft.Win32
                        void Main( object param )
                        {
                            string mailboxString = param.ToString().TrimEnd( null );
                            // open registry
                            RegistryKey unreadMailRegistryKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\UnreadMail\" + mailboxString );
                            if( unreadMailRegistryKey == null )
                            {
                                hs.WriteLog( "Warning", "Email account " + mailboxString + " not found" );
                            }
                            else
                            {
                                object unreadMailObject = unreadMailRegistryKey.GetValue("MessageCount", null );
                                if( unreadMailObject != null )
                                {
                                    bool waitBool = true;
                                    hs.Speak( "You have " + unreadMailObject.ToString() + " unread messages", ref waitBool, String.Empty );
                                }
                            }
                        }
                        Use the email account as the script parameter.

                        The list of email accounts with exact spelling can be found at the following registry key:
                        HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ UnreadMail\
                        --
                        stipus

                        Comment


                          #13
                          Script to shutdown a remote computer

                          Remote computer shutdown and reboot script.

                          Notes:
                          - The user running hsscript.exe must have administrative privilege.
                          - You may want to restart the script client automatically. You could use autologon and put hsscript.exe in the startup folder, or run HsScript.exe as a service.

                          Save this code snippet as remote_shutdown.cs
                          Code:
                          void Main( object param )
                          {
                              System.Diagnostics.Process.Start("Shutdown", "/r /f");
                          }
                          You can type command "shutdown" on your computer to list available options for the reboot command.
                          Here I have used /r = reboot and /f = force running applications to close.

                          For example, if you want to hibernate a vista computer, you may want to use option /h (*this shutdown option is only available on vista computers)

                          remote_hibernate_vista.cs
                          Code:
                          void Main( object param )
                          {
                              System.Diagnostics.Process.Start("Shutdown", "/h");
                          }
                          Here is an other script that can hibernate a Windows XP computer

                          remote_hibernate_xp.cs
                          Code:
                          void Main( object param )
                          {
                              System.Diagnostics.Process.Start("rundll32", PowrProf.dll,SetSuspendState");
                          }
                          Note:
                          You may use a similar script to remotely start any other process. Just replace "Shutdown" with the other process name (and path if the executable is not in the PATH), and replace "/r /f" with process startup parameters.
                          Last edited by stipus; January 18, 2008, 05:02 PM.
                          --
                          stipus

                          Comment


                            #14
                            Push an internet explorer URL maximized to a remote computer

                            Push Internet Explorer page maximized to a remote computer:

                            Save this code snippet as remote_ie.cs
                            Code:
                            #USING System.Diagnostics
                            void Main( object param )
                            {
                             ProcessStartInfo processStartInfo = new ProcessStartInfo();
                             processStartInfo.FileName = "IEXPLORE.EXE";
                             processStartInfo.Arguments = param.ToString();
                             processStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                             Process.Start( processStartInfo ); 
                            }
                            Use any URL such as http://x.y.com as the script parameter
                            --
                            stipus

                            Comment


                              #15
                              Control Arcam AVR300 Receiver connected to remote computer RS232

                              Here is a sample script to send RS232 ASCII commands from the HomeSeer server to an Arcam AVR300 receiver plugged to a remote computer serial port.

                              The ASCII string to be sent is the script parameter. The response is printed to the HomeSeer event log.

                              Save this script as remote_com1.cs
                              Code:
                              void Main( object param )
                              {
                                System.IO.Ports.SerialPort serialPort = new System.IO.Ports.SerialPort("COM1", 38400, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
                                serialPort.Encoding = System.Text.Encoding.ASCII;
                                serialPort.NewLine = new string( Convert.ToChar(0xd), 1 );
                                serialPort.Open();
                                serialPort.WriteLine( param.ToString() );
                                string responseString = serialPort.ReadLine();
                                serialPort.Close(); 
                                
                                hs.WriteLog( "Remote COM1", responseString );
                              }
                              
                              If you need other settings for the COM port here are the possible values from the .NET API documentation:

                              Parity:
                              - Even
                              - Mark
                              - None
                              - Odd
                              - Space

                              StopBits:
                              - None
                              - One
                              - OnePointFive
                              - Two

                              The end of line with the Arcam Receiver is always the 0xd character.

                              If your serial device uses another one such as carriage return, you may use one of:

                              serialPort.NewLine = "\n\r";

                              or

                              serialPort.NewLine = "\n";

                              or

                              serialPort.NewLine = "\r";
                              --
                              stipus

                              Comment

                              Working...
                              X