Jump to content

Problem using controlsend in place of send


Justen
 Share

Recommended Posts

Hello I am wanting to use ControlSend in place of Send, but I always get an error wrong number of args.

$msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                Do
                    Sleep(10)
                Until _IsPressed("01")
                    Sleep(2000)
                Send(GUICtrlRead($file) & "")
        EndSelect
    WEnd
EndFunc

Thanks!

Edited by Justen
Link to comment
Share on other sites

Hello I am wanting to use ControlSend in place of Send, but I always get an error wrong number of args.

$msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                Do
                    Sleep(10)
                Until _IsPressed("01")
                    Sleep(2000)
                Send(GUICtrlRead($file) & "")
        EndSelect
    WEnd
EndFunc

Thanks!

So, you looked up ControlSend() in the help file, changed that line of the script and it looked like... what? You don't show your ControlSend() line here.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

So, you looked up ControlSend() in the help file, changed that line of the script and it looked like... what? You don't show your ControlSend() line here.

:)

Well that's the problem, I don't know how to replace Send with it. Whenever I do it gives an error. :\ I was hoping someone could show me how to use it with an example etc. Thanks.

Link to comment
Share on other sites

Well that's the problem, I don't know how to replace Send with it. Whenever I do it gives an error. :\ I was hoping someone could show me how to use it with an example etc. Thanks.

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")

Or get a control handle and put in there. Use the AutoIt Info window to get the information.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Expanding bo8ster advice.

The parameters for the ControlSend () command can be found using Au3Info.exe, a utility found in your root AutoIt3 directory.

The parameter "title" of the window to access. You can use either the Title in quotes or the Window class as per example. When using Au3Info.exe this info is displayed in the top "Basic Window Info" group.

And below that group is the "Basic Control Info". This is where the parameter "controlID" to interact with is found. As an example, when Notepad is active the "Basic Control Info" of Au3Info.exe displays Class: Edit and Instance 1 . So for ControlSend to a Notepad widow the controlID parameter is "Edit1" as per example.

In the example, when the OK button is pressed the data in the input control is sent to a Notepad window if it exists, and, to the bottom output window of the Scite editor, if it exists.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $file, $btn, $msg

    GUICreate(" My GUI input ", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
           Case $msg = $btn
                If  WinExists("[class:Notepad]") Then
                    ;WinActivate("[class:Notepad]")
                    ControlSend("[class:Notepad]", "", "Edit1", GUICtrlRead($file), 1)
                EndIf
                If  WinExists("[class:SciTEWindow]") Then                    
                    ;WinActivate("[class:SciTEWindow]")
                    ControlSend("[class:SciTEWindow]", "", "Scintilla2", GUICtrlRead($file), 1)
                EndIf
        EndSelect
    WEnd
EndFunc   ;==>Example

Edit: Changed If Then

Edited by Malkey
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...