Problem with conditions when keys push up

Ask gaming related questions (AHK v1.1 and older)
69latrik
Posts: 3
Joined: 19 Nov 2015, 04:37

Problem with conditions when keys push up

19 Nov 2015, 04:41

Here is my actual script :

I press key "&" for 1 second to 3 second (its random depending on the situation)
When "&" is up my actual script do action 1 :

Code: Select all

~& Up::
{

Action 1

}

Return
I Want to do this :

IF DURING THE TIME OF "&" IS DOWN USING KEY 5 THEN DONT DO ACTION 1 WHEN "&" IS UP (Just do nothing)


Exemple :

Without action 1 :

& Down
Send 5
& Up
Do Nothing


With action 1 :

& Down
& Up
Action 1


Do you have any ideas ? Its possible ?

Thanks
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Problem with conditions when keys push up

19 Nov 2015, 05:22

Code: Select all

#singleinstance force
amp_down := 0
5_pressed := 0
return

*~&::
	amp_down := 1
	return

*~& up::
	amp_down := 0
	if (!5_pressed){
		GoSub, Action1
	}
	5_pressed := 0
	return

*~5::
	if (amp_down){
		5_pressed := 1
	}
	return

Action1:
	msgbox & released without 5 being pressed
	return
	
Also, be aware that if you Send keys as part of Action1, then the Shift key will be held, so executing a Send {a} would release shift, then send A, then hit Shift again, which would result in strange behavior.
To avoid this, see the {Blind} option for Send
69latrik
Posts: 3
Joined: 19 Nov 2015, 04:37

Re: Problem with conditions when keys push up

19 Nov 2015, 05:56

Thanks, i will try it tonight.

Detail of Action 1 to understand the script :

Code: Select all

{
Sleep 400
Send (
Sleep 350
Send "
}

& = A spell to load
5 = A random skill who breaking spell &
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Problem with conditions when keys push up

19 Nov 2015, 06:00

So in that instance (Sending ( and ", both of which require shift to be held), you would not need {Blind}, UNLESS you were also holding Ctrl or another modifier when it tried to send.

Whatever, if Action1 does not behave as expected, try:

Code: Select all

Sleep 400
Send {Blind}(
Sleep 350
Send {Blind}"
69latrik
Posts: 3
Joined: 19 Nov 2015, 04:37

Re: Problem with conditions when keys push up

19 Nov 2015, 11:26

Solved, Thanks

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 69 guests