littlebigman Posted December 5, 2020 Posted December 5, 2020 Hello, I've only used AutoIT a few times. This AutoHotKey script is supposed to be able to paste text with CTRL+V into Windows' terminal window (CMD.EXE). Has someone written the same script for AutoIT, preferably SHIFT+Ins (since I'm used ot it)? Thank you.
Nine Posted December 5, 2020 Posted December 5, 2020 Yes, it is kind of easy to do. Check help file for Run function with IN/OUT/ERR CHILD option flags. When the console is up, you can start discussing with it by using StdinWrite and StdOutRead to write and read the IO stream. Study the examples provided with the help file, it will give you a head start...If you have problem with your script, post the code here and we will gladly help you out. “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
littlebigman Posted December 5, 2020 Author Posted December 5, 2020 Thanks. Is it needed just to paste text from elsewhere?
Nine Posted December 5, 2020 Posted December 5, 2020 (edited) The other approaches, if you think it is too complicated, are : 1- ControlSend the content of the clipboard directly to the DOS console. 2- Interact with the DOS Console Menu by ControlSend (or even just Send) keys. But without your code and lack of precise informations from your part, it is hard to tell which is the best solution. BTW, to define a HotKey look at HotKeySet (if that was part of the question)... Edited December 5, 2020 by Nine “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
littlebigman Posted December 5, 2020 Author Posted December 5, 2020 Thanks. I have no code yet since I'm only getting started. I'll read up on how to locate a window, and send it the clipboard's content through StdinWrite.
Nine Posted December 5, 2020 Posted December 5, 2020 (edited) 5 minutes ago, littlebigman said: to locate a window, and send it the clipboard's content through StdinWrite If the Window already exists, you cannot link to its stream and use StdInWrite. You must use Run to initiate the DOS console to be able to use StdInWrite. If the Window already exists, then use one of the 2 others solutions I suggested Edited December 5, 2020 by Nine “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
littlebigman Posted December 5, 2020 Author Posted December 5, 2020 (edited) This works, but is there no smarter way than waiting between "keystrokes" so that Windows/the app has enough time to play the keys? #include <MsgBoxConstants.au3> Opt( "MustDeclareVars", 1 ) Opt("WintitleMatchMode", 2) If WinActivate("[TITLE:C:\Windows\system32\cmd.exe; CLASS:ConsoleWindowClass]", "") Then ;NOK Send("!{SPACE}AP") ;Send("!{SPACE}") ;Send("EP") ;Send("{APPSKEY}") Send("!{SPACE}") Sleep(500) Send("E") Sleep(500) Send("P") Else MsgBox($MB_SYSTEMMODAL, "", "Window not activated", 5) EndIf Google didn't return hits while looking for "AutoIT window open system menu". -- Edit: V2 #include <MsgBoxConstants.au3> #include <Constants.au3> #include <Date.au3> Opt( "MustDeclareVars", 1 ) Opt("WintitleMatchMode", 2) HotKeySet("+{INSERT}", "CheckCmd") While 1 Sleep(100) WEnd Func CheckCmd() If WinActive("[TITLE:C:\Windows\system32\cmd.exe; CLASS:ConsoleWindowClass]") Then Send("!{SPACE}") Sleep(100) Send("E") Send("P") Else Send(ClipGet()) EndIf EndFunc Edited December 5, 2020 by littlebigman
Nine Posted December 5, 2020 Posted December 5, 2020 Here a better way : Local $hDOS = WinGetHandle("[CLASS:ConsoleWindowClass]") If Not $hDOS Then Exit MsgBox($MB_SYSTEMMODAL, "", "Console not found") ControlSend($hDOS, "", "", ClipGet() & @CRLF) “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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