Hello, i need help for scripting
I was able to script my moves in a game but the problem is i may need the cancel the action and use another combination. instead
So here is what i did
Tab::
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2, D
Sleep, 1000
MouseClick , LEFT , , , 1, 2, U
Sleep, 400
and
q::
send, 1
Sleep, 50
MouseClick , RIGHT , , , 1, 2, D
Sleep, 500
MouseClick , RIGHT , , , 1, 2, U
Sleep, 400
the scripts are all good one by one.... what i really need is to cancel my 'Tab' action upon pressing 'q' button and do the 'q' action instead...
To be more clear: I want a way to end a script without Quitting the app, even if it's in the middle of executing some code. Is that possible?
any help would greatly appreciated
cancel/stop the previous action...
Re: cancel/stop the previous action...
You could maybe do it with Suspend or some method of "Quitting" the app, but you would probably be better off using some simple logic.
Something like this:
Something like this:
Code: Select all
Interrupt := 0
Tab::
MouseClick , LEFT , , , 1, 2
Sleep, 400
if (Interrupt) return
MouseClick , LEFT , , , 1, 2
Sleep, 400
if (Interrupt) return
MouseClick , LEFT , , , 1, 2
Sleep, 400
if (Interrupt) return
MouseClick , LEFT , , , 1, 2
Sleep, 400
if (Interrupt) return
MouseClick , LEFT , , , 1, 2, D
Sleep, 1000
if (Interrupt) return
MouseClick , LEFT , , , 1, 2, U
Sleep, 400
return
q::
Interrupt := 1
send, 1
Sleep, 50
MouseClick , RIGHT , , , 1, 2, D
Sleep, 500
MouseClick , RIGHT , , , 1, 2, U
Sleep, 400
Interrupt := 0
return
Re: cancel/stop the previous action...
Tnx for the reply. But this doesnt work either. Now the issue is when i hit tab button it only does the first action which is 'MouseClick , LEFT , , , 1, 2' and then stops... so i cant tell if the interrupt code works or not
Re: cancel/stop the previous action...
okay i want to try something different. What should i add to script if i want the 'Tab's button on push down only... I mean when i hit the 'Tab button it does what it does but is it possible to do the process on holding pushing down the button (Tab) only and when i release it stops the script running even if its in the middle of the process.
Re: cancel/stop the previous action...
Tab up:: only triggers on release of the key.
Re: cancel/stop the previous action...
M8 tnx for your answers but that wasnt what i've asked. I want the Tab button do its job only when i push it down and when i release it i want the script stop even if its in the middle of the process
IE:
I hold down the Tab button and it starts
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
and i released tab (so the rest of the actions whhich is below wont be triggered)
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2, D
Sleep, 1000
MouseClick , LEFT , , , 1, 2, U
Sleep, 400
is it possible?
IE:
I hold down the Tab button and it starts
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2
Sleep, 400
and i released tab (so the rest of the actions whhich is below wont be triggered)
MouseClick , LEFT , , , 1, 2
Sleep, 400
MouseClick , LEFT , , , 1, 2, D
Sleep, 1000
MouseClick , LEFT , , , 1, 2, U
Sleep, 400
is it possible?
Re: cancel/stop the previous action...
Yes, as I said, you want to hook into the up event.
Another way to do it would be to use GetKeyState() to check the state of the key, but the way I show here is probably more CPU efficient.
Also notice that I put the click parameters into an array, so we can easily check the state of the button without having to have loads of if blocks in the code.
(Untested code, but hopefully you get the idea...)
Another way to do it would be to use GetKeyState() to check the state of the key, but the way I show here is probably more CPU efficient.
Also notice that I put the click parameters into an array, so we can easily check the state of the button without having to have loads of if blocks in the code.
(Untested code, but hopefully you get the idea...)
Code: Select all
button_held := 0
button_sequence := [{btn: "LEFT", count: 1, speed: 2, event: "", sleep: 400}, {btn: "LEFT", count: 1, speed: 2, event: "D", sleep: 1000}, {btn: "LEFT", count: 1, speed: 2, event: "U", sleep: 400}]
Tab::
; Ignore key repeats (The down event will fire repeatedly while the key is held)
if (button_held){
return
}
max := button_sequence.length()
ctr := 1
; Set up an infinite loop
loop {
if (!button_held){
; Button released, stop
break
}
MouseClick, % button_sequence[ctr].btn, , , % button_sequence[ctr].count, % button_sequence[ctr].speed, % button_sequence[ctr].event
Sleep % button_sequence[ctr].sleep
ctr++
; reset ctr when we get to the end of the array
if (ctr > max){
ctr := 1
}
}
return
Tab up::
; Set button_up to 0, so the main loop stops.
button_held := 0
return
Who is online
Users browsing this forum: spisi69 and 23 guests