Jump to content
Sign in to follow this  
Deathspike

ControlSend with Handle

Recommended Posts

Deathspike

Hello. I have a window handle as a string and use it in ControlSend, as it is shown around these forums. However, the message never arives, nothing is executed. I cannot use a handle on ControlSend, WinActive, and more. Please help me out, what is wrong here (the following code is C#).

string hwnd = AutoItX.WinGetHandle( "Untitled - Notepad" );
AutoItX.ControlSend( "handle=" + hwnd, "", "Edit1", "Hello", 0 );

Taking any advice that might work (it must be using hwnd though)! :mellow:

Edited by Deathspike

Share this post


Link to post
Share on other sites
AdmiralAlkex

If AutoItX is anything like AutoIt then you're doing it all wrong. Did you not look at anything in the helpfile? Where is the square brackets? What happened with the colon?

And no, I have never used AutoItX so I can't leave any guarantee for anything, but seriously, your code looks nothing like the ones in helpfile.

Share this post


Link to post
Share on other sites
Deathspike

If AutoItX is anything like AutoIt then you have some errors. Did you not look at the helpfile? You are probably missing some square brackets and/or colons.

Thanks for the reply. It only required brackets. I fixed your message by the way. It's called a less hostile reply.

Share this post


Link to post
Share on other sites
Authenticity

AutoItX3Class ai = new AutoItX3Class();

ai.Run("notepad.exe", "", ai.SW_SHOWNORMAL);

ai.WinWaitActive("[class:Notepad]", "", 0);



string hwnd = ai.WinGetHandle("[class:Notepad]", "");

hwnd = "[handle:" + hwnd + "]";



ai.ControlSetText(hwnd, "", "Edit1", "12345678");

ai.WinSetState(hwnd, "", ai.SW_MINIMIZE);

ai.WinWaitNotActive(hwnd, "", 0);



string hCtrl = ai.ControlGetHandle(hwnd, "", "Edit1");

hCtrl = "[handle:" + hCtrl + "]";



ai.ControlSend(hCtrl, "", "", "{END}{ENTER}12345678", 0);

ai.WinSetState(hwnd, "", ai.SW_RESTORE);

Share this post


Link to post
Share on other sites
Richard Robertson

1. This is AutoIt, not AHK.

2. It's "AutoIt", not "AutoIT".

3. No bots. That's not only against our rules but also the game's rules.

Share this post


Link to post
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
Sign in to follow this  

×