Basic Array Stuff Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
magicinmath
Posts: 162
Joined: 12 Apr 2017, 23:03

Basic Array Stuff

14 Apr 2017, 17:56

Hey I'm trying to figure out how to read from a given window instead of a path. I tried ControlGetText, WinGetText instead, but didn't work :( ... Not sure what the command would be and how to relate the array object to it.

Code: Select all

^!+.::

	Array := Object()
	Array[j] := A_LoopField
	Array[j, k] := A_LoopReadLine

	ArrayCount := 0       
                 
	Loop, Read, path\file		;this is the line I'd like to change to access an unsaved notepad rather than read from a saved file.
	{
		ArrayCount += 1
		Array[ArrayCount] := A_LoopReadLine
	}

	Loop %ArrayCount%
	{

		MsgBox % Array[A_Index]
	}

Return
Thanks for your help.
Xeno234
Posts: 71
Joined: 24 Mar 2017, 18:14

Re: Basic Array Stuff

14 Apr 2017, 18:25

Code: Select all

f3::
	ControlGetText, var, edit1, ahk_class Notepad
	arr := strsplit(var, "`n")
	/* or
	arr := []
	loop, parse, var, `n
		arr.push(A_LoopField)
	*/	
	loop % arr.length()
		msgbox % arr[a_index]
return
pneumatic
Posts: 338
Joined: 05 Dec 2016, 01:51

Re: Basic Array Stuff  Topic is solved

14 Apr 2017, 18:50

"For dummies" version...

Code: Select all

^!F3::

	Array := Object()
	ControlGetText, NotepadText, Edit1, Untitled - Notepad   ;Use Window Spy to get the names of "Edit1" and "Untitled - Notepad" ; see image
	
    ArrayCount := 0             
	Loop, parse, NotepadText, `n, `r	
	{
		ArrayCount := ArrayCount + 1
		Array[ArrayCount] := A_LoopField
	}

	Loop %ArrayCount%
	{
		MsgBox % Array[A_Index]
	}

return
Image
magicinmath
Posts: 162
Joined: 12 Apr 2017, 23:03

Re: Basic Array Stuff

14 Apr 2017, 20:05

This is so helpful. I really appreciate the "for dummies" version and I learned a lot, especially showing me what the heck edit1 meant.
I have so many applications for that :) Thank you again.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RussF and 388 guests