Jump to content

Recommended Posts

Posted

Hi,

Im Trying to use ControlSend to a blurred/unfocused window without a control-ID. This is (slightly modified) from the example page:
 

Example()

Func Example()
    Run("notepad.exe")
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 2)

    ; Send a string of text to the edit control of Notepad. The handle returned by WinWait is used for the "title" parameter of ControlSend.
    ControlSend($hWnd, "", "", "This is some text")
    sleep(1000)
    ControlSend($hWnd, "", "", "This is some text")
    sleep(1000)
    ControlSend($hWnd, "", "", "This is some text")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)

    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example

It works, as long as I don't remove the focus from that window.

It also works when I supply a controlID ("Edit1") [even in background]

But I want to send keys to a background software without controlIDs.

Help would be greatly appreciated.

Michael

Posted

The background window doesn't have any controls. (I tried to find them with inspect.exe and the spy-tool that is linkes here somwhere :) )

Small update: AutoHotkeys ControlSend works perfectly without controlID and in background.

I could swear that a year ago, I had a working autoit script that sent to a background window with

ControlSend($hWnd, "", "", "This is some text")

Guess I'll have to switch. (which sucks, because i find the coding style of ahk VERY confusing.)

Posted

Thank you for the reply. Unfortunately i don't seem to understand it.

yes, the window has a consitent title. I am not sure what you mean by third and fourth parameter though. (Shouldn't it be 1st and 2nd?)

ControlSend ( "title", "text", controlID, "string" [, flag = 0] )

But i am already getting the right handle for the window (WinClose works fine).

Unfortunately, I don't get text.

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
×
×
  • Create New...