MarioX Posted December 5, 2005 Share Posted December 5, 2005 I had made lot's of search but nothing found... I'm a AutoIt beginner, until now all the GUI I had made was centered on screen using @DesktopHeight and @DesktopWidth. Now I want made a GUI that remember the last desktop position at next restart. Is this a Windows feature or some coding is required ? Thanks for any help! Mario Link to comment Share on other sites More sharing options...
Josbe Posted December 5, 2005 Share Posted December 5, 2005 I had made lot's of search but nothing found...I'm a AutoIt beginner, until now all the GUI I had made was centered on screen using @DesktopHeight and @DesktopWidth.Now I want made a GUI that remember the last desktop position at next restart.Is this a Windows feature or some coding is required ?Thanks for any help!MarioRequires code. Just use an INI file, get the position and store it into the INI before to close the GUI. Of course, the script need to read this values for X and Y when is displayed the next time. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 5, 2005 Share Posted December 5, 2005 you need some coding and maybe an ini-file Opt("OnExitFunc","OnAutoItExit") guicreate("gui", 300, 300, iniread("some.ini", "Section", "X-Pos", 0), iniread("some.ini", "Section", "Y-Pos", 0)); this will put your window to the last stored coordinates (default: 0/0) func OnAutoItExit() $a = wingetpos("your win") iniwrite("some.ini", "Section", "X-Pos", $a[0]) iniwrite("some.ini", "Section", "Y-Pos", $a[1]) hope this helps my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 5, 2005 Share Posted December 5, 2005 hm, seems Josbe was faster CONGRATULATIONS my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
MarioX Posted December 5, 2005 Author Share Posted December 5, 2005 Ooh... I'm amazed, really a super-fast assistance! Thanks all for the advice and supplied code, really appreciated. Mario Link to comment Share on other sites More sharing options...
MarioX Posted December 6, 2005 Author Share Posted December 6, 2005 (edited) Following the Nuffilein805 suggested code, I've made the following, but something goes wrong when it's time to store the window position in the .ini file I always get the following value: [Position] X-Pos=-4 Y-Pos=-4 It seem that WinGetPos don't read the Gui value I've forced WinGetPos to read the Gui using the following: $a = WinGetPos("gui") But I get a "Subscript used with non-Array variable" error. #include <GUIConstants.au3> Opt("OnExitFunc","OnAutoItExit") ; this will put your window to the last stored coordinates (default: 0/0) guicreate("gui", 300, 300, iniread("GuiPosition.ini", "Position", "X-Pos", 0), iniread("GuiPosition.ini", "Position", "Y-Pos", 0)) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend func OnAutoItExit() $a = WinGetPos("") IniWrite("GuiPosition.ini", "Position", "X-Pos", $a[0]) IniWrite("GuiPosition.ini", "Position", "Y-Pos", $a[1]) EndFunc What's wrong ? Edited December 6, 2005 by MarioX Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 6, 2005 Share Posted December 6, 2005 you're right it doesn't get the gui, because it is already closed 1 found a way to walk around #include<guiconstants.au3> Opt("OnExitFunc","OnAutoItExit") guicreate("gui", 300, 300, iniread("some.ini", "Section", "X-Pos", 0), iniread("some.ini", "Section", "Y-Pos", 0)); this will put your window to the last stored coordinates (default: 0/0) GUISetState() While 1 $msg = GUIGetMsg() dim $a $a = wingetpos("gui") If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend func OnAutoItExit() iniwrite("some.ini", "Section", "X-Pos", $a[0]) iniwrite("some.ini", "Section", "Y-Pos", $a[1]) EndFunc this should work at least it does at my pc my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
MarioX Posted December 6, 2005 Author Share Posted December 6, 2005 It work, thanks for prompt assistance! Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 6, 2005 Share Posted December 6, 2005 no problem glad i could help my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now