I click on the gui, move it outside screen, when i release it, it moves as it should within the screen but only for a brief moment, then it goes back to its original location.
This is the code:
Code: Select all
~LButton Up::
NewPosition() ; the only place it gets used.
Return
NewPosition()
global newPosX ; Making it global so i can use it to save to .ini in OnExit sub.
global newPosY ; Making it global so i can use it to save to .ini in OnExit sub.
global Width ; Get the window width.
global Height ; Get the window height
WinGetPos, newPosX, newPosY, , , ahk_id %hwnd1% ; Get the gui 1 hwnd.
KeepOnScreen := 1 ; Option that toggles but is set here for debugging to true.
if (KeepOnScreen=1)
{
if (newPosX<0)
newPosX:=0
else if (newPosX>(A_ScreenWidth-Width))
newPosX:=A_ScreenWidth-Width
if (newPosY<0)
newPosY:=0
else if (newPosY>(A_ScreenHeight-Height))
newPosY:=A_ScreenHeight-Height
WinMove, ahk_id %hwnd1%, , %newPosX%, %newPosY% ; Move it within screen.
}
return 1 ; call confirmed
Also, Gui 2 is child of Gui 1 but buttons (gui 3-6) are child of gui 2.
I am not moving the gui from anywhere inside the script, only here happens such an event. Any ideas why it does that?
I also use the above function to save the location with IniWrite when i close the script and use IniRead on startup to set it back where it was last time.
Id post the full script but its 1500+ lines and its hard to pull out what i guess relevant code that might make an issue?
But i dont think it should tho unless its some inherent issue or way how gdi works? Thats the only thing out of the ordinary in my script.