anixon Posted April 16, 2011 Share Posted April 16, 2011 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.. Link to comment Share on other sites More sharing options...
JScript Posted April 16, 2011 Share Posted April 16, 2011 You adapted this code from another language? http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Skitty Posted April 16, 2011 Share Posted April 16, 2011 (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.. 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.. , 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? expandcollapse popup#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 April 16, 2011 by System238 Link to comment Share on other sites More sharing options...
anixon Posted April 17, 2011 Author Share Posted April 17, 2011 You adapted this code from another language?I am pretty sure that it was adapted from a published AutoIT Script. Ant.. Link to comment Share on other sites More sharing options...
anixon Posted April 17, 2011 Author Share Posted April 17, 2011 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.. , 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? expandcollapse popup#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.. Link to comment Share on other sites More sharing options...
anixon Posted April 29, 2011 Author Share Posted April 29, 2011 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/sThanks again for the help Ant.. 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