AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What am I doing wrong?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Larnen
Guest





PostPosted: Sun May 11, 2008 8:22 pm    Post subject: What am I doing wrong? Reply with quote

A very simple script. When i move the mouse wheel up I want it to repeat a key sequence until i move the mouse wheel down. It should then stop until I next mouse wheel up. Here is the script with B being the hammered key. I have added a sending of 'A' to show the problem:

#HotkeyInterval 2000
#MaxHotkeysPerInterval 70
#InstallMouseHook
#IfWinActive ahk_class Notepad

$WheelUp::
Loop
{
Send A
if GetKeyState("WheelDown", "P")
break
Send B
Sleep, 50
}
return


When I reload this script and open up a notepad window and then hit mouse wheel up, I get (as you would expect):

ABABABABABABABABABABAB

AB keeps repeating until i mouse wheel down. As soon as I do it stops.

So far so good, but when i then mouse wheel up again, I just get:

A

In other words - once I have mouse wheel down once it seems to get 'stuck' and assume it is then always down. However clearly this isnt happening for mouse wheel up - or Id have a constant AAAAAA.

Anyone know whats going on?
Back to top
n-l-i-d
Guest





PostPosted: Sun May 11, 2008 8:26 pm    Post subject: Reply with quote

Quote:
What am I doing wrong?


1. You are posting in the wrong forum section
2. You use a useless title for your posting
3. You didn't use the code-tags
Back to top
Gosugenji



Joined: 07 May 2008
Posts: 13
Location: In your Internets

PostPosted: Sun May 11, 2008 9:30 pm    Post subject: Switch & Timer approach :) Reply with quote

I used my switch and timer approach to solve your little problem.

Code:

#HotkeyInterval 2000
#MaxHotkeysPerInterval 70
#InstallMouseHook
#IfWinActive ahk_class Notepad


SetTimer, Repeat, 50

$WheelUp::
{
Press=1
return
}
$WheelDown::
{
Press=0
return
}

Repeat:
SetTimer, Repeat, off
if (Press == 1)
{
Send A
Send B
}
SetTimer, Repeat, on
return
Back to top
View user's profile Send private message
Larnen
Guest





PostPosted: Mon May 12, 2008 12:22 am    Post subject: Re: Switch & Timer approach :) Reply with quote

Gosugenji wrote:
I used my switch and timer approach to solve your little problem.


Many thanks for your help - I will give this a go. Smile

As for the other responder, grow up. Being a forum nazi is the lowest rung of the evolutionary ladder.
Back to top
Elesar



Joined: 28 Jun 2007
Posts: 69

PostPosted: Mon May 12, 2008 12:55 am    Post subject: Re: Switch & Timer approach :) Reply with quote

Larnen wrote:

As for the other responder, grow up. Being a forum nazi is the lowest rung of the evolutionary ladder.


Maybe if you would follow the very simple forum outline, then nobody would have to be a forum nazi, and they could spend their time helping you instead of telling to you format your questions in the correct manner.

If you spend much time on the forum, you will see that, provided a poster follows the basic outline and is polite(at least not rude), there will be several people posting several possible answers to your questions.
Back to top
View user's profile Send private message
Z Gecko
Guest





PostPosted: Mon May 12, 2008 1:52 am    Post subject: Reply with quote

Quote:
As for the other responder, grow up. Being a forum nazi is the lowest rung of the evolutionary ladder.

I really donīt think that is appropriate.
daonlyfreez aka n-l-i-d is neither beeing a "forum-nazi" nor childish.
In fact, he one of the guys that are alway helping around when new-scripters ask questions,
even if they are so easy that quick look in the manual would have solved em.

And You were posting in the wrong forum, using a non-descriptive title and did not use the code-tags, what is really annoing when you try to read the code (especially if itīs just to help a stranger).

So be aware, that if you continue to be crappy, the people will stop talking to you.
So please read this: http://www.autohotkey.com/forum/topic4986.html before you post anything more.
Thank You. Sad
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group