Jump to content

Recommended Posts

Posted

I made this script:

#include <GUIConstantsEx.au3>
Global $mapx = 0
Global $mapy = 0
Global $sitex = 0
Global $sitey = 0
Global $attackx = 0
Global $attacky = 0
Global $workermaxx = 0
Global $workermaxy = 0
Global $warriormaxx = 0
Global $warriormaxy = 0
Global $scoutmaxx = 0
Global $scoutmaxy = 0
Global $herox = 0
Global $heroy = 0
Global $1okx = 0
Global $1oky = 0
Global $2okx = 0
Global $2oky = 0
Global $xx = 0
Global $xy = 0
Global $btn
Global $msg

Example()

Func Example()
    
    GUICreate("Evony Bot v2.0 coded by Kandúúúr^^", 440, 610, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 350, -1, 0x00000018); ablak méret, elhelyezkedés
    GUICtrlCreateLabel("Map gomb X koordinátája(pixel):", 10, 5, 160); 10. oszlop, 5. sor, 160 széles
    $mapx = GUICtrlCreateInput("0", 180, 5, 30, 20); 180. oszlop, 5. sor, 30 széles, 20 magas
;GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlCreateLabel("Map gomb Y koordinátája(pixel):", 230, 5, 160)
    $mapy = GUICtrlCreateInput("0", 400, 5, 30, 20)     
    
    GUICtrlCreateLabel("Támadható X koordináta(pixel):", 10, 35, 160)
    $sitex = GUICtrlCreateInput("0", 180, 35, 30, 20)
    GUICtrlCreateLabel("Támadható Y koordináta(pixel):", 230, 35, 160)
    $sitey = GUICtrlCreateInput("0", 400, 35, 30, 20)
    
    GUICtrlCreateLabel("Attack gomb X koordinátája(pixel):", 10, 65, 170) 
    $attackx = GUICtrlCreateInput("0", 180, 65, 30, 20) 
    GUICtrlCreateLabel("Attack gomb Y koordinátája(pixel):", 230, 65, 170)
    $attacky = GUICtrlCreateInput("0", 400, 65, 30, 20)
    
    GUICtrlCreateLabel("", 0, 120, 440, 2, 5);vonal
    
    GUICtrlCreateLabel("Worker:", 10, 145, 70)
    GUICtrlCreateLabel("Max gomb X koordinátája(pixel):", 190, 130, 150)
    $workermaxx = GUICtrlCreateInput("0", 350, 130, 30, 20)
    GUICtrlCreateLabel("Max gomb Y koordinátája(pixel):", 190, 160, 150)
    $workermaxy = GUICtrlCreateInput("0", 350, 160, 30, 20)
    
    GUICtrlCreateLabel("", 0, 185, 440, 2, 5);vonal
    
    GUICtrlCreateLabel("Warrior:", 10, 210, 70)
    GUICtrlCreateLabel("Max gomb X koordinátája(pixel):", 190, 195, 150)
    $warriormaxx = GUICtrlCreateInput("0", 350, 195, 30, 20)
    GUICtrlCreateLabel("Max gomb Y koordinátája(pixel):", 190, 225, 150)
    $warriormaxy = GUICtrlCreateInput("0", 350, 225, 30, 20)
    
    GUICtrlCreateLabel("", 0, 250, 440, 2, 5);vonal

    GUICtrlCreateLabel("Scout:", 10, 285, 70)
    GUICtrlCreateLabel("Max gomb X koordinátája(pixel):", 190, 265, 150)
    $scoutmaxx = GUICtrlCreateInput("0", 350, 265, 30, 20)
    GUICtrlCreateLabel("Max gomb Y koordinátája(pixel):", 190, 295, 150)
    $scoutmaxy = GUICtrlCreateInput("0", 350, 295, 30, 20)  

    GUICtrlCreateLabel("", 0, 320, 440, 2, 5);vonal
    
    GUICtrlCreateLabel("Hős gomb:", 10, 350, 70)
    GUICtrlCreateLabel("Hős gomb X koordinátája(pixel):", 190, 330, 150)
    $herox = GUICtrlCreateInput("0", 350, 330, 30, 20)
    GUICtrlCreateLabel("Hős gomb Y koordinátája(pixel):", 190, 360, 150)
    $heroy = GUICtrlCreateInput("0", 350, 360, 30, 20)  
    
    GUICtrlCreateLabel("", 0, 385, 440, 2, 5);vonal
    
    GUICtrlCreateLabel("1. Ok gomb:", 10, 415, 70)
    GUICtrlCreateLabel("1. Ok gomb X koordinátája(pixel):", 170, 395, 170)
    $1okx = GUICtrlCreateInput("0", 350, 395, 30, 20)
    GUICtrlCreateLabel("1. Ok gomb Y koordinátája(pixel):", 170, 425, 170)
    $1oky = GUICtrlCreateInput("0", 350, 425, 30, 20)   
    
    GUICtrlCreateLabel("0", 0, 450, 440, 2, 5);vonal
    
    GUICtrlCreateLabel("2. Ok gomb:", 10, 480, 70)
    GUICtrlCreateLabel("2. Ok gomb X koordinátája(pixel):", 170, 460, 170)
    $2okx = GUICtrlCreateInput("0", 350, 460, 30, 20)
    GUICtrlCreateLabel("2. Ok gomb Y koordinátája(pixel):", 170, 490, 170)
    $2oky = GUICtrlCreateInput("0", 350, 490, 30, 20)   
    
    GUICtrlCreateLabel("", 0, 515, 440, 2, 5);vonal
    
    GUICtrlCreateLabel(" X gomb:", 10, 545, 70)
    GUICtrlCreateLabel(" X gomb X koordinátája(pixel):", 170, 525, 170)
    $xx = GUICtrlCreateInput("0", 350, 525, 30, 20)
    GUICtrlCreateLabel(" X gomb Y koordinátája(pixel):", 170, 555, 170)
    $xy = GUICtrlCreateInput("0", 350, 555, 30, 20) 
    
    $btn = GUICtrlCreateButton("Ok", 190, 580, 60, 20)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                ExitLoop
        EndSelect
    WEnd
    
