Jump to content

HotkeySet, hold shift down and send right arrow


Recommended Posts

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 by tp9191
Link to comment
Share on other sites

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

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

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

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

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. :P.

I also tried messing around with While's instead of If's and also Do's.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...