divadnivip007 Posted February 13, 2012 Posted February 13, 2012 Hey, First I am a newb with AutoIt. I've tried to do it by myself but I cannot figure how to manage the function "If is pressed again". Is there a way to do something like this: If "F2" is pressed then send "1" If "F2" is pressed again then send "2" If "F2" is pressed again send "1" If "F2" is pressed again then send "2" Here is my script so far: While 1 If _IsPressed("71") = 1 Then ;IF F2 is pressed Send("{1}") ; Send 1 Thx a lot Dave
iamtheky Posted February 13, 2012 Posted February 13, 2012 (edited) give your ispressed if statement other criteria to determine the 1 or the 2. This should alternate 1 and 2 as you hold down F2... #Include <Misc.au3> $flag = 0 while 1 If _ispressed(71) And $flag = 1 Then send ("2") $flag = 0 elseif _ispressed(71) And $flag <> 1 Then send ("1") $flag = 1 Endif sleep (100) Wend Edited February 13, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
divadnivip007 Posted February 14, 2012 Author Posted February 14, 2012 Great script. Could it be changed so I don't have to hold down "F2"? I would like to send a different number every time I presses "F2" and make a infinite loop for it. Thx Dave
iamtheky Posted February 14, 2012 Posted February 14, 2012 This is probably better anyway. hotkeyset("{F2}" , "one") Func one() send ("1") hotkeyset("{F2}" , "two") EndFunc Func two() send ("2") hotkeyset("{F2}" , "one") EndFunc while 1 sleep (5) Wend ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
divadnivip007 Posted February 14, 2012 Author Posted February 14, 2012 It works perfectly! Thx a lot Boththose!!
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