我可以使用 'ifwinexist' 作为函数中的参数吗?

Can I use 'ifwinexist' as an argument in a function?

请看下面的代码

;----------------------------------------------------------------
;  INFORMATION
;----------------------------------------------------------------
; Full resolution is 2560 * 1600
; 
; Taskbar is 40 pixels high
;----------------------------------------------------------------
#NoEnv
SetTitleMatchMode, 2

^j::ResizeWin()

ResizeWin()
{
  ifwinexist ahk_exe Chrome.exe                     ;Google Chrome
  DoTheThing(0,0,1280,800)

  ifwinexist ahk_class CommunicatorMainWindowClass  ;Skype
  DoTheThing(0,800,400,760)

  ifwinexist ahk_class rctrl_renwnd32               ;Outlook
  DoTheThing(1280,0,1280,1560)

  ifwinexist ahk_exe WhatsApp.exe                   ;WhattsApp
  DoTheThing(400,800,880,760)
}

DoTheThing(posX = 0, posY = 0, Width = 0, Height = 0)
{
  WinActivate
  WinMove,%WindowID%,,posX,posY,%Width%,%Height%
}

我写了上面的代码来重新排列我打开的 windows 在我的桌面上,每当我将它们拖到不同的地方时。目前这工作正常,但我认为有可能通过在函数调用中处理 windows 的选择来清理代码。

在我看来,我应该最终得到

的多个实例
DoTheThing(posX,posY,Width,Height,Name/class/exe_of_the_window)

并在函数主体中处理激活和移动。 我该怎么做?

这是我认为最简单的解决方案:

^j::ResizeWin()

ResizeWin(){
  WinMove, ahk_exe Chrome.exe,, 0,0,1280,800
  WinMove, ahk_class CommunicatorMainWindowClass,, 0,800,400,760
  ; ...
}