Announcement

Collapse
No announcement yet.

MouseClick script?

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

    MouseClick script?

    Is there a mouse click script already that I've missed?

    I just thought I'd ask before reinventing the wheel...
    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
    Running on Windows 10 (64) virtualized
    on ESXi (Fujitsu Primergy TX150 S8).
    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

    #2
    I've used AutoIt and Mortscript for that.

    --Dan
    Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

    Comment


      #3
      Thanks!
      But I'd like to do it "directly" in .NET. I've already written such an application, I'd just convert it to a script...
      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
      Running on Windows 10 (64) virtualized
      on ESXi (Fujitsu Primergy TX150 S8).
      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

      Comment


        #4
        If you need to click the mouse this is what I did in .net;

        PHP Code:
        Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As LongByVal dx As LongByVal dy As LongByVal cButtons As LongByVal dwExtraInfo As Long)

        Sub Main(ByVal Sval as String)
         
        Windows.Forms.Cursor.Current.Position = New System.Drawing.Point(225105)
        hs.waitsecs(2)
        Call mouse_event(&H20001)
        hs.waitsecs(1)
        Call mouse_event(&H40001)
        End Sub 
        Which clicked the mouse at the co-ordinates in the system.drawing.point (left click down and 1sec later left click up), need to have the system.drawing dll reference in HS though...

        I got from somewhere on the net, can't remember where though sorry.

        Comment


          #5
          This script should work with the script connector plugin, with a #IMPORT at the top for the System.Drawing dll.
          --
          stipus

          Comment


            #6
            Originally posted by mrhappy View Post
            If you need to click the mouse this is what I did in .net
            Yeah, that's what I'm trying to achieve here, but I'll guess I need some #imports sorted out:
            http://forums.homeseer.com/showthread.php?t=142632
            HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
            Running on Windows 10 (64) virtualized
            on ESXi (Fujitsu Primergy TX150 S8).
            WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

            Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

            Comment


              #7
              I figured it out:
              Code:
              #IMPORT System.Drawing,system.drawing.dll
              #IMPORT System.Windows.Forms,system.windows.forms.dll
              
              Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal dwData As Long, ByVal dwExtraInfo As IntPtr)
              
              Private Const MouseEventLeftDown As Int32 = 2
              Private Const MouseEventLeftUp As Int32 = 4
              
              Public Sub Main(ByVal param As Object)
                  Dim params() As String = param.ToString().Split("|")
                  If params.Length > 2 Then GenerateMouseClick(params(0), params(1), params(2))
              
              End Sub
              
              Private Sub GenerateMouseClick(ByVal x As Integer, ByVal y As Integer, Optional ByVal mouseclicks As Integer = 2, Optional ByVal return_mouse As Boolean = True)
                  Try
                      If mouseclicks < 1 OrElse mouseclicks > 3 Then
                          hs.WriteLog("MouseClick", "Only 1, 2 or 3 mouse clicks are allowed")
                          Exit Sub
                      End If
              
                      Dim pointOldPosition As Point = Windows.Forms.Cursor.Position
                      Windows.Forms.Cursor.Position = New Point(x, y)
              
                      For i As Integer = 1 To mouseclicks
                          mouse_event(MouseEventLeftDown, 0, 0, 0, New System.IntPtr())
                          mouse_event(MouseEventLeftUp, 0, 0, 0, New System.IntPtr())
                      Next
              
                      If return_mouse Then Windows.Forms.Cursor.Position = pointOldPosition
                  Catch ex As Exception
                      hs.WriteLog("MouseClick", "Error occured. Sorry about that...")
                  End Try
              End Sub
              HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
              Running on Windows 10 (64) virtualized
              on ESXi (Fujitsu Primergy TX150 S8).
              WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

              Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

              Comment

              Working...
              X