Jump to content

Recommended Posts

Posted

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])

#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

Posted

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

 

Posted (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 by Hylia
Posted (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 by Hylia
Posted (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 by czardas
Posted (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

#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 by Hylia
Posted (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:

#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 by Rux
Posted (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 by czardas

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
  • Recently Browsing   0 members

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