AutoHotkey Community

It is currently May 26th, 2012, 2:25 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: loop/hotkey quesiton
PostPosted: January 21st, 2009, 4:23 am 
Offline

Joined: January 20th, 2009, 9:35 pm
Posts: 16
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: loop/hotkey quesiton
PostPosted: January 21st, 2009, 4:25 am 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
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.

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 4:58 am 
Offline

Joined: January 20th, 2009, 9:35 pm
Posts: 16
sorry i thought it was apparent.

just trying to toggle the tooltip on and off depending on when i press the endkey.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 5:25 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5478
Location: the tunnel(?=light)
It might be easier to toggle with SetTimer.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 5:28 am 
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 :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 5:31 am 
Offline

Joined: January 20th, 2009, 9:35 pm
Posts: 16
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 :)


this was a very handy piece of info, this was exactly what the problem was. thank you very much.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 6:18 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: G. Sperotto, poserpro, SKAN, Yahoo [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group