ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

autohotkey arrays

<< < (2/2)

rulfzid:
I'm always fighting with them can you tell me what's the easiest way to maintain a list of strings, add a listitem, remove a listitem, return a listitem? For example I'd like to keep a list of hidden window titles and then unhide one and remove it from the list. Autohotkey makes it really hard, I usually build a concatenated string and split them into an array but then when i want to return a value but am not sure where its position is it's near impossible.

Any ideas?
-justice (September 17, 2008, 07:45 AM)
--- End quote ---

I know this thread is a bit old, but here are a couple of threads you could take a look at from the AHK forums:

SimpleArray
AHKArray

Also, for your initial problem, I'd first recommend working with window handles instead of window titles, but either way, you could use the native AHK string commands, which are pretty fast:


--- ---hiddenwindowlist = window 1,window 2,window 3,window 4,

MsgBox, % "The current list: " hiddenwindowlist

unhide( "window 3", hiddenwindowlist)

MsgBox, % "The new list: " hiddenwindowlist

unhide( wintitle_to_unhide, ByRef wlist )
{
    If wintitle_to_unhide in %wlist%                            ; is wintitle_to_unhide in our list?
    {
        MsgBox, % "Unhiding " wintitle_to_unhide                ; then show the window
        StringReplace, wlist, wlist, %wintitle_to_unhide%`,     ; and remove it from the list
    }
}

justice:
Thanks so much for your  post rulfzid! AHKArray looks promising and I learned a lot from your example. I always used Instring to check if a value was in a string but the if statement you used is more readable, and the string replace is clever.

Navigation

[0] Message Index

[*] Previous page

Go to full version