drquochoai Posted July 6, 2015 Share Posted July 6, 2015 I'm using this code :HotKeySet("^q", "_hd") While 1 WEnd Func _hd() $oldClip = ClipGet(); get the data that is currently in the clipboard Send('^c'); copy the selected text to the clipboard $phrase = ClipGet(); get the data from the clipboard (which is now the selected word) ClipPut($oldClip); put the old data back in the clipboard ConsoleWrite($phrase& @CRLF) EndFuncFirst time of running, he do too good his job, but the second time i press Ctrl+Q, he can not get the selected text that i want.I don't know why, but i've spent 2 days with this problem, i just wonder if we can use CMD or ObjCreate function to do that, without using Send() function with lots of buggy inside.Hope you can help.Thanks so much. Link to comment Share on other sites More sharing options...
JohnOne Posted July 6, 2015 Share Posted July 6, 2015 You should see if you can find a help forum section. drquochoai 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted July 6, 2015 Share Posted July 6, 2015 First you should insert a Sleep statement into your loop. Else it will eat up all available CPU.While 1 Sleep(10) WEndSecond: You are sure that the application where you marked the text does support Ctrl+c? drquochoai 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
drquochoai Posted July 6, 2015 Author Share Posted July 6, 2015 thanks for your tip, now i can do it:Func _copyAnyWhere() $window_title = WinGetTitle("[active]") WinActivate($window_title) $readtext = "" For $i = 1 to 2 Step 1 $rand = random (1, 4, 1) Send ("{CTRLDOWN}") Switch $rand Case 1 Send("{INS}") Case 2 ControlSend($window_title, "", "", "{INS}") Case 3 Send("c") Case 4 ControlSend($window_title, "", "", "c^") EndSwitch Send ("{CTRLUP}") $readtext = ClipGet() If $readtext <> "" Then return $readtext EndIf If $i = 4 Then WinActivate($window_title) Sleep(100) EndIf Next return $readtext EndFuncWe can not send Ctrl, but we can send one key, so that we will hold control then send a key.I found it in our forum, thanks so much. 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