fmen Posted July 25, 2007 Share Posted July 25, 2007 I am trying to do the following:If the left mouse button remains clicked for more than 2 seconds then send some keystrokes. I am having problems with the timing.What this would do is automatically copy highlighted text to the clipboard...just like in linux.While 1If _IsPressed('01') = 1 AND (Left mouse button down for more than 2 seconds) Then Send ("^c")Sleep (10)WendCan anyone direct me to a solution? Yes I am still a noob after several years of using AutoIt. Thanks. Link to comment Share on other sites More sharing options...
MisterBates Posted July 25, 2007 Share Posted July 25, 2007 (edited) I am trying to do the following:If the left mouse button remains clicked for more than 2 seconds then send some keystrokes. I am having problems with the timing.What this would do is automatically copy highlighted text to the clipboard...just like in linux.While 1If _IsPressed('01') = 1 AND (Left mouse button down for more than 2 seconds) Then Send ("^c")Sleep (10)WendCan anyone direct me to a solution? Yes I am still a noob after several years of using AutoIt. Thanks.Take a look at this post for the "is the mouse button pressed" part. For the "more than two seconds", take a look at TimerInit and TimerDiff - set a variable to TimerInit before your while loop, and test TimerDiff > 2000 (milliseconds) in your loop condition.EDIT: OK, now I re-read your code. Change the "While 1" to be "While _IsPressed('01') and timerDiff($iStartTime) <= 2000", add your TimerInit call before the loop, and after the loop test that TimerDiff($iStartTime) is >= 2000 (to be sure the loop didn't exit because the mouse button was released). Edited July 25, 2007 by MisterBates [u]MisterBates[/u]_____________________________________________________Suspend/Resume Windows ScreensaverWatchWindows - Window watcher/loggerUDF: Click systray menu/submenu itemsUDF: Outlook Express Folder/Message handling (+ example code)HowTo: Multiple icons in one compiled script Link to comment Share on other sites More sharing options...
Toady Posted July 25, 2007 Share Posted July 25, 2007 (edited) #include <misc.au3> While 1 If _IsPressed('01') = 1 Then Local $timer = TimerInit() While _IsPressed('01') If TimerDiff($timer) > 2000 Then Send ("^c") ExitLoop EndIf Sleep(10) ToolTip(TimerDiff($timer)) WEnd EndIf Sleep (10) Wend btw, i like this script Edited July 25, 2007 by Toady www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
fmen Posted July 25, 2007 Author Share Posted July 25, 2007 #include <misc.au3> While 1 If _IsPressed('01') = 1 Then Local $timer = TimerInit() While _IsPressed('01') If TimerDiff($timer) > 2000 Then Send ("^c") ExitLoop EndIf Sleep(10) ToolTip(TimerDiff($timer)) WEnd EndIf Sleep (10) Wend btw, i like this script Thanks to both of you!! Great stuff. In real life for this to work I had to make some slight changes with the $timer so that ^c would be sent at the appropriate time. It will still need some tweaking for universal application, though. I wonder if there is a completely different approach to getting the job done. Thanks again. AutoItSetOption ( "SendKeyDelay", '.01' ) AutoItSetOption ( "WinTitleMatchMode", 2 ) #include <misc.au3> While 1 If _IsPressed('01') = 1 Then Local $timer = TimerInit() While _IsPressed('01') If TimerDiff($timer) > 500 Then Sleep(1000) Send ("^c") ExitLoop EndIf Sleep(10) ToolTip(TimerDiff($timer)) WEnd EndIf Sleep (10) Wend Link to comment Share on other sites More sharing options...
Xkill Posted July 25, 2007 Share Posted July 25, 2007 Hi But for simulate a CTRL + CLICK LEFT ???? How to make? Sorry my english but i am italian :"> 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