ReMoTe04 Posted July 28, 2014 Share Posted July 28, 2014 (edited) Hy programmers, i have a questionn for you:) How can i save (with the mouse) drag-selected texts, in a varriable if key pressed X? IF -> Pressed X THEN IF THE -> Selected area is TEXT, save the drag-selected text in the "text" variable ELSE -> MsgBox: "You must select a TEXT" Is it possible? I want a program like the windows's Copy and Paste, but if the selected item is not text, then do nothing:) Edited July 28, 2014 by ReMoTe04 Link to comment Share on other sites More sharing options...
Muzaiyan Posted July 28, 2014 Share Posted July 28, 2014 use a mouse hook Link to comment Share on other sites More sharing options...
JohnOne Posted July 28, 2014 Share Posted July 28, 2014 You will need these functions. _IsPressed Or HotKeySet Send Ctrl and c ClipGet And a bit of logic That is the minimum you need to create a basic functioning script. See if you can do it. 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...
computergroove Posted July 29, 2014 Share Posted July 29, 2014 (edited) HotKeySet("x", "GetData");If you press x then GetData() will be called While 1;Loop to keep the program running forever Sleep(100) WEnd Func GetData() Local $text;variable to be used if there is text in the copied string of data Send("{CTRLDOWN}" & "c");windows keyboard shortcut to copy selected data to the windows clipboard Sleep(100);pause for stability - may not be needed Send("{CTRLUP}") Local $sData = ClipGet();$sData is a temp variable to push through clipget to see if its text or not If @error Then;If Clipget returns an error then open a message box to tell the user MsgBox(0,"Message","You must select a TEXT") Else $text = $sData;if there is no error then set the clipboard data to $text variable EndIf EndFunc Try this. *Edit - added CTRLUP Edited July 29, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
JohnOne Posted July 29, 2014 Share Posted July 29, 2014 (edited) But do not forget Send("{CTRLUP}") if you do. Or change Send("{CTRLDOWN}" & "c") to Send("^c") Edited July 29, 2014 by JohnOne 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...
ReMoTe04 Posted July 29, 2014 Author Share Posted July 29, 2014 HotKeySet("x", "GetData");If you press x then GetData() will be called While 1;Loop to keep the program running forever Sleep(100) WEnd Func GetData() Local $text;variable to be used if there is text in the copied string of data Send("{CTRLDOWN}" & "c");windows keyboard shortcut to copy selected data to the windows clipboard Sleep(100);pause for stability - may not be needed Local $sData = ClipGet();$sData is a temp variable to push through clipget to see if its text or not If @error Then;If Clipget returns an error then open a message box to tell the user MsgBox(0,"Message","You must select a TEXT") Else $text = $sData;if there is no error then set the clipboard data to $text variable EndIf EndFunc Try this. THANKS Link to comment Share on other sites More sharing options...
computergroove Posted July 29, 2014 Share Posted July 29, 2014 Shoot I did forget the ctrlup. I like John One's suggestion better. Replace the following: Send("{CTRLDOWN}" & "c");windows keyboard shortcut to copy selected data to the windows clipboard Sleep(100);pause for stability - may not be needed With this: Send("^c") or else windows wont release the ctrl button. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
-Pete Posted September 4, 2015 Share Posted September 4, 2015 (edited) I know this is an older post, but wanted to say thank you.Also, a findings for other's that are new to Auto IT like myself;I found I had to move the line: "$text = $sData;if there is no error then set the clipboard data to $text" down a line, leaving "Else" on the line above, to work. Otherwise there's an error for illegal command.Also, found out that you can't use the 'x' key, so turned this to [ALT]+[x].Also, found out the script would never end, so added the terminate hotkey via [ALT]+[ESC]HotKeySet("!{x}", "GetData");If you press x then GetData() will be called HotKeySet("!{ESC}", "Terminate") ;Exit from the script/program <Alt>+<Esc>. While 1;Loop to keep the program running forever Sleep(100) WEnd Func GetData() Local $text;variable to be used if there is text in the copied string of data Send("{CTRLDOWN}" & "c");windows keyboard shortcut to copy selected data to the windows clipboard Sleep(100);pause for stability - may not be needed Send("{CTRLUP}") Local $sData = ClipGet();$sData is a temp variable to push through clipget to see if its text or not If @error Then;If Clipget returns an error then open a message box to tell the user MsgBox(0,"Message","You must select a TEXT") Else $text = $sData;if there is no error then set the clipboard data to $text variable EndIf EndFunc Func Terminate() Exit ;Exit the script/progam. EndFunc ;==>Terminate Edited September 4, 2015 by -Pete 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