FileDelete("coords.txt")

$file = FileOpen("coords.txt", 1)
FileWriteLine($file, $mapx  )
FileWriteLine($file, $mapy )
FileWriteLine($file, $sitex )
FileWriteLine($file, $sitey )
FileWriteLine($file, $attackx )
FileWriteLine($file, $attacky )
FileWriteLine($file, $workermaxx )
FileWriteLine($file, $workermaxy )
FileWriteLine($file, $warriormaxx )
FileWriteLine($file, $warriormaxy )
FileWriteLine($file, $scoutmaxx )
FileWriteLine($file, $scoutmaxy )
FileWriteLine($file, $herox )
FileWriteLine($file, $heroy )
FileWriteLine($file, $1okx )
FileWriteLine($file, $1oky )
FileWriteLine($file, $2okx )
FileWriteLine($file, $2oky )
FileWriteLine($file, $xx )
FileWriteLine($file, $xy )

FileClose($file)

    MsgBox(4096, "Pixel koordináták mentve", "Pixel kooridnáták mentve")
EndFunc  ;==>Example

This is make a GUI with texts and input box, i get the variables from the input box, then write it to a file named "coords.txt" but everytime its write this to the file:

4
6
8
10
12
14
18
20
24
26
30
32
36
38
42
44
48
50
54
56

but why??? if you can, please help me

  • Moderators
Posted

wazze,

You are writing the ControlID of the various controls, not their content. Use GUICtrlRead:

FileWriteLine($file, GUICtrlRead($mapx))
FileWriteLine($file, GUICtrlRead($mapy));etc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

wazze,

You are writing the ControlID of the various controls, not their content. Use GUICtrlRead:

FileWriteLine($file, GUICtrlRead($mapx))
FileWriteLine($file, GUICtrlRead($mapy));etc

M23

oh, thanks, so much ^^ i'm very new in this lang ^^
  • 4 weeks later...
  • 1 month later...
  • Moderators
Posted

sokol (and theshint, sorry I missed you last time!),

When AutoIt creates a control it gives it a ControlID (CID) - it has space for 65532 controls/CIDs. The CIDs are allocated on a successive numeric basis, with a new control getting the first available CID. An example:

GUICreate(....)

GUICtrlCreateInput(....) ; this control would get a CID of 3 (usually the first available CID)

GUICtrlCreateButton(....) ; this control would get a CID of 4

GUICtrlCreateButton(....) ; this control would get a CID of 5

and so on... Note that if you were to delete the first button and immediately create another control it would (at least it has every time I have tried!) take on the same CID - which is why I said that a control will take the first available CID rather than the next in order. The CID is used a lot in AutoIt to identify the control. Almost every GUI function uses it somewhere.

The original code saved the CID of the various controls when created like this:

$mapx = GUICtrlCreateInput(....)

The variable $mapx now holds the CID of the Input control. But when the OP tried to write to the file, he used this:

FileWriteLine($file, $mapx)

I hope you can see now that he writing the CID to the file - which showed in the resulting list of numbers. Incidentally, the numbers are all 2 apart because the OP created a label between each control - which is also allocated a CID of course!

What the OP needed to do was read the contents of the control - and you do that with GUICtrlRead(ControlID). See how the CID is used to identify the control to AutoIt?:

FileWriteLine($file, GUICtrlRead($mapx))

Now the content of the control will be written to the file.

I hope that is sufficiently clear.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...