 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Fri May 09, 2008 6:53 pm Post subject: Disable thread continue after interrupt |
|
|
Sorry about my english. IŽll do my best.
I made a script for a game call Imperium Ao.
The thing is that when I interrupt a thread with other one or with it self, it REALY bothers me that the thread interrupted continue after the other one finish.
Is necesary in this game to interrupt macros continually, so when I finish "fight" the mouse continue making moves for a very long time.
Conclusion, I need something that disable thread continue after interrupt of another hotkey or it self.
By the way, I am rookie.
Thanks for all. Here is may script:
#IfWinActive, ImperiumAO 1.42.0
#MaxThreads 20
#SingleInstance force
NumpadEnter::
Suspend, Permit
if (A_IsSuspended == 0)
Suspend, on
else
Suspend, off
return
#SingleInstance force
#MaxThreadsPerHotkey 20
#MaxHotkeysPerInterval 2000
Thread, interrupt, 1500
Numpad0::
Send {f8 down}{f8 up}
Sleep,20
Loop, 3
{
Send {f11 down}{f11 up}
Sleep,20
}
Loop 11
{
MouseClick, left, 285, 302
Send {f8 down}{f8 up}
Sleep,20
}
Loop 20
{
Send {f8 down}{f8 up}
Sleep,50
}
return
Thread, interrupt, 0
MButton::
Loop, 3
{
Send {f1 down}{f1 up}
Sleep,50
}
Loop, 10
{
Send {f7 down}{f7 up}
Sleep,30
}
Loop, 11
{
Send, {LButton}
Send {f7 down}{f7 up}
Sleep,30
}
Loop 2
{
Loop, 2
{
Send {f5 down}{f5 up}
Sleep,50
}
Loop, 11
{
Send, {LButton}
Send {f7 down}{f7 up}
Sleep,30
}
Loop, 8
{
Send {f7 down}{f7 up}
Sleep,30
}
}
Loop, 10
{
Send {f7 down}{f7 up}
Sleep,50
}
return
Thread, interrupt, 0
RButton::
Sleep,100
Send {f2 down}
Sleep,100
Send {f2 up}
Loop, 4
{
Send {f7 down}{f7 up}
Sleep,50
}
Sleep,1000
return
Thread, interrupt, 0
Numpad1::
Sleep,100
Send {f11 down}
Sleep,100
Send {f11 up}
Loop, 4
{
Send {f7 down}{f7 up}
Sleep,50
}
Sleep,1000
return
Thread, interrupt, 0
WheelDown::
#MaxThreadsPerHotkey 1
Loop 3
{
Loop, 2
{
Send {f5 down}{f5 up}
Sleep,50
}
Loop, 11
{
Send, {LButton}
Send {f7 down}{f7 up}
Sleep,30
}
}
return |
|
| Back to top |
|
 |
Razlin
Joined: 05 Nov 2007 Posts: 434 Location: canada
|
Posted: Fri May 09, 2008 7:03 pm Post subject: |
|
|
not the best way to do this but this should work for you
will stop execution and reload the script. when you hit esacpe.
Like I said.. this is not the right wait to do this but is the simplest way for me to help; _________________ -=Raz=- |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Fri May 09, 2008 7:13 pm Post subject: |
|
|
Well, It seams that I could express me problem in english IŽam realy proud of mi self.
Thanks, itŽs usefull, but in this game moving my hand tu "escape" botton costs me to much time...so IŽam dead....
But if nothing better exist, I have no doubt that it will improve my play |
|
| Back to top |
|
 |
rashard Guest
|
Posted: Fri May 09, 2008 7:25 pm Post subject: |
|
|
Welcome!
_____________________________________
Rashard likes sirens.  |
|
| Back to top |
|
 |
Mkbailey755
Joined: 20 Aug 2007 Posts: 178
|
Posted: Sat May 10, 2008 4:31 am Post subject: |
|
|
You can set it to whatever you like just change
Escape to "whatever"
Instead of
you could have
or |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Sat May 10, 2008 4:51 am Post subject: |
|
|
Yes I know that, but I mean, pressing any key has realy much cost.
Is nothing I can do to make a thread be completly stoped when another hotkey is hit? |
|
| Back to top |
|
 |
