tp9191 Posted March 15, 2013 Share Posted March 15, 2013 (edited) When I hold down F8, I want it to send shiftdown and hold down the right arrow. And same thing for F7, except left arrow instead of right. Is Send suitable for this or should I rather use IsPressed, or do they get the same thing done? #include <Misc.au3> HotKeySet("{F7}", "F7") HotKeySet("{F8}", "F8") HotKeySet("{F11}", "Terminate") While 1 Sleep (100) WEnd Func F8() Send ("{SHIFTDOWN}{RIGHT}") EndFunc Func Terminate() Exit 0 EndFunc That's all I got because I am terrible with this. And I imagine I would have to send SHIFTUP upon release which makes this even more confusing to me. EDIT: #include <Misc.au3> While If _IsPressed ("76") Then Send ("{SHIFTDOWN}{RIGHT}") EndIf WEnd Or how about that? I'm a bit confused how to release shift still, too. EDIT 2: Or dis? #include <Misc.au3> While 1 If _IsPressed ("76") Then Send ("+{LEFT}") EndIf WEnd While 1 If _IsPressed ("77") Then Send ("+{RIGHT}") EndIf WEnd Both don't work at same time though. hmm.. Edited March 15, 2013 by tp9191 Link to comment Share on other sites More sharing options...
JohnOne Posted March 15, 2013 Share Posted March 15, 2013 Which one does work? 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...
tp9191 Posted March 15, 2013 Author Share Posted March 15, 2013 (edited) The 77 one doesn't work. (F8) PS. Is email notify broke? Edited March 15, 2013 by tp9191 Link to comment Share on other sites More sharing options...
FireFox Posted March 15, 2013 Share Posted March 15, 2013 @tp9191 #include <Misc.au3> While 1 If _IsPressed("77") Then ConsoleWrite("toto" & @CRLF) EndIf WEnd 1. Nothing in the console, a program is blocking the key on your pc. 2. toto in the console, the Send function does not work as you expected. Br, FireFox. Link to comment Share on other sites More sharing options...
tp9191 Posted March 15, 2013 Author Share Posted March 15, 2013 Thanks for the response. After trying it again, and being able to test, they BOTH individually do work, 76, and 77, but not when they are in the script together. Just to give you an idea.. in the program I am using it for, the normal functions are as follows: F7 - zoom out F8 - zoom in shift+ < - previous frame shift+ > - next frame So basically I want previous frame and next frame to bind to F7 and F8 keys, respectively, instead. #include While 1 If _IsPressed ("76") Then Send ("+{LEFT}") EndIf WEnd While 1 If _IsPressed ("77") Then Send ("+{RIGHT}") EndIf WEnd Link to comment Share on other sites More sharing options...
FireFox Posted March 16, 2013 Share Posted March 16, 2013 but not when they are in the script together. Indeed, here is why : #include <Misc.au3> While 1 ;endless loop If _IsPressed ("76") Then Send ("+{LEFT}") EndIf WEnd ;there is no exitloop, everything below will NOT be executed. While 1 ... Correct code : #include <Misc.au3> While 1 If _IsPressed ("76") Then Send ("+{LEFT}") ElseIf _IsPressed ("77") Then Send ("+{RIGHT}") EndIf WEnd Understood ? Br, FireFox. Link to comment Share on other sites More sharing options...
tp9191 Posted March 16, 2013 Author Share Posted March 16, 2013 Indeed, here is why : #include <Misc.au3> While 1 ;endless loop If _IsPressed ("76") Then Send ("+{LEFT}") EndIf WEnd ;there is no exitloop, everything below will NOT be executed. While 1 ... Correct code : #include <Misc.au3> While 1 If _IsPressed ("76") Then Send ("+{LEFT}") ElseIf _IsPressed ("77") Then Send ("+{RIGHT}") EndIf WEnd Understood ? Br, FireFox. Yes thank you, that works now. I can't believe I didn't think to use that conditional statement. But I have some questions: 1. It's using 25% CPU, I can just stick a sleep loop in there now, right? 2. The program is zooming out/in since it shares the F7/F8 key. Is there a way to block the original function of those keys? 3. No need to release shift, correct? Link to comment Share on other sites More sharing options...
FireFox Posted March 16, 2013 Share Posted March 16, 2013 1. It's using 25% CPU, I can just stick a sleep loop in there now, right? Right, you can set its value depending on how fast you want it to respond. 2. The program is zooming out/in since it shares the F7/F8 key. Is there a way to block the original function of those keys? HotKeySet 3. No need to release shift, correct? Yes, the send function presses and releases the keys as you were taping on your keyboard unless you are using the DOWN word (e.g: "{LSHIFTDOWN}"). Here you go : #include <Misc.au3> HotKeySet("{F7}", "_none") HotKeySet("{F8}", "_none") While 1 If _IsPressed ("76") Then Send("+{LEFT}") ElseIf _IsPressed ("77") Then Send("+{RIGHT}") EndIf Sleep(50) WEnd Func _none() EndFunc Br, FireFox. Link to comment Share on other sites More sharing options...
tp9191 Posted March 18, 2013 Author Share Posted March 18, 2013 Right, you can set its value depending on how fast you want it to respond. HotKeySet Yes, the send function presses and releases the keys as you were taping on your keyboard unless you are using the DOWN word (e.g: "{LSHIFTDOWN}"). Here you go : #include <Misc.au3> HotKeySet("{F7}", "_none") HotKeySet("{F8}", "_none") While 1 If _IsPressed ("76") Then Send("+{LEFT}") ElseIf _IsPressed ("77") Then Send("+{RIGHT}") EndIf Sleep(50) WEnd Func _none() EndFunc Br, FireFox. Thank you for all your help so far. I was now wondering how it would look like if I wanted to lock in the button hold until I pressed either the same keys again (F7 or F8), or perhaps any key on the keyboard, too. #include <Misc.au3> HotKeySet("{F7}", "_none") HotKeySet("{F8}", "_none") While 1 If _IsPressed ("76") Then Send("+{LEFT}") Until _IsPressed ("76") ElseIf If _IsPressed ("77") Then Send("+{RIGHT}") Until _IsPressed ("77") EndIf Sleep(50) Wend Func _none() EndFunc It says no matching While statement right now for me. I imagine it has to do something with an illegal combination of the Then's and Until's? I can't figure it out though. I tried a couple other things but I figured I'd only embarrass myself one time per post maximum. . I also tried messing around with While's instead of If's and also Do's. 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