Hylia Posted February 16, 2013 Posted February 16, 2013 I'm wondering why it won't write the ini file I think I'm doing everything correctly? (Complete script in spoiler) Case $msg = $Save IniWrite("Vars.ini", "Variables", "X", $X[5]) expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1_1", 170, 135, 222, 464) $Save = GUICtrlCreateMenu("Save") $hX = GUICtrlCreateInput("pos[0]", 16, 16, 49, 21) $hY = GUICtrlCreateInput("pos[1]", 104, 16, 49, 21) $MouseCoordX = GUICtrlCreateInput("-1", 16, 96, 49, 21) $MouseCoordY = GUICtrlCreateInput("-1", 104, 96, 49, 21) $N = GUICtrlCreateInput("1", 64, 56, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;pre-declare x & y local $X[5] local $Y[5] ;pre-declare end HotKeySet("{SPACE}", "Var") While 1 $nSet = GUICtrlRead($N) $pos = MouseGetPos() GUICtrlSetData($hX, $pos[0]) GUICtrlSetData($hY, $pos[1]) If $nSet > 0 then GUICtrlSetData($MouseCoordX, $x[$nSet]) GUICtrlSetData($MouseCoordY, $y[$nSet]) EndIf $Msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() fileDelete(@tempDir & "\image9.jpg") ExitLoop Exit Case $msg = $Save IniWrite("Vars.ini", "Variables", "X", $X[5]) EndSelect WEnd Func Var() If $nSet > 0 then $x[$nSet] = $pos[0] $y[$nSet] = $pos[1] GUICtrlSetData($N, $nSet + 1) EndIf EndFunc
water Posted February 16, 2013 Posted February 16, 2013 The file could be read-only. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
HeavenlyDemon Posted February 16, 2013 Posted February 16, 2013 try to set the full path to the ini file IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value")
Hylia Posted February 16, 2013 Author Posted February 16, 2013 (edited) Tried both, File is not read-only, folder also isn't read-only, tried both running as admin and without, also tried with path specified nothing. (and yes, it's with a compiled file) Edited February 16, 2013 by Hylia
czardas Posted February 16, 2013 Posted February 16, 2013 (edited) Are you saying it works when not compiled? You are trying to write a value that can't exist => $x[5] Edited February 16, 2013 by czardas operator64 ArrayWorkshop
Hylia Posted February 16, 2013 Author Posted February 16, 2013 (edited) Are you saying it works when not compiled? You are trying to write a value that can't exist => $x[5] No, it doesn't. I want it to write all 5 of the $X[5] to write. Edited February 16, 2013 by Hylia
czardas Posted February 16, 2013 Posted February 16, 2013 (edited) $x only contains 5 elements as shown: $x[0] $x[1] $x[2] $x[3] $x[4] I want it to write all 5 of the $X[5] to write. Write a separate entry for each element that exists. Edited February 16, 2013 by czardas operator64 ArrayWorkshop
Hylia Posted February 16, 2013 Author Posted February 16, 2013 $x only contains 5 elements: $x[0] $x[1] $x[2] $x[3] $x[4] Oh didn't know that [0] was also considered one.
HeavenlyDemon Posted February 16, 2013 Posted February 16, 2013 (edited) ok...got some 9999999999999999 unknoun code there i second please For $i = 1 To 5 IniWrite("Vars.ini", "Variables", "X", $X[$i]) next Edited February 16, 2013 by HeavenlyDemon
czardas Posted February 16, 2013 Posted February 16, 2013 Oh didn't know that [0] was also considered one. operator64 ArrayWorkshop
Hylia Posted February 16, 2013 Author Posted February 16, 2013 (edited) Changed it to $X[1] still no file is created. :S Can someone give me something to compile to see if it's my computer? V current thing I'm compiling expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1_1", 170, 135, 222, 464) $Save = GUICtrlCreateMenu("Save") $hX = GUICtrlCreateInput("pos[0]", 16, 16, 49, 21) $hY = GUICtrlCreateInput("pos[1]", 104, 16, 49, 21) $MouseCoordX = GUICtrlCreateInput("-1", 16, 96, 49, 21) $MouseCoordY = GUICtrlCreateInput("-1", 104, 96, 49, 21) $N = GUICtrlCreateInput("1", 64, 56, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;pre-declare x & y local $X[5] local $Y[5] ;pre-declare end HotKeySet("{SPACE}", "Var") While 1 $nSet = GUICtrlRead($N) $pos = MouseGetPos() GUICtrlSetData($hX, $pos[0]) GUICtrlSetData($hY, $pos[1]) If $nSet > 0 then GUICtrlSetData($MouseCoordX, $x[$nSet]) GUICtrlSetData($MouseCoordY, $y[$nSet]) EndIf $Msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() fileDelete(@tempDir & "\image9.jpg") ExitLoop Exit Case $msg = $Save IniWrite("C:\Temp\Vars.ini", "Variables", "X", $X[1]) EndSelect WEnd Func Var() If $nSet > 0 then $x[$nSet] = $pos[0] $y[$nSet] = $pos[1] GUICtrlSetData($N, $nSet + 1) EndIf EndFunc Edited February 16, 2013 by Hylia
Rux Posted February 16, 2013 Posted February 16, 2013 (edited) So I put a message box after the IniWrite() and it never popped up when I clicked save. So that means the code is never even reaching that line. I replaced the "Save" bar button with a regular button and it reaches the line, but $X[5] exceeds the variable's array range, which means $X's array is smaller than 5. I changed the number to 2 and it worked. EDIT: Here is your edited code: expandcollapse popup#include #include #include #include #include #include #include #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1_1", 170, 135, 222, 464) ;$Save = GUICtrlCreateMenu("Save") $Save = GUICtrlCreateButton("TEST", 10, 10, 30, 30) $hX = GUICtrlCreateInput("pos[0]", 16, 16, 49, 21) $hY = GUICtrlCreateInput("pos[1]", 104, 16, 49, 21) $MouseCoordX = GUICtrlCreateInput("-1", 16, 96, 49, 21) $MouseCoordY = GUICtrlCreateInput("-1", 104, 96, 49, 21) $N = GUICtrlCreateInput("1", 64, 56, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;pre-declare x & y local $X[5] local $Y[5] ;pre-declare end HotKeySet("{SPACE}", "Var") While 1 $nSet = GUICtrlRead($N) $pos = MouseGetPos() GUICtrlSetData($hX, $pos[0]) GUICtrlSetData($hY, $pos[1]) If $nSet > 0 then GUICtrlSetData($MouseCoordX, $x[$nSet]) GUICtrlSetData($MouseCoordY, $y[$nSet]) EndIf $Msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() fileDelete(@tempDir & "\image9.jpg") ExitLoop Exit Case $msg = $Save IniWrite("Vars.ini", "Variables", "X", $X[2]) MsgBox(64, "TEST", "MADE IT HERE") EndSelect WEnd Func Var() If $nSet > 0 then $x[$nSet] = $pos[0] $y[$nSet] = $pos[1] GUICtrlSetData($N, $nSet + 1) EndIf EndFunc Edited February 16, 2013 by Rux
czardas Posted February 16, 2013 Posted February 16, 2013 (edited) The problem is here => GUICtrlCreateMenu. This menu has no items to click on. If you replace that with a button (or add a menu item that can receive clicks using GUICtrlCreateMenuItem), it will create the ini. There is currently no message being received. Edited February 16, 2013 by czardas operator64 ArrayWorkshop
Hylia Posted February 16, 2013 Author Posted February 16, 2013 (edited) Rux, awesome, thanks a lot! and czardas I'll try that. Edited February 16, 2013 by Hylia
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