Sign in to follow this  
Followers 0
Dlund

Dynamic array code request

22 posts in this topic

#1 ·  Posted (edited)

hi-- I'm fairly new to autoit, and am at an impasse in the code I'm trying to write.

To learn what I seem to not be able to teach myself, I would like to see code that does a fairly simple thing, using either a multidimensional array, or multiple single dimensional arrays.

How would you make a script to have a dialogue box come up with 3 value boxes to ask for x,y,z coordinates, then have a couple of buttons-- one to save where you are and display the string of coordinates you have saved, or to save the current value and go on to the next one.
 

looking something like this
https://drive.google.com/file/d/0B-qmcX0K3QZXTTFyR3lxTDhHNkU/edit?usp=sharing

In the end, I want to be able to call these arrays, saved to an ini with [F1-F8]. My current understanding writes values to be read from the ini to the script one value at a time.  so my config file looks like, 

2xPos[0]=1200
2yPos[0]=769
2xPos[1]=0
2yPos[1]=0
2xPos[2]=0
2yPos[2]=0

 

 

 

Could this be cleaned to
2i=[1200][769][1],[0][0][0] ; <--(0,0,0) to be interpreted as the end of the sequence

 

 

? Ideally, this script will be able to intake an infinite number of variables and save them to a config file to be reloaded later.

 

Edited by Dlund

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstantsEx.au3>

$oForm1 = GUICreate("Form1", 623, 226, 192, 114)
$Input1 = GUICtrlCreateInput("X Value", 8, 8, 177, 21)
GUICtrlSetData(-1, "New Data")
$Input2 = GUICtrlCreateInput("Y Value", 264, 8, 129, 21)
$Input3 = GUICtrlCreateInput("Z Value", 496, 8, 121, 21)
;GUICtrlSetState(-1, $GUI_DISABLE)

$Button1 = GUICtrlCreateButton("$Button1", 8, 187, 137, 16)
$Button2 = GUICtrlCreateButton("$Button2", 152, 187, 145, 16)
$Button3 = GUICtrlCreateButton("$Button3", 304, 187, 137, 16)

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
                  GUICtrlSetData($Input1, "Newer Data")
        Case $Button2


        Case $Button3

    EndSwitch
WEnd

Here is a start to the msg box you want and the loop that will wait for user interaction. I hacked it out of a past project so you will have to re-position all of the elements.

Edited by Shane0000
1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

For the Functions look into IniWriteSection/IniWrite and IniReadSection,/IniRead

you can save your 6 coordinate as 

$sIniLine = $x1 & ',' & $y1 & ',' & $z1& ',' & $x2 & ',' & $y2 & ',' & $z2 

so that when you read this from the INI you can use

StringSplit($LineFromIni, ',', $STR_NOCOUNT)

and this will split it into a 6 element array ($a2i = [ $x1 , $y1 , $z1 , $x2 , $y2 , $z2 ])

Where $a2i[0] would equal $x1

Edited by Shane0000
1 person likes this

Share this post


Link to post
Share on other sites

@shane0000 - Please note "to be interpreted by the bot"

Thread reported

1 person likes this

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

My apologies kylomas.  I do use the term lightly. the script does nothing more than click in a prerecorded sequence as fast as possible.

Thank you for your time, all. 

Share this post


Link to post
Share on other sites

Dlund,

The "bot" word raises red flags around here - see the Forum rules to understand why. Can you please explain why you are trying to store coordinates and click types for later use. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

<snip>

Ive added a fourth value where you can specify a pause between clicks.

Edited by Melba23
Removed code

Share this post


Link to post
Share on other sites

Geir1983,

When a Mod has asked questions in a thread as I did above, it is NOT a good idea to post any help until the all-clear has been given. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

It is for macro creation for any stationary screen; so, in this instance say I want to set [F1] to create bold.  Then, I might hover my cursor over the big then set the button for left click.  While typing, I can simply press F1 then type and press f1 again to stop bold.  As long as my window hasn't moved the mouse will left click in the positiion recorded.  This could be extended to do bold, then italic, then underline, and i will ideally have it run the line backwards with, say f9.  This will then "undo" them running through the sequence again in reverse. 

Share this post


Link to post
Share on other sites

Dlund,

Fine - just avoid the "bot" word in future, please. ;)

But there might be ways to activate these buttons without such a cumbersome process. What app are you trying to automate? :huh:

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Thank you M23 :) Unfortunately, we are getting off topic.

Back to the request at hand, a gui to prompt for three values at a time then store them to an array.
 Config file has not yet been incorporated

I'm this far

#include <GUIConstantsEx.au3>
#include <Array.au3>
main()

Func saveData($arr, $newData)

    If IsArray($arr) = 1 Then
        $Bound = UBound($arr)
        ReDim $arr[$Bound+1]
        $arr[$Bound] = $newData
    Else
        Dim $arr[1]
        $arr[0] = $newData
     EndIf
   Return $arr
  EndFunc



