Jump to content
Sign in to follow this  
tp9191

HotkeySet, hold shift down and send right arrow

Recommended Posts

tp9191

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

Share this post


Link to post
Share on other sites
tp9191

The 77 one doesn't work. (F8)

PS. Is email notify broke?

Edited by tp9191

Share this post


Link to post
Share on other sites
FireFox

@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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
tp9191

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

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
tp9191

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?

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
tp9191

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.

Share this post


Link to post
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
Sign in to follow this  

×