tauruzian Posted November 12, 2014 Share Posted November 12, 2014 Hi, How do I perform short cut key in Auto It. For an example I need to copy a text from text file. How do I perform 'Ctrl C' and 'Ctrl V' using Auto It. Any suggestion or reference links is highly appreciated. Thanks. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 12, 2014 Moderators Share Posted November 12, 2014 Is there a reason you need to use a shortcut key rather than using the built in FileRead or FileReadLine functions? 232showtime 1 "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! Link to comment Share on other sites More sharing options...
tauruzian Posted November 13, 2014 Author Share Posted November 13, 2014 I need to read certain text for the entire document. For an example, if user just highlight(using mouse and highlight the text) the first paragraph of the entire document, I just need to read those. I cannot predefine which line to be read since the user might select any text in the document. Link to comment Share on other sites More sharing options...
Solution somdcomputerguy Posted November 13, 2014 Solution Share Posted November 13, 2014 (edited) The easiest way to do this is to read the help file. You may want to use the Send() or ControlCommand() or maybe even the ClipPut() function. Edited November 13, 2014 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
tauruzian Posted November 13, 2014 Author Share Posted November 13, 2014 The easiest way to do this is to read the help file. You may want to use the Send() or ControlCommand() or maybe even the ClipPut() function. Func addToClipboard() Send ("^c") sleep(1000) ; EndFunc and Func printOutput2() Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("^v") EndFunc does the trick, but how do I refer to particular document. For an example get ctrl c for test.txt. Please advice. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted November 13, 2014 Share Posted November 13, 2014 Run("notepad.exe test.txt") or ShellExecute("notepad.exe", "test.txt") or ShellExecute("test.txt") if files with .txt extension are associated with notepad. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
tauruzian Posted November 14, 2014 Author Share Posted November 14, 2014 Run("notepad.exe test.txt") or ShellExecute("notepad.exe", "test.txt") or ShellExecute("test.txt") if files with .txt extension are associated with notepad. The notepad is active. For an example, I open the test.txt, highlight some text in the txt file, run the auto it script. How do I point the script to the active document. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted November 14, 2014 Share Posted November 14, 2014 How do I point the script to the active document. o:) Post your script code. Use the AutoIt code tags! - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
czardas Posted November 14, 2014 Share Posted November 14, 2014 You don't need to point the script to the active window. Send commands only interact with the active window. If the window loses focus you can use WinActivate(). operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 14, 2014 Moderators Share Posted November 14, 2014 (edited) WinGetHandle for notepad window ControlGetHandle for notepad edit area _GUICtrlEdit_GetSel to get the selected character positions StringMid to retrieve data Modified helpfiles "example" for a quick example of use: **Edit**: Please don't think to just use this out of the box without error checking, this is just an example! expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hStatusBar, $idEdit, $hGUI Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt" Local $aPartRightSide[3] = [190, 378, -1], $aSel ; Create GUI $hGUI = GUICreate("Edit Get Sel", 400, 300) $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide) _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll") GUISetState(@SW_SHOW) ; Set Margins _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) ; Set Text _GUICtrlEdit_SetText($idEdit, FileRead($sFile)) ; Set Sel _GUICtrlEdit_SetSel($idEdit, 15, 20) ; Get Sel $aSel = _GUICtrlEdit_GetSel($idEdit) Local $sz_selected = StringMid(ControlGetText($hGUI, "", $idEdit), $aSel[0], ($aSel[1] - $aSel[0]) + 1) MsgBox(64, "Selected Text", $sz_selected) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Edited November 14, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted November 14, 2014 Share Posted November 14, 2014 Hello If you want to use ctrl-c/v i use: Send("{CTRLDOWN}v{CTRLUP}") usually There are a good number of other method to do it (as we can see above). Also if you want to save it as a variable you can use ClipGet() (If I misunderstood the question then sorry ) 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