Micha321 Posted August 2, 2018 Posted August 2, 2018 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
Moderators JLogan3o13 Posted August 2, 2018 Moderators Posted August 2, 2018 Are you saying the background window does not have any controls, or the controls don't show any IDs? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Micha321 Posted August 2, 2018 Author Posted August 2, 2018 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.)
Moderators JLogan3o13 Posted August 2, 2018 Moderators Posted August 2, 2018 Does the window have any consistent title or text (third and fourth parameters) you can use in your ControlSend statement? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Micha321 Posted August 3, 2018 Author Posted August 3, 2018 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.
Moderators JLogan3o13 Posted August 4, 2018 Moderators Posted August 4, 2018 Sorry, typo on my part. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now