Sign in to follow this  
Followers 0
Kard0

Problem with Hotkeys / Send functions

8 posts in this topic

I managed to create a script that keeps the Left Control key pressed down, but getting it back up just doesn't want to work as it should be. If I press the hotkey that should trigger the script that releases the hotkey it just won't happen, LCTRL still stays pressed down. Also, is it possible to attach it to a certain program names / windows only, so for example in FireFox CTRL won't be pressed, but in another window like notepad it will be pressed down.

Heres the code.

HotKeySet("{PGUP}", "ctrldown")
HotKeySet("{PGDN} ", "ctrlup")




Func ctrldown()
$ctrl = 1
$onoff3 = "ON"
$color3 = "0x008000"
GUICTRLSetColor($control,$color3)
GUICTRLSetdata($control,$onoff3)
Send("{LCTRL down}")


EndFunc

Func ctrlup()
$onoff3 = "OFF"
$color3 = "0xff0000"
Send("{LCTRL up}")
GUICTRLSetColor($control,$color3)
GUICTRLSetdata($control,$onoff3)

EndFunc

I took out the parts that just make going over the code a bit longer, colors, GUI etc.

Kardo.

Share this post


Link to post
Share on other sites



It's not that case, the FAQ you sent me says, if a key gets stuck after just Send key, I'm forcing it to stay down with Send keyname down behind it. After its down, I also made a hotkey to trigger a function that releases it, but it just doesn't to release it. Also, still a question to me, how can I make the script attach it to some certain window names, so that If I'm on msn for example and lets say Right Click is ON, then it would only work inside certain windows. A bit messy but I hope I managed to explain my idea.

Kardo

PS: I love the small text in your Signature, no clue why.

Share this post


Link to post
Share on other sites

Well, in my timezone, its a new day, and still the same problem, would love if someone could help me out. Thank you.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It's not that case, the FAQ you sent me says, if a key gets stuck after just Send key, I'm forcing it to stay down with Send keyname down behind it. After its down, I also made a hotkey to trigger a function that releases it, but it just doesn't to release it. Also, still a question to me, how can I make the script attach it to some certain window names, so that If I'm on msn for example and lets say Right Click is ON, then it would only work inside certain windows. A bit messy but I hope I managed to explain my idea.

Kardo

PS: I love the small text in your Signature, no clue why.

Look at WinExist or ControlFocus, etc... the Control_____ or Win_______ functions with some loop command for return status.

Edited by targeter

Share this post


Link to post
Share on other sites

OnAutoItExitRegister("_Exit")

Global $onoff3

HotKeySet("{PGUP}", "ctrldown")
HotKeySet("{PGDN} ", "ctrlup")

While 1
    Sleep(100)
    If WinActive("Firefox") And $onoff3 = "ON" Then ctrlup()
WEnd

Func ctrldown()
    $ctrl = 1
    $onoff3 = "ON"
    $color3 = "0x008000"
    GUICtrlSetColor($control, $color3)
    GUICtrlSetData($control, $onoff3)
    Send("{LCTRL down}")
EndFunc   ;==>ctrldown

Func ctrlup()
    $onoff3 = "OFF"
    $color3 = "0xff0000"
    Send("{LCTRL up}")
    GUICtrlSetColor($control, $color3)
    GUICtrlSetData($control, $onoff3)
EndFunc   ;==>ctrlup

Func _exit()
    ctrlup()
    Exit
EndFunc   ;==>_exit

Try this.

Share this post


Link to post
Share on other sites

I have the same problem. I found this problem on the same keys pressed to activate Hotkey.

I need to press the same key to get control.

Here is a little script with this problem used in Visual Studio 2008

HotKeySet("^+p", "Namespace")
HotKeySet("^+e", "Terminate")

While 1
    Sleep(100)
WEnd

func Namespace()
    Send("namespace Cap15 {{} ^{END} {}} ")
EndFunc

func Terminate()
    Exit
EndFunc

I use this to add namespace to many source. When script terminates I need to press SHIFT and CTRL.

Share this post


Link to post
Share on other sites

HotKeySet("{PGUP}", "ctrldown")

HotKeySet("{PGDN} ", "ctrlup")

i think that your problem would be here

you are waiting for the user to press PageDown, however, once ctrl is held down, the user is actually pressing ctrl-pagedown.

use HotKeySet("^{PGDN}", "ctrlup")

also, if a user presses ctrl when ctrl is held down, the button is released. just an fyi. (you could block it so that they cant press it)

legoman

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  
Followers 0