How to make All 3 conditions in Autohotkey (how to code "AND")

I have a simple autohotkey code, but I cannot figure out how to make all 3 conditions met before doing the rules in the first bracket.

My code functions like, if any one condition is met, it will proceed. But I want to all 3 conditions met before proceeding.

The conditions should be:

  1. the title of the window must be September-Sales.
  2. the window must be Microsoft Word
  3. process winword.exe
Start:
IfWinExist, September-Sales ; (Title of the Microsoft Word Window)
if WinExist("ahk_class OpusApp") ; class
if WinExist("ahk_exe WINWORD.EXE") ; process
{ WinActivate SendInput, {Tab} SendInput, {Invoice Category} SendInput, {Enter}
}
else msgbox, Call the Encoder and give the O.R. Number.
Return
End
1

2 Answers

The Autohotkey documentation on IfWinExist / IfWinNotExist / WinExist provides an example of multiple conditions.

if WinExist("ahk_class Notepad") or WinExist("ahk_class" . ClassName)

For your purposes, you would want the following code

if WinExist("September-Sales") and WinExist("ahk_class OpusApp") and WinExist("ahk_exe WINWORD.EXE")
{ ...
}
6

You are ending your statements too early with the ';' operator.

if WinExist("ahk_exe WINWORD.EXE") && WinExist("ahk_class OpusApp")
{ WinActivate SendInput, {Tab} SendInput, {Invoice Category} SendInput, {Enter}
}
else
{ msgbox, Call the Encoder and give the O.R. Number.
}
Return

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like