LiberrY Posted October 12, 2008 Share Posted October 12, 2008 Hi there, im not very new to AutoIt but im not perfect in scripting now my question: how do i do something like this: i press "q" and the script presses 5 times left mouse buttoni thought something like that:$var1=?pressedkey?("q")while $var1=$var1do mouseclick("left")do mouseclick("left")do mouseclick("left")do mouseclick("left")do mouseclick("left")wend Link to comment Share on other sites More sharing options...
DW1 Posted October 12, 2008 Share Posted October 12, 2008 #include <Misc.au3> HotKeySet("{ESC}", "Leave") HotKeySet("q", "ClickMe") While 1 Sleep(10) ; For CPU usage sake WEnd Func ClickMe() While _IsPressed("51") ; Wait until Q is released to do action Sleep(10) ; Waiting for Q to be released to perform action WEnd MouseClick("Left", MouseGetPos(0), MouseGetPos(1), 5) ; Action: Click left mouse button 5 times where mouse currently sitsq EndFunc ;==>ClickMe Func Leave() Exit EndFunc ;==>Leave AutoIt3 Online Help Link to comment Share on other sites More sharing options...
SoulA Posted October 12, 2008 Share Posted October 12, 2008 HotKeySet("q", "sup") While 1 Sleep(100) WEnd Func sup() For $i = 1 to 5 MouseClick("left") Next EndFunc Link to comment Share on other sites More sharing options...
LiberrY Posted October 12, 2008 Author Share Posted October 12, 2008 thx guy for quick reply, the script is working but only when i press q for a while, so when i press q only very short it is only pressing left mouse button one time, when i hold q 3-5 seconds its doing its job. maybe this is fixable? Link to comment Share on other sites More sharing options...
DW1 Posted October 12, 2008 Share Posted October 12, 2008 (edited) Ooops, forgot to switch the hotkey status. #include <Misc.au3> HotKeySet("{ESC}", "Leave") HotKeySet("q", "ClickMe") While 1 Sleep(10) ; For CPU usage sake WEnd Func ClickMe() HotKeySet("q", "Nothing" ) While _IsPressed("51") ; Wait until Q is released to do action Sleep(10) ; Waiting for Q to be released to perform action WEnd MouseClick("Left", MouseGetPos(0), MouseGetPos(1), 5) ; Action: Click left mouse button 5 times where mouse currently sitsq HotKeySet("q", "ClickMe") EndFunc ;==>ClickMe Func Nothing() Sleep(1); Nothing EndFunc Func Leave() Exit EndFunc ;==>Leave EDIT: Second oops, Fixed so you don't get q's pressed at all Edited October 12, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
LiberrY Posted October 12, 2008 Author Share Posted October 12, 2008 thank you, but it does only half its job, because sometimes it only presses one time, sometimes 3, sometimes nothing happens, everytime its based on how long i press q. when i only tip it it only presses one time. Link to comment Share on other sites More sharing options...
DW1 Posted October 12, 2008 Share Posted October 12, 2008 Perhaps the game is not picking up the clicks fast enough. Try this with delay: #include <Misc.au3> Global $delay = 10 ; Adjust delay here HotKeySet("{ESC}", "Leave") HotKeySet("q", "ClickMe") While 1 Sleep(10) ; For CPU usage sake WEnd Func ClickMe() HotKeySet("q", "Nothing" ) While _IsPressed("51") ; Wait until Q is released to do action Sleep(10) ; Waiting for Q to be released to perform action WEnd For $a = 1 To 5 MouseClick("Left") ; Action: Click left mouse button 5 times where mouse currently sitsq Sleep($delay) Next HotKeySet("q", "ClickMe") EndFunc ;==>ClickMe Func Nothing() Sleep(1); Nothing EndFunc Func Leave() Exit EndFunc ;==>Leave AutoIt3 Online Help Link to comment Share on other sites More sharing options...
LiberrY Posted October 12, 2008 Author Share Posted October 12, 2008 sry, but not really working. btw, where did you know from that its for a game xD Link to comment Share on other sites More sharing options...
DW1 Posted October 12, 2008 Share Posted October 12, 2008 Increase the delay amount AutoIt3 Online Help Link to comment Share on other sites More sharing options...
LiberrY Posted October 12, 2008 Author Share Posted October 12, 2008 (edited) ahh thank you, i edited the script a little bit so that its working perfect now, again thank you very much, you're my hero now xD EDIT: can someone pls tell me how to use "Shift" as hotkey? i know that ALT is "!" but what is shift? edit2: i found out how it works but thx Edited October 12, 2008 by LiberrY 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