Razlin
Joined: 05 Nov 2007 Posts: 434 Location: canada
|
Posted: Mon May 12, 2008 12:14 pm Post subject: |
|
|
I really dont know what your trying to accomplish with your "game"
as most of your loops could be removed and used single send command
example
| Code: | ;your code ##############
Loop, 3
{
Send {f1 down}{f1 up}
Sleep,50
}
Loop, 10
{
Send {f7 down}{f7 up}
Sleep,30
}
;my code ##################3
SetKeyDelay, 50
send {F1 3}
SetKeyDelay, 30
send {F7 10}
Loop, 11
{
click
Send {f7 down}{f7 up}
} |
I'm not 100% sure of the internal architecture of ahk but I think thoes are both the same.
you could use a suspend option with a key that would also disable your keys.
look up suspend on forums
or toggle hotkeys. _________________ -=Raz=- |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Mon May 12, 2008 2:24 pm Post subject: |
|
|
What happends if I put after each hotkey something like this???
Mbutton::
Send {escape}
and then continue the thread....
return
escape::reload
That will stop completly previus threads?? |
|
| Back to top |
|
 |
Razlin
Joined: 05 Nov 2007 Posts: 434 Location: canada
|
Posted: Mon May 12, 2008 3:10 pm Post subject: |
|
|
no that wont work. in theory that will just reload your script and never continue
| Code: | Mbutton:: ; hit mbutton
Send {escape} ; reload. which means restart and wipe out all variables in ahk memory
and then continue the thread.... ;will never get executed
return |
code gets executed from top to bottom. there is more then one way to get out
-one is reload << not right but will get out.
-using a trigger.
example
| Code: |
loop ;loop for ever and ever and ever UNLESS break.
{
getkeystate, activateKey, scrolllock, T ;check scrolllock key
if activatekey = D ;key was pushed get out
{
tooltip
break; ;stop looping get out
}
tooltip, I'm working here ;key was not pushed dont get out of loop
}
|
Hope this helps a bit _________________ -=Raz=- |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Mon May 12, 2008 3:37 pm Post subject: |
|
|
Thanks a lot Raz, a realy complete answer.
By the moment the easyest solution I found is to put a "Reload" before the "return" in each thread. Seams to good, but sometimes the script intead of reload, it opens again like a different script (so I the same script open 2 times in my sistem).
I like to improve this using this trigger, but I realy donŽt undertand how to make it usefull in my script. Please give mi a hand, this is how it is working now:
| Code: |
#IfWinActive, ImperiumAO 1.42.0
#MaxThreads 20
#SingleInstance force
NumpadEnter::
Suspend, Permit
if (A_IsSuspended == 0)
Suspend, on
else
Suspend, off
return
#SingleInstance force
#MaxThreadsPerHotkey 20
#MaxHotkeysPerInterval 2000
Thread, interrupt, 500
Numpad0::
Send {f8 down}{f8 up}
Sleep,20
Loop, 3
{
Send {f11 down}{f11 up}
Sleep,20
}
Loop 11
{
MouseClick, left, 285, 302
Send {f8 down}{f8 up}
Sleep,20
}
Loop 20
{
Send {f8 down}{f8 up}
Sleep,50
}
Reload
return
Thread, interrupt, 0
MButton::
Loop, 3
{
Send {f1 down}{f1 up}
Sleep,50
}
Loop, 10
{
Send {f7 down}{f7 up}
Sleep,30
}
Loop, 11
{
Send, {LButton}
Send {f7 down}{f7 up}
Sleep,30
}
Loop 2
{
Loop, 2
{
Send {f5 down}{f5 up}
Sleep,50
}
Loop, 11
{
Send, {LButton}
Send {f7 down}{f7 up}
Sleep,30
}
Loop, 8
{
Send {f7 down}{f7 up}
Sleep,30
}
}
Loop, 10
{
Send {f7 down}{f7 up}
Sleep,50
}
Reload
return
Thread, interrupt, 0
RButton::
Sleep,100
Send {f2 down}
Sleep,100
Send {f2 up}
Loop, 4
{
Send {f7 down}{f7 up}
Sleep,50
}
Sleep,1000
return
Thread, interrupt, 0
Numpad1::
Sleep,100
Send {f11 down}
Sleep,100
Send {f11 up}
Loop, 4
{
Send {f7 down}{f7 up}
Sleep,50
}
Sleep,1000
return
Thread, interrupt, 0
WheelDown::
#MaxThreadsPerHotkey 1
Loop 3
{
Loop, 2
{
Send {f5 down}{f5 up}
Sleep,50
}
Loop, 11
{
Send, {LButton}
Send {f7 down}{f7 up}
Sleep,30
}
}
Reload
return
escape::reload
|
Bye |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|