#NoTrayIcon
#include <GUIConstantsEx.au3>
Global $X = -1, $Y = -1
If FileExists(@ScriptDir & '\settings.ini') Then
$X = IniRead(@ScriptDir & '\settings.ini', 'POS', 'X', '')
$Y = IniRead(@ScriptDir & '\settings.ini', 'POS', 'Y', '')
EndIf
$Form1 = GUICreate("Form1", 400, 300, $X, $Y)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$WS = WinGetState($Form1)
If Not BitAND($WS, 16) Then
$WP = WinGetPos($Form1)
IniWrite(@ScriptDir & '\settings.ini', 'POS', 'X', $WP[0])
IniWrite(@ScriptDir & '\settings.ini', 'POS', 'Y', $WP[1])
EndIf
Exit
EndSwitch
WEnd