Announcement

Collapse
No announcement yet.

How to send commands to an AutoIt script/program

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send commands to an AutoIt script/program

    I want to have an AutoIt program running in the background, to which I can send commands through RoadRunner. I couldn't find any code examples, though . Could some clever AutoIt-programmer lighten me up, please ?

  • #2
    because its very easy and i have a script open at the moment i will show u how to run a road runner command in autoit. Copy this to your .au3

    Code:
    ;create SDK for COM with RR.  This must be done ONLY once per script
    $rr = ObjCreate("RoadRunner.SDK")
    
    ;replace COMMAND with your RR command
    $rr.execute("COMMAND")
    and because i'm a good mood i'll show u how to request an rr label into a autoit variable as well

    Code:
    ;trackname can be replaced with any rr label in the screens .skin file
    $var=$rr.getInfo("TRACKNAME")
    ;to request RR variables simply use
    $var=$rr.getInfo("=$musicpath$")
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

    Comment


    • #3
      Thanks, but I know how to grab information from RoadRunner and make it execute commands. I want to know how it works vice versa : I want my AutoIt program LISTEN for commands from RoadRunner, i.e. I press a button in RoadRunner, then a command is send to my AutoIt program (which runs constantly in the background).

      Comment


      • #4
        Code:
        while 1
        $var1 = $rr.getInfo(=$Var1$)
        $var2 = $rr.getInfo(=$Var2$)
        if $var1 = "pressed" then 
           [RUN whatever stuff u wanna do with auto it]
            $rr.execute("SETVAR;VAR1;unpressed")
        end if
        if $var2 = "pressed" then
            [RUN whatever stuff u wanna do with the second button]
            $rr.execute("SETVAR;VAR2;unpressed")
        end if
        WEnd
        then instead of running RR commands with your button presses just set the appropriate variable to "pressed" (like SETVAR;VAR1;pressed) so that autoit performs that function. Quick and dirty way to do things and it works
        mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
        Follow Me on Twitter or Facebook
        Live mp3Car Facebook Chat

        Comment


        • #5
          Or from the RR source:

          Code:
          Global Const $StructDef_COPYDATA = "ptr;dword;ptr"
          Global Const $WM_COPYDATA = 0x4A
          Global Const $WM_CLOSE = 0x10
          Global Const $STRUCTDEF_AU3MESSAGE = "char[255]"
          
          Dim $cmd
          
          ; Create Reciver window
          $hwmd_Reciver = GUICreate("Receiver")
          
          ; Register Windows Messages
          GUIRegisterMsg($WM_COPYDATA, "_GUIRegisterMsgProc")
          GUIRegisterMsg($WM_CLOSE, "_GUIRegisterMsgProc")
          
          ;Loop indefinitely - put your commands in here
          While 1
          If $cmd = "this" Then
            $cmd = ""
            <do this>
          Endif
          
          If $cmd = "that" Then
            $cmd = ""
            <do that>
          Endif
          
          Sleep(250)
          WEnd
          
          ; Message Handler
          Func _GUIRegisterMsgProc($hWnd, $MsgID, $WParam, $LParam)
          	If $MsgID = $WM_COPYDATA Then
          		; We Recived a WM_COPYDATA Message
          		; $LParam = Poiter to a COPYDATA Struct
          		$vs_cds = DllStructCreate($StructDef_COPYDATA, $LParam)
          		; Member No. 3 of COPYDATA Struct (PVOID lpData;) = Pointer to Costum Struct
          		$vs_msg = DllStructCreate($STRUCTDEF_AU3MESSAGE, DllStructGetData($vs_cds, 3))
          
          		$SciTECmdLen = DllStructGetData($vs_cds, 2)
          		$cmd = StringLeft(DllStructGetData($vs_msg, 1), $SciTECmdLen)
          
          		; Display what we have recived
          		MsgBox(0, "Test String", $cmd)
          
          	ElseIf $MsgID = $WM_CLOSE Then
          	; We Recived a WM_CLOSE Message
          		Exit
          	EndIf
          EndFunc ;==>_GUIRegisterMsgProc
          Once the script is running, you can send commands to it from RR via "SENDMSG;Receiver;<cmd>"

          In this example, <cmd> can be "this" or "that."

          *Note the the "Receiver" name has to match

          Sonic's way is good too. I prefer the method above as it's more process friendly for my M10K since it just sleeps until a message is recieved.
          Pico-ITX / XP Home with EWF-HORM / RR v12/02/2009 / Winamp v5.13 / RRMedia v1.2.2

          Comment


          • #6
            Thanks for your help guys .

            Comment


            • #7
              another way is you can send command line arguments to your script at runtime, i find this works good for scripts that only run for a few secs, do there thing and exit.

              search in the autoit help file for cmdlineraw

              the way i normally use it is i have a command in RR that will run the script and send some bit of information from RR to the script. The script is expecting this information as cmdlineraw is a var inside of autoit.

              Both of the other methods above are very good also, i use them both but depends on what the script calls for ect.
              01101100 01101001 01110001 01110101 01101001 01100100 01011111 01110011
              01101101 01101111 01101011 01100101

              beer replenishment fund
              http://www.mp3car.com/vbulletin/forumdisplay.php?f=93
              mp3car live search

              i have joost invites, just hit me up for one.

              Comment


              • #8
                I really appreciate your help guys .

                (Wouldn't this thread fit in the FAQ-section of RoadRunner ?)

                Comment


                • #9
                  my media plugin has a LOT of sendmgs to it from rr..
                  RideRunner...The #1 FE, PERIOD.

                  Current Project: DFXVoice [v1.0 Released]
                  Next in line: RRMedia v2.0

                  DFX 5.1.1 Skin
                  Appstore Link

                  My RideRunner Plugins
                  RRMedia
                  RRExtended
                  DFXVoice

                  "There are no bugs - only undocumented features."

                  Comment


                  • #10
                    I realize this is 4 years old but found this info very interesting... Anyone have some updates to this to use with Ride runner / DFX5?

                    Do all of the above posts still apply and work with current RR?

                    thanks!

                    Comment

                    Working...
                    X