antai Posted January 10 Share Posted January 10 (edited) Hi, I cannot select the text in the Windows Console Host using this script Opt("WinTitleMatchMode", 2) #RequireAdmin ; <= this solved the problem WinActivate ("Command") Sleep(1000) ;MouseClick ("left", 800, 400) Sleep(1000) Send ("^a") Sleep(1000) Send ("^c") $text = ClipGet () MsgBox (0, "Clipboard", $text) - CTRL-A using my keyboard DOES work - CTRL-A using AutoitScript does NOT work Edited January 11 by antai Link to comment Share on other sites More sharing options...
636C65616E Posted January 10 Share Posted January 10 (edited) Hey, First : you should do some error checking, eg read the help files and check after each step if everything is ok, for instance : func assert($check, $msg, $line=@SCRIPTLINENUMBER) if (not $check) then MsgBox(0x10,'ERROR','Assert failed at line ' & $line & @CRLF & $msg) Exit endif endfunc local $res = WinActivate("Excavator") ; from the doc : WinActivate success return the value 0 assert($res = 0, 'WinActivate failed') Then proceed step by step. A guess why it doesnt work : you cannot simply use the window title, you maybe need to use the window handle (idk maybe). A tool to help you with the windows title/class/etc : AU3Info. As mentionned many time here: sending keystroke is usually a bad idea, however for the specific case of consoles it is not that simple to retrieve text buffer (it is doable but a bit tedious by working around the windows console api), so i guess it is a more "simple" solution to proceed as you do Edited January 10 by 636C65616E Link to comment Share on other sites More sharing options...
antai Posted January 10 Author Share Posted January 10 9 hours ago, 636C65616E said: sending keystroke is usually a bad idea, however for the specific case of consoles it is not that simple to retrieve text buffer (it is doable but a bit tedious by working around the windows console api), so i guess it is a more "simple" solution to proceed as you do That error checking helped with the WinActivate() function, thanx. The Send() function however returns nothing. The confusing point is that "all things equal" the Console - does not react to keystrokes sent by the script but does - does react to keystrokes sent byt the keyboard. I.e. even when activated by hand and clicking inside the Window at the exact same moment the script does not work while physical keyboard does work. // that brought me to just doing a test with a virtual keyboard and it works as well. So a solution is to invoke virtual keyboard and send mouse clicks to the virtual keyboard. Kinda cumbersome and there's definitely something different how the script sends the kyes compared to the Windows built in virtual keyboard (that should be the same on the program level). Link to comment Share on other sites More sharing options...
Solution Nine Posted January 10 Solution Share Posted January 10 (edited) You cannot send keys to a higher elevation program than the script is...You can find out if it is elevated with this : If it is, then you need to use #RequireAdmin Edited January 10 by Nine 636C65616E 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
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