How to give a life time for a Variable ?

Get help with using AutoHotkey and its commands and hotkeys
dsewq1LYJ
Posts: 114
Joined: 26 Aug 2014, 23:21

How to give a life time for a Variable ?

21 Sep 2015, 16:36

Follow is my code:

Code: Select all

SS1:
LS1:=1
Exit
SS2:
LS2:=1
Exit
SS3:
LS3:=1
Exit

CMB:
if LS1
PixelGetColor,S1,1,1
if LS2
PixelGetColor,S2,2,2
if LS3
PixelGetColor,S3,3,3
if LS4
PixelGetColor,S4,4,4

if (S1=0x000000){
	LS1:=0
	SetTimer,SS1,-2000
} if (S2=0x111111){
	LS2:=0
	SetTimer,SS2,-2000
} if (S3=0x333333){
	LS3:=0
	SetTimer,SS3,-2000
}

if (S1<>0x000000)
	Send A
if (S2<>0x111111 && S1=0x222222)
	Send B
if (S3<>0x333333 && S1=0x222222 && S2=0x111111)
	Send C
if (S4<>0x444444 && S1=0x222222 && S2=0x111111 && S3=0x333333)
	Send D
Exit
As you can see.
I wanna make LS1,LS2,LS3 revert to 1 after 2,000 ms, and of course SS1,SS2,SS3 will interrupt the main label CMB.

I ask the almost same situation in previous post.
http://ahkscript.org/boards/viewtopic.p ... 479#p52479

but this time I wanna know how to figure it out...(Revert vairables and without any interruption.)
I still stuck in it(My brain too...) : [
Last edited by dsewq1LYJ on 21 Sep 2015, 16:53, edited 1 time in total.
guest3456
Posts: 3109
Joined: 09 Oct 2013, 10:31

Re: How to give a life time for a Variable ?

21 Sep 2015, 16:47

why are you using Exit instead of return? using Exit in the SS* labels won't interrupt the CMB label because SetTimer created a new thread. i've never used Exit nor have i ever seen anyone else use it, and i had to read the docs just now to understand what it does

does this not do it?

Code: Select all

SS1:
   LS1:=1
return

SS2:
   LS2:=1
return

SS3:
   LS3:=1
return

 
CMB:
   if LS1
   PixelGetColor,S1,1,1
   if LS2
   PixelGetColor,S2,2,2
   if LS3
   PixelGetColor,S3,3,3
   if LS4
   PixelGetColor,S4,4,4
    
   if (S1=0x000000){
           LS1:=0
           SetTimer,LS1,-2000
           return
   } if (S2=0x111111){
           LS2:=0
           SetTimer,LS2,-2000
           return
   } if (S3=0x333333){
           LS3:=0
           SetTimer,LS3,-2000
           return
   }
    
   if (S1<>0x000000)
           Send A
   if (S2<>0x111111 && S1=0x222222)
           Send B
   if (S3<>0x333333 && S1=0x222222 && S2=0x111111)
           Send C
   if (S4<>0x444444 && S1=0x222222 && S2=0x111111 && S3=0x333333)
           Send D
return

dsewq1LYJ
Posts: 114
Joined: 26 Aug 2014, 23:21

Re: How to give a life time for a Variable ?

21 Sep 2015, 16:56

guest3456 wrote:why are you using Exit instead of return? using Exit in the SS* labels won't interrupt the CMB label because SetTimer created a new thread. i've never used Exit nor have i ever seen anyone else use it, and i had to read the docs just now to understand what it does

does this not do it?

Code: Select all

SS1:
   LS1:=1
return

SS2:
   LS2:=1
return

SS3:
   LS3:=1
return

 
CMB:
   if LS1
   PixelGetColor,S1,1,1
   if LS2
   PixelGetColor,S2,2,2
   if LS3
   PixelGetColor,S3,3,3
   if LS4
   PixelGetColor,S4,4,4
    
   if (S1=0x000000){
           LS1:=0
           SetTimer,LS1,-2000
           return
   } if (S2=0x111111){
           LS2:=0
           SetTimer,LS2,-2000
           return
   } if (S3=0x333333){
           LS3:=0
           SetTimer,LS3,-2000
           return
   }
    
   if (S1<>0x000000)
           Send A
   if (S2<>0x111111 && S1=0x222222)
           Send B
   if (S3<>0x333333 && S1=0x222222 && S2=0x111111)
           Send C
   if (S4<>0x444444 && S1=0x222222 && S2=0x111111 && S3=0x333333)
           Send D
return
I edited my post (I type the wrong label name of SetTimer :headwall: )
and I can not add return in condition about S1,S2,S3.
It would not go to the Send area.
--------------
I replace "Exit" to "Return" but the LS1,LS2,LS3 won't revert to 1...
but at least ~ the "Return" won't block CMB.
guest3456
Posts: 3109
Joined: 09 Oct 2013, 10:31

Re: How to give a life time for a Variable ?

21 Sep 2015, 17:06

answer this, why do you want to wait 2 seconds before resetting the variable?

dsewq1LYJ
Posts: 114
Joined: 26 Aug 2014, 23:21

Re: How to give a life time for a Variable ?

21 Sep 2015, 17:20

guest3456 wrote:answer this, why do you want to wait 2 seconds before resetting the variable?
OMG...My brain is totally f**k off...I just need to take a break...Over 20 hours without sleep :HeHe: ............. :crazy:
You really solve my problem...all issues just from "Exit"

I replace all "Exit" to "Return" everything works just "AWESOME".

and the answer is ~ I give a life time to variable to reduce the usage.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, Google [Bot], JackMa, rpgfreak128 and 250 guests