Jump to content

ControlSend with Handle


 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

  • 1 month later...

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