Sign in to follow this  
Followers 0

Save Window x y Location

6 posts in this topic

#1 ·  Posted

Using the code the value written to the INI file for both x and y is minus eight '-8' which is not the true location of the AutoIT created window. This is required so when the user opens the Window on the next occasion it is opened in its last known position

I have not posted the code which reads the INI file for no other reason as it is probably not necessary to resolve why the wrong value is being written to the INI file in the first place. Both $sUpLeft and $sUpTop are set as Global Variables.

;//Compile Current Window Position
Func _RFCalcWinPos()
 ;//Set the Focus on the RFCalculator Window
 WinActivate($Title, "")
 ;//Capture the RFCalculator Window x y position
 Local $Handle = WinGetHandle($Title, "")
 $RFScreenPos = WinGetPos($Handle, "")
 If UBound($RFScreenPos) = 4 Then
  $sUpLeft = $RFScreenPos[0]
  $sUpTop = $RFScreenPos[1]
  ;//Width and Height are Constants
  ;$sUPWidth = $RFScreenPos[2]
  ;$sUpHeight = $RFScreenPos[3]
 EndIf
 msgbox(0,"",$sUpLeft) ;//### Debug
 IniWrite($MyFile, "sUpLeft", "value", $sUpLeft) 
IniWrite($MyFile, "sUpTop", "value", $sUpTop)
EndFunc   ;==>_RFCalcWinPos

Help is always appreciated Ant.. :unsure:

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Using the code the value written to the INI file for both x and y is minus eight '-8' which is not the true location of the AutoIT created window. This is required so when the user opens the Window on the next occasion it is opened in its last known position

I have not posted the code which reads the INI file for no other reason as it is probably not necessary to resolve why the wrong value is being written to the INI file in the first place. Both $sUpLeft and $sUpTop are set as Global Variables.

;//Compile Current Window Position
Func _RFCalcWinPos()
 ;//Set the Focus on the RFCalculator Window
 WinActivate($Title, "")
 ;//Capture the RFCalculator Window x y position
 Local $Handle = WinGetHandle($Title, "")
 $RFScreenPos = WinGetPos($Handle, "")
 If UBound($RFScreenPos) = 4 Then
  $sUpLeft = $RFScreenPos[0]
  $sUpTop = $RFScreenPos[1]
  ;//Width and Height are Constants
  ;$sUPWidth = $RFScreenPos[2]
  ;$sUpHeight = $RFScreenPos[3]
 EndIf
 msgbox(0,"",$sUpLeft) ;//### Debug
 IniWrite($MyFile, "sUpLeft", "value", $sUpLeft) 
IniWrite($MyFile, "sUpTop", "value", $sUpTop)
EndFunc   ;==>_RFCalcWinPos

Help is always appreciated Ant.. :unsure:

I'm having a problem understanding... your problem... I'm smoking weed right now and the way some of you decide to compose yall's post's is kinda hard to apprehend...

(Or its probably just me.. Posted Image, Not trying to be an ass though..)

But by what I understood, you're trying to save the windows position and open it in the position it was last used right?

Is this what you're trying to do or what?

#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>

$MyFile = @DesktopDir&"\~$ettings.ini"

If FileExists($MyFile) Then
    $GUI=GUICreate('TEST',173, 126,IniRead($MyFile,"sUpLeft","value",0),IniRead($MyFile,"sUpTop","value",0))
Else
    $GUI=GUICreate('TEST')
EndIf

$Button1 = GUICtrlCreateButton("Set Pos", 56, 80, 65, 25, $WS_GROUP)

#region - GUI Create
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            _RFCalcWinPos()
    EndSelect
WEnd
#endregion

;//Compile Current Window Position
Func _RFCalcWinPos()
 ;//Set the Focus on the RFCalculator Window
 WinActivate($GUI, "")
 ;//Capture the RFCalculator Window x y position
 Local $Handle = WinGetHandle($GUI, "")
 $RFScreenPos = WinGetPos($Handle, "")
 If UBound($RFScreenPos) = 4 Then
  ;//Width and Height are Constants
  ;$sUPWidth = $RFScreenPos[2]
  ;$sUpHeight = $RFScreenPos[3]
 EndIf
; msgbox(0,"",$RFScreenPos[0]) ;//### Debug
 IniWrite($MyFile, "sUpLeft", "value", $RFScreenPos[0])
IniWrite($MyFile, "sUpTop", "value", $RFScreenPos[1])
EndFunc   ;==>_RFCalcWinPos
Edited by System238

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#4 ·  Posted

You adapted this code from another language?

I am pretty sure that it was adapted from a published AutoIT Script. Ant..

Share this post


Link to post
Share on other sites

#5 ·  Posted

I'm having a problem understanding... your problem... I'm smoking weed right now and the way some of you decide to compose yall's post's is kinda hard to apprehend...

(Or its probably just me.. Posted Image, Not trying to be an ass though..)

But by what I understood, you're trying to save the windows position and open it in the position it was last used right?

Is this what you're trying to do or what?

#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>

$MyFile = @DesktopDir&"\~$ettings.ini"

If FileExists($MyFile) Then
    $GUI=GUICreate('TEST',173, 126,IniRead($MyFile,"sUpLeft","value",0),IniRead($MyFile,"sUpTop","value",0))
Else
    $GUI=GUICreate('TEST')
EndIf

$Button1 = GUICtrlCreateButton("Set Pos", 56, 80, 65, 25, $WS_GROUP)

#region - GUI Create
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            _RFCalcWinPos()
    EndSelect
WEnd
#endregion

;//Compile Current Window Position
Func _RFCalcWinPos()
 ;//Set the Focus on the RFCalculator Window
 WinActivate($GUI, "")
 ;//Capture the RFCalculator Window x y position
 Local $Handle = WinGetHandle($GUI, "")
 $RFScreenPos = WinGetPos($Handle, "")
 If UBound($RFScreenPos) = 4 Then
  ;//Width and Height are Constants
  ;$sUPWidth = $RFScreenPos[2]
  ;$sUpHeight = $RFScreenPos[3]
 EndIf
; msgbox(0,"",$RFScreenPos[0]) ;//### Debug
 IniWrite($MyFile, "sUpLeft", "value", $RFScreenPos[0])
IniWrite($MyFile, "sUpTop", "value", $RFScreenPos[1])
EndFunc   ;==>_RFCalcWinPos

I have to go and pull some weeds I pretty sure it is called Dock so unfortunately today I have pretty much run out of time but within the next 24 hours I will test your version of capturing screen position and post a response. Ant..

Share this post


Link to post
Share on other sites

#6 ·  Posted

I have to go and pull some weeds I pretty sure it is called Dock so unfortunately today I have pretty much run out of time but within the next 24 hours I will test your version of capturing screen position and post a response. Ant..

I apologise for not responding earlier but with Easter and other family commitments I have been dragged in other directions. Well the short and quick answer is the code works perfectly and I thank the respondant/s

Thanks again for the help Ant.. :unsure:

Share this post


Link to post
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
Sign in to follow this  
Followers 0