Jump to content

Send() back to originating application


trids
 Share

Recommended Posts

How do I Send() or ControlSend() a string back to an application that launches a script?

The application is a Multi Document Interface (MDI) .. in this case TextPad. The script is meant to lookup a word in an INI file, matching the currently selected word in TextPad, and display the results in a listbox. The user then selects an item from the listbox, to send back to TextPad. I have everything working up to where I have to send results back to TextPad (see attached script if necessary).

TextPad can provide all sorts of interesting contextual values when calling the script, including:

$SelWord-- The word containing the cursor. I'm using this in the script to lookup values in an INI file

$AppWnd-- The handle of the main application window. This is a decimal number.

$DocWnd-- The handle of the active document's window. This is a decimal number.

I sense that the answer is very simple .. I just can't see it :)

I'm not itching to use $AppWnd or $DocWnd .. I'd be happy to somehow reactivate the last active window and just Send() there, if I could!

Any ideas?

TIA

SQL_popup.zip

Link to comment
Share on other sites

  • Moderators

Have you gandered at the Std*() + ConsoleWrite() functions :) ? Might be as easy as the 2 of them catching what the other is doing, and the one updating itself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks Smokey, but the ConsoleWrite() ends up in a special window within TextPad .. not the document currently open. And there doesn't seem to be a way to get the results of the Std*() functions into the current document either.

First prize would be some way to reactivate the last window beneath the script, so I can simply Send() the string back to it wherever the cursor is.

Fallback option is to have the script ClipPut() the string, then leave it to the user to Paste it into TextPad .. but this is very clunky and unbefitting of an AU3 script :P

Any more ideas? :)

Link to comment
Share on other sites

  • Moderators

Thanks Smokey, but the ConsoleWrite() ends up in a special window within TextPad .. not the document currently open. And there doesn't seem to be a way to get the results of the Std*() functions into the current document either.

First prize would be some way to reactivate the last window beneath the script, so I can simply Send() the string back to it wherever the cursor is.

Fallback option is to have the script ClipPut() the string, then leave it to the user to Paste it into TextPad .. but this is very clunky and unbefitting of an AU3 script :P

Any more ideas? :)

You probably couldn't make heads or tails of this, I'm exhausted, but I tried to make it to where I understood what you were asking.
_LaunchNextAu3('AtSciptPath\ScriptName.au3')
Func _LaunchNextAu3($hNextAu3)
    Local $hWnd = WinGetHandle('');Get the handle of the window your working in
    Local $sCID = 'Edit1' ; ClassNameNN of Control To be read
    Run(@AutoItExe & ' /AutoIt3ExecuteScript ' & $hNextAu3 & ' ' & $hWnd & ' ' & $sCID, '', @SW_HIDE)
EndFunc

;~======================= Au3 launched ============================
;Next Au3
Global $hWnd, $sCID, $sCIDText
If $cmdline[0] Then
    $hWnd = $cmdline[1]
    $sCID = $cmdline[2]
    $sCIDText = ControlGetText($hWnd, '', $sCID)
EndIf

;Do my thing
;Now set the text of the entire control before exit
$allNewInfo = $sCIDText & ' all the new stuff I would set'
ControlSetText($hWnd, '', $sCID, $allNewInfo)

This is all based on both scripts being .au3's or at least your own Au3.exe's

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Woo-hoo! Solved :)

I was trying things like the following (where $hWndSend is TextPad's $DocWnd):

WinActivate( $hWndSend )
Send( $sSend )
oÝ÷ Ûbrbv}ý·
+­¶§!جrÞ­ç¢Z+£M4Ñ÷쥩ì·)^

I'll keep your _LaunchNextAu3 UDF in mind, Smokey, when I want to communicate between scripts. But for communicating back to a non-script app that launches a script, it wasn't quite what I was after. But thanks for trying!

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...