Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

AutoHotkey: WinMaximize

Hello experts,
I am trying to understand the logic behind WinMaximize however the documentation available at:
https://www.autohotkey.com/docs/commands/WinMaximize.htm
is not enough for me.
The need is to set a WinActive condition, maximize and send a click:
Like this:
If (WinActive("ahk_exe ssms.exe"))
{
 WinMaximize
 MouseClick, left, 55, 233
 Return
}
Else
{
  MsgBox,4144,Error,Active window is not a supported program
  Return
}

Open in new window

Thank you for your help.
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luis Diaz

ASKER

Joe,
I tested the following and it works for me.
+^F12::
If (WinActive("ahk_exe ssms.exe"))
	{
	WinActivate
	WinMaximize 
	}
Else
	MsgBox,4112,Error,SSMS is not your active windows
Return

Open in new window

Thank you very much for your advice.
OK, but the WinActivate should not be needed. The only way that you'll get into that logic path is if the WinActive returns True, in which case you certainly don't have to activate it...it's already active!
Noted, I will retest without winactivate to see what happens.
I'm sure it will work without it...if not, something wacky is going on!
Indeed it works!
Final result:
+^F12::
If (WinActive("ahk_exe ssms.exe"))
{
	WinMaximize 
	MouseClick, Right, 800, 125
}
Else
	MsgBox,4112,Error,SSMS is not your active windows
Return

Open in new window

Thank you for your help.
Great news! Regards, Joe