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 

loop/hotkey quesiton

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 3:23 am    Post subject: loop/hotkey quesiton Reply with quote

does anyone know why this isnt working? and if there is a better way to do this?

switch := 1
End:: switch/=-1


loop
{
if switch = 1
tooltip running
sleep 500
}
Back to top
View user's profile Send private message
SpiderGames



Joined: 09 Jun 2008
Posts: 936
Location: Canada

PostPosted: Wed Jan 21, 2009 3:25 am    Post subject: Re: loop/hotkey quesiton Reply with quote

ifckladyluck wrote:
does anyone know why this isnt working? and if there is a better way to do this?

switch := 1
End:: switch/=-1


loop
{
if switch = 1
tooltip running
sleep 500
}


It helps if you tell us what you are trying to do.
_________________

I know i have 6 legs. It's cuz I'm special.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 3:58 am    Post subject: Reply with quote

sorry i thought it was apparent.

just trying to toggle the tooltip on and off depending on when i press the endkey.
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Wed Jan 21, 2009 4:25 am    Post subject: Reply with quote

It might be easier to toggle with SetTimer.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Wed Jan 21, 2009 4:28 am    Post subject: Reply with quote

The 1st problem is that the script never runs far enough to get to the loop. When you run the code you posted, it stops as soon as it hits End:: switch/=-1 (hotkeys mark the end of the Auto-Execute section of a script).

So put that below your loop and then you can finish debugging why your switch isn't working Smile
Back to top
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 4:31 am    Post subject: Reply with quote

Anonymous wrote:
The 1st problem is that the script never runs far enough to get to the loop. When you run the code you posted, it stops as soon as it hits End:: switch/=-1 (hotkeys mark the end of the Auto-Execute section of a script).

So put that below your loop and then you can finish debugging why your switch isn't working Smile


this was a very handy piece of info, this was exactly what the problem was. thank you very much.
Back to top
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Wed Jan 21, 2009 5:18 pm    Post subject: Reply with quote

My recommendation would be to use "*=" instead of "/=".

Code:
switch *= 1


My reasons:
1) it does the same thing
2) Multiplcation is ALWAYS faster than division.

3) Just some input of my own - you might want to do this instead.

Code:
switch := !switch


Then, you could use
Code:
if Switch
MsgBox, Do thing
else
MsgBox, Don't do thing


Plus, my quess is that the not operation ("!") is quicker than multiplication, but that's just my guess.
_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
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