Runing a cmd using vars in a table

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
FalconSaint
Posts: 1
Joined: 25 Apr 2018, 11:44

Runing a cmd using vars in a table

25 Apr 2018, 12:05

So, In short, I've got a table in a program with a bunch of different network elements. Several columns, I only care about the first 2.
I've build a stringreplace and stringsplit script to give me usable variables when i'm selecting only one row from the table.

However, I need help finding out how I can grab the variables from multiple rows to run a function using only data from one of the columns of those rows
Example. Column A is the element name, column B is the element IP.
I want to select >1 number of rows.
And then run the same command using the data from column B.

exhibit:

Code: Select all

COLUMN A |  COLUMN B  | JUNK   | JUNK | JUNK | JUNK
NAME     |192.168.1.1 | Blah   | Blah | Blah | Blah
NAMEA    |192.168.1.2 | Blah   | Blah | Blah | Blah
NAMEB    |192.168.1.3 | Blah   | Blah | Blah | Blah
NAMEC    |192.168.1.4 | Blah   | Blah | Blah | Blah
Result:
CMD Prompt
Ping 192.68.1.1 -t

New CMD Prompt window
ping 192.168.1.2 -t

New CMD Prompt window
ping 192.168.1.3 -t

New CMD Prompt window
ping 192.168.1.4 -t

etc, etc, etc



I would also like the assigned variables be reusable while the script is running, for example, instead of just pining everything, I want to be able to have the script use those vars to open terminal sessions to, as an example.




Much help appreciated.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Runing a cmd using vars in a table

27 Apr 2018, 17:32

Hi.
Your issue seems small, but it is a bit bigger.
You have wrote
FalconSaint wrote:... I want to select >1 number of rows. ...
There are so much different ways to "select" a row.
I think, your list is saved on hard disk.
  • You can directly read a row with Loop, Read, ...
  • You can load your file into a variable and you can use a similar command Loop, parse, ...
  • You could load into a ListView and select with mouse or cursor
  • You could read into an array
  • ...
As it is easiest way, I recommend using first suggestion together with an edit field, where you can type the row-number inside.
If you want to do this more professional, use a ListView. Easy way like below:

Code: Select all

Gui, add, Button, w100 h25 gMyButton, Start
Gui, add, Edit, vMyEdit
Gui, show
GuiControl, Focus, MyEdit
return

MyButton:
GuiControlGet, Out,, MyEdit
FileReadLine, OutRow, table.txt, Out+1 ; As we have a header, we must consider this with "Out+1"
ip_array := StrSplit(OutRow, "|")  ; Omits periods.
MsgBox % "The IP is " ip_array[2]
; do your desired stuff with comspec 
return
Quick and dirty
Einfach nur ein toller Typ. :mrgreen:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, mikeyww and 314 guests