Func main()
   dim $arr1;
   $oForm1 = GUICreate("Form1", 623, 226, 192, 114)
   $Input1 = GUICtrlCreateInput("X Value", 8, 8, 177, 21)
   $Input2 = GUICtrlCreateInput("Y Value", 264, 8, 129, 21)
   $Input3 = GUICtrlCreateInput("Z Value", 496, 8, 121, 21)
         GUICtrlSetData($Input1, "New Data")
         GUICtrlSetData($Input2, "New Data")
         GUICtrlSetData($Input3, "New Data")

   $Button1 = GUICtrlCreateButton("Save and Continue", 8, 187, 137, 16)
   $Button2 = GUICtrlCreateButton("Save and Print", 152, 187, 145, 16)
   $Button3 = GUICtrlCreateButton("Cancel and Print", 304, 187, 137, 16)

   GUISetState(@SW_SHOW)

   While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
                  $arr1 = saveData($arr1, $Input1)
                  $arr1 = saveData($arr1, $Input2)
                  $arr1 = saveData($arr1, $Input3);
                  GUICtrlSetData($Input1, "Newer Data")
                  GUICtrlSetData($Input2, "Newer Data")
                  GUICtrlSetData($Input3, "Newer Data")
               Case $Button2
                  $arr1 = saveData($arr1, $Input1)
                  $arr1 = saveData($arr1, $Input2)
                  $arr1 = saveData($arr1, $Input3);
                  _ArrayDisplay($arr1)
        Case $Button3
           _ArrayDisplay($arr1)
            Exit
    EndSwitch
WEnd
EndFunc 

this prompts for values, stores a number to an array which increases in size as values are added... but-- how the values are being stored, they are seemingly being overwritten.

Inputting the values: [1,2,3,4,5,6] to [x1,y1,z1,x2,y2,z2] respectively yields the following array

 

Row|Col 0

[0]|3
[1]|4
[2]|5
[3]|3
[4]|4
[5]|5
 

:huh2:

**Edit**
Looking into the saveData function, I assumed that It was returning 3,4,5 being, perhaps, the last three values of Bound or UBound; but continuing to input data up to 7,8, and 9 has yielded more repetition of 3,4,5.

Also, entering in numbers of multiple hundreds are also returning repetitious 3,4,5

Edited by Dlund

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Pardon me but you failed to answer the moderator's question. Melba asked you "What is the name of the application?"

(Forgive me for speaking out of turn Melba):

I believe you are being asked this question for you may be going down a road with lots of work in front of you when a much simpler solution may already be available. The goal here is we want to help you but it is best to work smart, not hard. ;)

Edited by MBALZESHARI

Share this post


Link to post
Share on other sites

Well, I'm not sure how to answer the question.  The app being automated is not really an app.. it is simply the user interface. 

The extrapolation of this code application works by asking:
Which button would you like to press to automate movements?
When you press this button, where should the mouse click?
once it clicks there, should it click elsewhere?

As far as I see my script, it does not automate an app.  I don't understand how I could work at this smarter.

Share this post


Link to post
Share on other sites

Dlund,

The question is not difficult to answer:

I might hover my cursor over the big [ B ]

The "big [ B ]" in what window? You are looking to store coordinates and say "as long as my window hasn't moved" - so this button must exist in some window. All we are asking is:

 

What app owns that window?

Is that so hard to answer? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I guess he means the big in the forum editor, he mentions "Bold".

1 person likes this

Share this post


Link to post
Share on other sites

Werty,

That is really helpful - why not wait ( I was going to say STFU) until the OP answers? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

<snip>

 

There are easier, more reliable ways to work with some of the better known programs that could save you loads of time. I suggest you step back and get a plan of attack together and make sure there are not easier ways to do what you want.

Edited by Melba23
Lines removed

Share this post


Link to post
Share on other sites

Shane0000,

Did you not read my post #8 above? As my post #14 asks a pretty pointed question, I would have thought that it was obvious that I was no longer happy with the thread and that everyone else should keep out. :(

Please engage brain before posting in future - if you want to discuss it send me a PM so we do not clutter this disaster of a thread any further. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Dlund,

The question is not difficult to answer:

The "big [ B ]" in what window? You are looking to store coordinates and say "as long as my window hasn't moved" - so this button must exist in some window. All we are asking is:

 

What app owns that window?

Is that so hard to answer? :huh:

M23

 

Google Chrome would harness the big next to my avatar here that denotes posting these letters as bold.  

With my app, that process would only mean pressing [F1]: to move my cursor to the , click, then there again when [F1] is pressed again.

What apps might be more reliable?  I tend to reinvent the wheel a lot.

  

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Sorry Melba for me speaking.

Dlund,

  Your missing the point here. You obviously want to automate something specific. We are not stupid. You are dancing around answering the question and basically refusing to answer. This is no time to be cute, no time to think you can be evasive so you can get what you want. Just answer his question CLEARLY. I strongly suspect if you answer like how you answered before you will receive a locked thread and a vacation from the forum by a moderator.

This is what is being asked of you:

If it is a web browser then the name of the site?

If it is an app then the name of the app?

If this is not clear enough for you then I can tell you from being here for 10 years you won't last long here. If you have any questions on how we do things here, feel free to read the forum rules. The rules here are specific and are strictly enforced. Please do not waste our time trying to get around them. That has failed for the hundreds that have tried that route before you. Been there, seen it, watched and ate popcorn while the moderator took care of business.

Now if you are doing something for a legitimate purpose, I would be glad to help you. However, it HAS to be allowed by forum rules. Is this not clear enough for you? So please, just answer the question. 

What are you trying to automate?

Thanks.

(Again, sorry Melba, forgive me for speaking out of turn)

Edited by MBALZESHARI

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0