beginner script world of warcraft -> condition not met? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Wetboy
Posts: 4
Joined: 21 Jul 2016, 12:33

beginner script world of warcraft -> condition not met?

21 Jul 2016, 12:45

This is my script:

Code: Select all

NotInChat := true

#IfWinActive, World of Warcraft
{
	
	~Enter::
	NotInChat := !NotInChat
	Return

	if (NotInChat){

		~1::
		Loop, 60
		{
			Send, {1}			
		}
		Return

		~2::
		Loop, 60
		{
			Send, {2}
		}
		Return

		~3::
		Loop, 60
		{
			Send, {3}
		}
		Return

		~4::
		Loop, 60
		{
			Send, {4}
		}
		Return


		~5::
		Loop, 60
		{
			Send, {5}
		}
		Return

	}
	else{
		Return
	}
}
Basically i want the hotkeys 1 through 5 only to work, if

1. World of Warcraft Window is active (This condition is evaluated correctly)
2. I am not in chat (e.g. I never pressed Enter to begin with or I hit it twice)

Now, it appears that the expression

Code: Select all

if(NotInChat)
is always true, no matter how often i hit the Enter-key.

It feels like something trivial, yet I cannot find the bug..
Can someone help me, please?

Thanks in advance =)

P.S. Also is there a more optimised approach to do what I do with the hotkeys? (repeatedly sending keys a few times)
Like for instance:

Insert a delay between the "Send" (if so: how long?)
or use different commands?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: beginner script world of warcraft -> condition not met?

21 Jul 2016, 13:03

Does your keys work if you remove the if block? Does it work if you write if true?

If you want a delay, search for sleep in the help file.

It's not clear what you want with your keys so it's not clear what should be optimised.
Wetboy
Posts: 4
Joined: 21 Jul 2016, 12:33

Re: beginner script world of warcraft -> condition not met?

21 Jul 2016, 13:35

Helgef wrote:Does your keys work if you remove the if block? Does it work if you write if true?

If you want a delay, search for sleep in the help file.

It's not clear what you want with your keys so it's not clear what should be optimised.
It works without the if block. It works all the time. That's the problem.

In online games it's optimal to repeatedly hit the key you usually just hit once. Because of input-lag etc..
But rather than hitting the keys myself like a lunatic, especially since after a while my fingers start to hurt, I want AHK to do the job.
I set it to hit the key 60 times as fast as possible. BUT if I want to chat ingame (chat is called via the ENTER key) and I use one of my script keys, obviously
the number will be written 60 times in the chat input box. So I want the hotkeys only to work outside of chat.

As for the delay question, I am familiar with sleep, but I wanted to know from a WoW-Player (in case someone here plays it as well) how high to set the delay (with GCD in mind).
Guest

Re: beginner script world of warcraft -> condition not met?

21 Jul 2016, 13:49

Try...

Code: Select all

NotInChat := true
 
#IfWinActive, World of Warcraft
~Enter::
NotInChat := !NotInChat
Return
#if
#if NotInChat
~1::
Loop, 60
{
	Send, {1}			
}
Return
 
~2::
Loop, 60
{
	Send, {2}
}
Return
 
~3::
Loop, 60
{
	Send, {3}
}
Return
 
~4::
Loop, 60
{
	Send, {4}
}
Return
 
 
~5::
Loop, 60
{
	Send, {5}
}
Return
#if
Wetboy
Posts: 4
Joined: 21 Jul 2016, 12:33

Re: beginner script world of warcraft -> condition not met?

21 Jul 2016, 14:27

Guest wrote:Try...

Code: Select all

NotInChat := true
 
#IfWinActive, World of Warcraft
~Enter::
NotInChat := !NotInChat
Return
#if
#if NotInChat
~1::
Loop, 60
{
	Send, {1}			
}
Return
 
~2::
Loop, 60
{
	Send, {2}
}
Return
 
~3::
Loop, 60
{
	Send, {3}
}
Return
 
~4::
Loop, 60
{
	Send, {4}
}
Return
 
 
~5::
Loop, 60
{
	Send, {5}
}
Return
#if
Okay the chat thing now works, thanks =)
However the hotkeys now of course trigger outside of World of Warcraft, which they shouldn't :/
Any solution for that? The #if seem to work as tags, which can't be nested?
Guest

Re: beginner script world of warcraft -> condition not met?  Topic is solved

21 Jul 2016, 14:30

Try...

Code: Select all

NotInChat := true
 
#IfWinActive, World of Warcraft
~Enter::
NotInChat := !NotInChat
Return
#if
#if NotInChat && WinActive("World of Warcraft")
~1::
Loop, 60
{
	Send, {1}			
}
Return
 
~2::
Loop, 60
{
	Send, {2}
}
Return
 
~3::
Loop, 60
{
	Send, {3}
}
Return
 
~4::
Loop, 60
{
	Send, {4}
}
Return
 
 
~5::
Loop, 60
{
	Send, {5}
}
Return
#if
 
Wetboy
Posts: 4
Joined: 21 Jul 2016, 12:33

Re: beginner script world of warcraft -> condition not met?

21 Jul 2016, 14:34

Guest wrote:Try...

Code: Select all

NotInChat := true
 
#IfWinActive, World of Warcraft
~Enter::
NotInChat := !NotInChat
Return
#if
#if NotInChat && WinActive("World of Warcraft")
~1::
Loop, 60
{
	Send, {1}			
}
Return
 
~2::
Loop, 60
{
	Send, {2}
}
Return
 
~3::
Loop, 60
{
	Send, {3}
}
Return
 
~4::
Loop, 60
{
	Send, {4}
}
Return
 
 
~5::
Loop, 60
{
	Send, {5}
}
Return
#if
 
Perfect had the same thing in mind, yet I didn't know you can use WinActive individually from IfWinActive. And the && and 'and' in the documentation added to my confusion. Anyway problem solved now, thank you very much! =)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Marium0505 and 345 guests