Jump to content

Gui Start at last location saved


maqleod
 Share

Recommended Posts

here's a piece of a script you can add into anything with a gui to have it open at the same location it was closed. Nothing special, just thought some might find it handy.

#include <GUIConstants.au3>

$xpos = RegRead("HKEY_CURRENT_USER\SOFTWARE\AutoItTest", "Xpos")
if $xpos = 1 OR $xpos = -32000 then
RegWrite("HKEY_CURRENT_USER\SOFTWARE\AutoItTest","Xpos","REG_SZ",-1)
$xpos = RegRead("HKEY_CURRENT_USER\SOFTWARE\AutoItTest", "Xpos")
endif
$ypos = RegRead("HKEY_CURRENT_USER\SOFTWARE\AutoItTest", "Ypos")
if $ypos = 1 OR $ypos = -32000 then
RegWrite("HKEY_CURRENT_USER\SOFTWARE\AutoItTest","Ypos","REG_SZ",-1)
$ypos = RegRead("HKEY_CURRENT_USER\SOFTWARE\AutoItTest", "Ypos")
endif

$parent = GUICreate("test",195,175,$xpos,$ypos,-1,-1)

GUISetState()
Do
$msg = GUIGetMsg()

Until $msg = $GUI_EVENT_CLOSE
$newpos = WinGetPos("test","")
RegWrite("HKEY_CURRENT_USER\SOFTWARE\AutoItTest","Xpos","REG_SZ",$newpos[0])
RegWrite("HKEY_CURRENT_USER\SOFTWARE\AutoItTest","Ypos","REG_SZ",$newpos[1])
GUIDelete()
Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

I like using the registry so much

nice example

see ya

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...