GUI Scroll Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
sqlcode
Posts: 27
Joined: 02 Nov 2017, 08:55

GUI Scroll

21 Feb 2018, 17:28

I am going through old topics but couldn't find anything that works so posting a new question here. I apologize if this is a repeat question and if its repeat, would appreciate someone pointing me to the right link.

I have a small gui application to configure hotkeys. It works fine if my number of Hotkeys are 25. If I have more than 25 hotkeys, then I need GUI window to be scrollable. How do I handle that?

Thanks,
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: GUI Scroll

21 Feb 2018, 17:46

My scrolling was sourced from http://www.autohotkey.com/board/topic/2 ... ntry168174 by Lexikos. There may be better ways nowadays. But it worked for me.

These are snippets of code; you should be able to implement just with this.

Code: Select all

OnMessage(0x115, "OnScroll") ; WM_VSCROLL
OnMessage(0x114, "OnScroll") ; WM_HSCROLL

Code: Select all

Hotkey, *WheelUp, WheelScroll
Hotkey, *WheelDown, WheelScroll
WheelScroll:
    ; SB_LINEDOWN=1, SB_LINEUP=0, WM_HSCROLL=0x114, WM_VSCROLL=0x115
    OnScroll(InStr(A_ThisHotkey,"Down") ? 1 : 0, 0, GetKeyState("Shift") ? 0x114 : 0x115, WinExist())
return

Code: Select all


; http://www.autohotkey.com/board/topic/26033-scrollable-gui-proof-of-concept/#entry168174

UpdateScrollBars(GuiNum, GuiWidth, GuiHeight)
{
    static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1
    
    Gui, %GuiNum%:Default
    Gui, +LastFound
    
    ; Calculate scrolling area.
    Left := Top := 9999
    Right := Bottom := 0
    WinGet, ControlList, ControlList
    Loop, Parse, ControlList, `n
    {
        GuiControlGet, c, Pos, %A_LoopField%
        if (cX < Left)
            Left := cX
        if (cY < Top)
            Top := cY
        if (cX + cW > Right)
            Right := cX + cW
        if (cY + cH > Bottom)
            Bottom := cY + cH
    }
    Left -= 8
    Top -= 8
    Right += 8
    Bottom += 8
    ScrollWidth := Right-Left
    ScrollHeight := Bottom-Top
    
    ; Initialize SCROLLINFO.
    VarSetCapacity(si, 28, 0)
    NumPut(28, si) ; cbSize
    NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask
    
    ; Update horizontal scroll bar.
    NumPut(ScrollWidth, si, 12) ; nMax
    NumPut(GuiWidth, si, 16) ; nPage
    DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1)
    
    ; Update vertical scroll bar.
;     NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask
    NumPut(ScrollHeight, si, 12) ; nMax
    NumPut(GuiHeight, si, 16) ; nPage
    DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1)
    
    if (Left < 0 && Right < GuiWidth)
        x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left)
    if (Top < 0 && Bottom < GuiHeight)
        y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top)
    if (x || y)
        DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0)

}

OnScroll(wParam, lParam, msg, hwnd)
{
    static SIF_ALL=0x17
	SCROLL_STEP:=(msg=0x115)?32:295 ; made a change to this so horizontal scrolling is larger
    
    bar := msg=0x115 ; SB_HORZ=0, SB_VERT=1
    
    VarSetCapacity(si, 28, 0)
    NumPut(28, si) ; cbSize
    NumPut(SIF_ALL, si, 4) ; fMask
    if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si)
        return
    
    VarSetCapacity(rect, 16)
    DllCall("GetClientRect", "uint", hwnd, "uint", &rect)
    
    new_pos := NumGet(si, 20, "int") ; nPos
    
    action := wParam & 0xFFFF
    if action = 0 ; SB_LINEUP
        new_pos -= SCROLL_STEP
    else if action = 1 ; SB_LINEDOWN
        new_pos += SCROLL_STEP
    else if action = 2 ; SB_PAGEUP
        new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP
    else if action = 3 ; SB_PAGEDOWN
        new_pos += NumGet(rect, 12, "int") - SCROLL_STEP
    else if (action = 5 || action = 4) ; SB_THUMBTRACK || SB_THUMBPOSITION
        new_pos := wParam>>16
    else if action = 6 ; SB_TOP
        new_pos := NumGet(si, 8, "int") ; nMin
    else if action = 7 ; SB_BOTTOM
        new_pos := NumGet(si, 12, "int") ; nMax
    else
        return

    
    min := NumGet(si, 8, "int") ; nMin
    max := NumGet(si, 12, "int") - NumGet(si, 16, "int")  ; nMax-nPage
    new_pos := new_pos > max ? max : new_pos
    new_pos := new_pos < min ? min : new_pos
    
    old_pos := NumGet(si, 20, "int") ; nPos
    
    x := y := 0
    if bar = 0 ; SB_HORZ
        x := old_pos-new_pos
    else
        y := old_pos-new_pos
    ; Scroll contents of window and invalidate uncovered area.
    DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0)
    
    ; Update scroll bar.
    NumPut(new_pos, si, 20, "int") ; nPos
    DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1)
}
I might have made my own changes to the code compared to the original thread to make it work on my system; I never heard complaints of it not working when other people used the program I distributed as an .exe.
sqlcode
Posts: 27
Joined: 02 Nov 2017, 08:55

Re: GUI Scroll

02 Mar 2018, 13:42

Sorry for delayed response and i am going to apologize in advance for asking this stupid question, but do i have to use these in conjunction? Would you have an example of a small gui that uses this control? Obviously first two snippets look good because there is not a lot of coding involved but i doubt that's the case. I tried and it didn't work so i am sure i am missing a piece here.

Thanks,
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: GUI Scroll  Topic is solved

03 Mar 2018, 04:41

Huh, I'm struggling to make it work with a sample GUI. Here is a working script in full. Remind me tomorrow to shorten the code or figure out a better sample... I see I have many commented out sections. A lot of the code is just data generation.

I was struggling to come up with a sample code that actually scrolled. This code does work. Please select "RBY" in the dropdownmenu and then in MaxColumns enter "1" to force scrolling.

I am confident the scrolling function(s) in the code below is different than what I shared previously. I Tried using the code I posted above to make the sample GUI which wouldn't scroll for me. I dug around for several instances of OnScroll() throughout my .ahk files and even those "working" codes no longer seemed to work, and in those codes I had attempted to artificially emulate the scrollbar buttons of the up/down arrows because they initially did not work for me. The code below does have a fully functional scrollbar, which tells me I must have changed something at some point to make it all work.

Again, sorry for this being such massive code. But I have published this in the past and it has worked fine. (And maybe one day I'd update it for the newest games... Probably, not though.)

Code: Select all

#SingleInstance
; Pokemon Nuzlocke Encounter Tracking
version:=0.2
title:="Nuzlocke Encounter Tracking"
; This software is NOT FOR SALE. This software may be modified so long as any derived works are NOT FOR SALE.

SysGet, WorkArea, MonitorWorkArea
WorkAreaWidth:=WorkAreaRight-WorkAreaLeft
WorkAreaHeight:=WorkAreaBottom-WorkAreaTop

OnMessage(0x115, "OnScroll") ; WM_VSCROLL
OnMessage(0x114, "OnScroll") ; WM_HSCROLL

Hotkey, IfWinActive, %title%
Hotkey, *WheelUp, WheelScroll
Hotkey, *WheelDown, WheelScroll
Hotkey, ^s, &Save
Hotkey, ^o, &Open
Hotkey, ^n, &New
Hotkey, IfWinActive


; All the data is below

Gen1:=["Pallet Town","Route 1","Viridian City","Route 22","Route 2","Viridian Forest","Route 3","Route 4","Mt. Moon","Cerulean City","Route 24","Route 25","Route 5","Route 6","Vermillion City","Route 11","Diglett's Cave","Route 9","Route 10","Rock Tunnel","Pokemon Tower","Route 12","Route 8","Route 7","Celadon City","Route 16","Route 17","Route 18","Fuschia City","Safari Zone","Route 15","Route 14","Route 13","Power Plant","Route 19","Route 20","Seafoam Islands","Cinnabar Island","Pokemon Mansion","Route 21","Route 23","Victory Road","Cerulean Cave"]
; Omitted Pewter City, Lavendar Town, Saffron City, Silph Co, SS Anne, Underground x2, Rocket Hideout, Indigo Plateau

Gen1_Safari_Zone:=["Area 1","Area 2","Area 3","Area 4"]
Gen1_Victory_Road:=["Floor 1","Floor 2","Floor 3"]
Gen1_Mt_Moon:=["Floor 1","Lower Floor 1","Lower Floor 2"]
Gen1_Seafoam_Islands:=["Floor 1","Lower Floor 1","Lower Floor 2","Lower Floor 3","Lower Floor 4"]
Gen1_Pokemon_Mansion:=["Floor 1","Floor 2","Floor 3","Lower Floor 1"]
Gen1_Pokemon_Tower:=["Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Floor 7"]
Gen1_Rock_Tunnel:=["Floor 1","Lower Floor 1"]
Gen1_Cerulean_Cave:=["Floor 1","Floor 2","Lower Floor 1"]

Gen1_Additionals:=[Gen1_Safari_Zone,Gen1_Victory_Road,Gen1_Mt_Moon,Gen1_Seafoam_Islands,Gen1_Pokemon_Mansion,Gen1_Pokemon_Tower,Gen1_Rock_Tunnel,Gen1_Cerulean_Cave]

Extender("Gen1")


Gen2:=["New Bark Town","Route 29","Cherrygrove City","Route 30","Route 31","Dark Cave","Violet City","Sprout Tower","Route 32","Ruins of Alph","Union Cave","Route 33","Azalea Town","Slowpoke Well","Ilex Forest","Route 34","Goldenrod City","Route 35","National Park","Route 36","Route 37","Ecruteak City","Burned Tower","Tin Tower","Route 38","Route 39","Olivine City","Route 40","Route 41","Whirl Islands","Cianwood City","Route 42","Mt. Mortar","Mahogany Town","Rocket Hideout","Route 43","Lake of Rage","Route 44","Ice Path","Blackthorn City","Dragon's Den","Route 45","Dark Cave 2","Route 46","Route 27","Tohjo Falls","Route 26","Victory Road","Indigo Plateau","Vermillion City","Route 6","Saffron City","Route 5","Route 7","Route 8","Route 10","Power Plant (Crystal, Trade)","Rock Tunnel","Route 9","Cerulean City","Route 24","Route 25","Route 4","Route 16","Route 17","Route 18","Fuschia City","Route 15","Route 14","Route 13","Route 12","Route 11","Diglett's Cave","Route 2","Pewter City","Route 3","Mt Moon","Viridian City","Route 1","Pallet Town","Route 21","Cinnabar Island","Route 20","Route 19","Route 22","Route 28","Mt. Silver"]

;Omitted Lighthouse, S.S. Aqua, Radio Tower, Goldenrod City Underground, Mahogany Town, Reception Gate, Route 23, Saffron City, Lavendar Town, Seafoam Islands
;Power Plant trade for Crystal

Gen2_Ruins_of_Alph:=["Outside","Inside"]
Gen2_Sprout_Tower:=["Floor 2","Floor 3"]
Gen2_Union_Cave:=["Floor 1","Lower Floor 1","Lower Floor 2"]
Gen2_Slowpoke_Well:=["Floor 1","Lower Floor 1"]
Gen2_Burned_Tower:=["Floor 1","Lower Floor 1"]
Gen2_Tin_Tower:=["Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Floor 7","Floor 8","Floor 10"]
Gen2_Whirl_Islands:=["Upper Left","Upper Right","Lower Left","Lower Right","Lower Floor 1","Lower Floor 1 Middle","Lower Floor 2","Lower Floor 2 Inner"]
Gen2_Ice_Path:=["Floor 1","Lower Floor 1","Lower Floor 2 Room 1","Lower Floor 3","Lower Floor 2 Room 2"]
Gen2_Victory_Road:=["Floor 1","Floor 2","Floor 3"]
Gen2_Rock_Tunnel:=["Floor 1","Lower Floor 1"]
Gen2_Vermillion_City:=["","Harbor"]
Gen2_Mt_Moon:=["Floor 1","Floor 2"]
Gen2_Mt_Silver:=["Outside","Entrance","Inside","Waterfall Cave","End"]

Gen2_Additionals:=[Gen2_Ruins_of_Alph,Gen2_Sprout_Tower,Gen2_Union_Cave,Gen2_Slowpoke_Well,Gen2_Burned_Tower,Gen2_Tin_Tower,Gen2_Whirl_Islands,Gen2_Ice_Path,Gen2_Victory_Road,Gen2_Rock_Tunnel,Gen2_Vermillion_City,Gen2_Mt_Moon,Gen2_Mt_Silver]

Extender("Gen2")


Gen1R:=["Pallet Town","Route 1","Viridian City","Route 22","Route 2","Viridian Forest","Route 3","Route 4","Mt. Moon","Cerulean City","Route 24","Route 25","Route 5","Route 6","Vermillion City","Route 11","Diglett's Cave","Route 9","Route 10","Rock Tunnel","Pokemon Tower","Route 12","Route 8","Route 7","Celadon City","Route 16","Route 17","Route 18","Fuschia City","Safari Zone","Route 15","Route 14","Route 13","Power Plant","Route 19","Route 20","Seafoam Islands","Cinnabar Island","Pokemon Mansion","Route 21","One Island","Treasure Beach","Kindle Road","Mt. Ember","Cape Brink","Three Isle Port","Bond Bridge","Berry Forest","Route 23","Victory Road","Four Island","Icefall Cave","Five Island","Five Isle Meadow","Memorial Pillar","Water Labyrinth","Resort Gorgeous","Lost Cave","Water Path","Green Path","Pattern Bush","Outcast Island","Altering Cave","Ruin Valley","Trainer Tower","Canyon Entrance","Seavault Canyon","Tanoby Ruins","Cerulean Cave"]

; Omitted Pewter City, S.S. Anne, Saffron City, Two Island, Three Island, Six Island, Dotted Cave, Seven Island, 

Gen1R_Safari_Zone:=["Area 1","Area 2","Area 3","Area 4"]
Gen1R_Victory_Road:=["Floor 1","Floor 2","Floor 3"]
Gen1R_Mt_Moon:=["Floor 1","Lower Floor 1","Lower Floor 2"]
Gen1R_Seafoam_Islands:=["Floor 1","Lower Floor 1","Lower Floor 2","Lower Floor 3","Lower Floor 4"]
Gen1R_Pokemon_Mansion:=["Floor 1","Floor 2","Floor 3","Lower Floor 1"]
Gen1R_Pokemon_Tower:=["Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Floor 7"]
Gen1R_Rock_Tunnel:=["Floor 1","Lower Floor 1"]
Gen1R_Cerulean_Cave:=["Floor 1","Floor 2","Lower Floor 1"]
Gen1R_Mt_Ember:=["Base","Summit","Summit Path Floor 1","Summit Path Floor 2","Summit Path Floor 3","Ruby Path Floor 1","Ruby Path Lower Floor 1","Ruby Path Lower Floor 2","Ruby Path Lower Floor 3","Ruby Path Lower Floor 4"]
Gen1R_Icefall_Cave:=["Floor 1 Room 1","Floor 1 Room 2","Floor 1 Room 3","Lower Floor 1"]
Gen1R_Lost_Cave:=["Room 1","Room 2","Room 3","Room 4","Room 5","Room 6","Room 7","Room 8","Room 9","Room 10","Room 11","Room 12","Room 13","Room 14"]
Gen1R_Tanoby_Ruins:=["","Monean Chamber","Liptoo Chamber","Weepeth Chamber","Dilford Chamber","Scufib Chamber","Rixy Chamber","Viapois Chamber"]

Gen1R_Additionals:=[Gen1R_Safari_Zone,Gen1R_Victory_Road,Gen1R_Mt_Moon,Gen1R_Seafoam_Islands,Gen1R_Pokemon_Mansion,Gen1R_Pokemon_Tower,Gen1R_Rock_Tunnel,Gen1R_Cerulean_Cave,Gen1R_Mt_Ember,Gen1R_Icefall_Cave,Gen1R_Lost_Cave,Gen1R_Tanoby_Ruins]

Extender("Gen1R")



Gen3:=["Littleroot Town","Route 101","Route 102","Route 103","Petalburg City","Route 104","Petalburg Woods","Rustboro City","Route 115","Route 116","Rusturf Tunnel","Dewford Town","Route 106","Granite Cave","Route 107","Slateport City","Route 110","Altering Cave","New Mauville","Route 117","Route 111","Mirage Tower (Emerald)","Route 112","Fiery Path","Route 113","Route 114","Desert Underpass (Emerald)","Meteor Falls","Jagged Pass","Lavaridge Town","Route 118","Route 119","Fortree City","Route 120","Route 121","Safari Zone","Lilycove City","Route 122","Mt. Pyre","Route 123","Team Magma Hideout (Emerald)","Route 124","Mossdeep City","Route 125","Shoal Cave","Route 127","Route 128","Seafloor Cavern","Route 126","Sootopolis City","Cave of Origin","Route 129","Route 130","Route 131","Sky Pillar","Pacifidlog Town","Mirage Island","Route 105","Route 108","Abandoned Ship","Route 109","Route 132","Route 133","Route 134","Ever Grande City","Victory Road","S.S. Tidal","Battle Frontier","Artisan Cave"]

; Omitted Oldale Town, Trick House, Mauville City, Verdanturf Town, Trainer Hill, Mt. Chimney, Fallarbor Town, Scorched Slab, Southern Island (Event Only, but is accessed in ORAS)
; Trade is Fortree City, Rustboro. Rustboro also has Fossils. Also Pacifidlog, but can water encounter there.
; Gift is Lavaridge Town.

Gen3_Mirage_Tower_Emerald:=["Floor 1","Floor 2","Floor 3","Floor 4"]
Gen3_Granite_Cave:=["Floor 1 Room 1","Floor 1 Room 2","Lower Floor 1","Lower Floor 2"]
Gen3_New_Mauville:=["Entrance","Building"]
Gen3_Meteor_Falls:=["Floor 1 Room 1","Floor 1 Room 2","Lower Floor 1","Lower Floor 1","Steven's Room (Emerald)"]  ; Different rooms in ORAS
Gen3_Safari_Zone:=["Southwest","Southeast","Northwest","Northeast"]
Gen3_Mt_Pyre:=["Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Outside","Summit"]
Gen3_Team_Magma_Hideout_Emerald:=["Room 1","Room 2","Room 3","Room 4","Room 5","Room 6","Room 7"]
Gen3_Shoal_Cave:=["High Tide Room 1","High Tide Room 2","Low Tide Floor 1 Room 1","Low Tide Floor 1 Room 2","Low Tide Lower Floor 1","Low Tide Lower Floor 2","Low Tide Lower Floor 3"]
Gen3_Seafloor_Cavern:=["Entrance","Room 6","Room 7"]
Gen3_Cave_of_Origin:=["Floor 1 Room 1","Floor 1 Room 2","Lower Floor 1","Lower FLoor 2","Lower Floor 3","Lower Floor 4"]
Gen3_Sky_Pillar:=["Floor 1","Floor 3","Floor 5","Floor 6"]
Gen3_Victory_Road:=["Floor 1","Lower Foor 1","Lower Floor 2"]
Gen3_Artisan_Cave:=["Floor 1","Lower Floor 1"]

Gen3_Additionals:=[Gen3_Mirage_Tower_Emerald,Gen3_Granite_Cave,Gen3_New_Mauville,Gen3_Meteor_Falls,Gen3_Safari_Zone,Gen3_Mt_Pyre,Gen3_Team_Magma_Hideout_Emerald,Gen3_Shoal_Cave,Gen3_Seafloor_Cavern,Gen3_Cave_of_Origin,Gen3_Sky_Pillar,Gen3_Victory_Road,Gen3_Artisan_Cave]

Extender("Gen3")


Gen3R:=["Littleroot Town","Route 101","Route 102","Route 103","Petalburg City","Route 104","Petalburg Woods","Rustboro City","Route 115","Route 116","Rusturf Tunnel","Dewford Town","Route 106","Granite Cave","Route 107","Slateport City","Route 110","Altering Cave","New Mauville","Route 117","Route 111","Route 112","Fiery Path","Route 113","Route 114","Meteor Falls","Jagged Pass","Lavaridge Town","Route 118","Southern Island","Route 119","Fortree City","Route 120","Route 121","Safari Zone","Lilycove City","Route 122","Mt. Pyre","Route 123","Team Aqua/Magma Hideout Entrance","Route 124","Mossdeep City","Route 125","Shoal Cave","Route 127","Route 128","Seafloor Cavern","Route 126","Sootopolis City","Cave of Origin","Soaring","Route 129","Route 130","Route 131","Sky Pillar","Pacifidlog Town","Mirage Island","Route 105","Route 108","Abandoned Ship","Route 109","Route 132","Route 133","Route 134","Ever Grande City","Victory Road","S.S. Tidal","Pathless Plain","Nameless Cavern","Fabled Cave","Gnarled Den","Trackless Forest","Crescent Isle","Battle Resort","Mirage Cave","Mirage Forest","Mirage Island","Mirage Mountain"]

; Omitted Oldale Town, Trick House, Mauville City, Verdanturf Town, Trainer Hill, Mt. Chimney, Fallarbor Town, Scorched Slab
; Trade is Fortree City, Rustboro. Rustboro also has Fossils. Also Pacifidlog, but can water encounter there.
; Gift is Lavaridge Town.
Gen3R_Granite_Cave:=["Floor 1 Room 1","Floor 1 Room 2","Lower Floor 1","Lower Floor 2"]
Gen3R_Meteor_Falls:=["Floor 1 Room 1","Floor 1 Room 2","Lower Floor 1","Lower Floor 1"]
Gen3R_Safari_Zone:=["Southwest","Southeast","Northwest","Northeast"]
Gen3R_Mt_Pyre:=["Floor 1","Floor 2","Floor 3","Floor 4","Outside","Summit"]
Gen3R_Shoal_Cave:=["High Tide Room 1","High Tide Room 2","Low Tide Floor 1 Room 1","Low Tide Floor 1 Room 2","Low Tide Lower Floor 1","Low Tide Lower Floor 2","Low Tide Lower Floor 3"]
Gen3R_Seafloor_Cavern:=["Room 1","Room 2","Room 3","Room 4","Room 5","Room 6","Room 7","Room 8","Room 9","Room 10"]
Gen3R_Cave_of_Origin:=["Floor 1","Lower Floor 1","Lower FLoor 2","Lower Floor 3","Lower Floor 4","Slide Path","Deepest"]
Gen3R_Sky_Pillar:=["Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Summit"]
Gen3R_Victory_Road:=["Floor 1 Room 1","Floor 1 Room 2","Lower Foor 1","Floor 2 Room 1","Floor 2 Room 2"]

Gen3R_Additionals:=[Gen3R_Granite_Cave,Gen3R_Meteor_Falls,Gen3R_Safari_Zone,Gen3R_Mt_Pyre,Gen3R_Shoal_Cave,Gen3R_Seafloor_Cavern,Gen3R_Cave_of_Origin,Gen3R_Sky_Pillar,Gen3R_Victory_Road]


Extender("Gen3R")



Gen4:=["Twinleaf Town","Route 201","Lake Verity","Route 202","Route 203","Oreburgh Gate","Oreburgh City","Oreburgh Mine","Route 207","Route 204","Ravaged Path","Floaroma Meadow","Route 205","Valley Windworks","Eterna Forest","The Old Chateau","Eterna City","Route 206","Wayward Cave","Mt. Coronet","Route 208","Hearthome City","Route 209","The Lost Tower","Solaceon Ruins","Route 210","Route 215","Veilstone City","Route 212","Trophy Garden","Pastoria City","Great Marsh","Route 213","Valor Lakefront","Lake Valor","Route 214","Ruin Maniac's Cave","Ruin Maniac's Tunnel","Celestic Town","Fuego Ironworks","Routes 219","Route 220","Route 221","Route 218","Canalave City","Iron Island","Route 211","Route 216","Route 217","Acuity Lakefront","Lake Acuity","Snowpoint Temple","Route 222","Sunyshore City","Route 223","Pokemon League","Victory Road","Route 224","Route 230","Route 229","Resort Area","Route 228","Route 226","Route 227","Stark Mountain","Route 225","Sendoff Spring","Turnback Cave","Distortion World","Spear Pillar","Newmoon Island","Flower Paradise","Hall of Origin"]

;Omitted Varity Lakefront, Sandgem Town, Jubilife City, Floaroma Town, Amity Square, Solaceon Town, Pokemon Mansion, Snowpoint City, Fight Area, Battle Park, Battle Frontier, 
;Gifts: Hearthome City, Veilstone City, 
;Trade: Snowpoint City

Gen4_Oreburgh_Gate:=["Floor 1","Lower Floor 1"]
Gen4_Oreburgh_Mine:=["Floor 1","Lower Floor 1"]
Gen4_The_Old_Chateau:=["Entrance","Floor 2","Floor 2 Room 1","Floor 2 Room 2","Floor 2 Room 3","Floor 2 Room 4","Floor 2 Room 5","Floor 2 Room 6","Dining Room"]
Gen4_Wayward_Cave:=["Floor 1","Lower Floor 1"]
Gen4_Mt_Coronet:=["Floor 1","Lower Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Floor 7","Snow Area","Top","Top Cave","Iceburg Ruins"]
Gen4_The_Lost_Tower:=["Floor 1","Floor 2","Floor 3","Floor 4","Floor 5"]
Gen4_Solaceon_Ruins:=["Entrance","Entrance Side 1","Entrance Side 2","F Chamber","F Chamber Side 1","F Chamber Side 2","R Chamber","R Chamber Side 1","R Chamber Side 2","I Chamber","I Chamber Side","E Chamber","E Chamber Side 1","E Chamber Side 2","N Chamber","N Chamber Side 1","N Chamber Side 2","D Chamber","Ruin Extnesion"]
Gen4_Great_Marsh:=["Area 1","Area 2","Area 3","Area 4","Area 5","Area 6"]
Gen4_Ruin_Maniacs_Cave:=["Main Area","Expansion"]
Gen4_Iron_Island:=["Outside","Floor 1","Lower Floor 1 Left","Lower Floor 1 Right","Lower Floor 2 Left","Lower Floor 2 Right","Lower Floor 3","Iron Head Ruins"]
Gen4_Snowpoint_Temple:=["Floor 1","Lower Floor 1","Lower Floor 2","Lower Floor 3","Lower Floor 4","Lower Floor 5"]
Gen4_Route_228:=["","Rock Peak Ruins"]
Gen4_Stark_Mountain:=["Main Area","Entrance","Interior","Deepest"]
Gen4_Turnback_Cave:=["Before First Pillar","Between First and Second Pillar","Between Second and Third Pillar","Beyond Third Pillar"]

Gen4_Additionals:=[Gen4_Oreburgh_Gate,Gen4_Oreburgh_Mine,Gen4_The_Old_Chateau,Gen4_Wayward_Cave,Gen4_Mt_Coronet,Gen4_The_Lost_Tower,Gen4_Solaceon_Ruins,Gen4_Great_Marsh,Gen4_Ruin_Maniacs_Cave,Gen4_Iron_Island,Gen4_Snowpoint_Temple,Gen4_Route_228,Gen4_Stark_Mountain,Gen4_Turnback_Cave]

Extender("Gen4")



; Definitely not thorough on this one. There could be more gift mons or redone routes for this.
Gen2R:=["New Bark Town","Route 29","Cherrygrove City","Route 30","Route 31","Dark Cave","Violet City","Sprout Tower","Route 32","Ruins of Alph","Union Cave","Route 33","Azalea Town","Slowpoke Well","Ilex Forest","Route 34","Goldenrod City","Route 35","National Park","Route 36","Route 37","Ecruteak City","Burned Tower","Bell Tower","Route 38","Route 39","Olivine City","Route 40","Route 41","Whirl Islands","Cianwood City","Cliff Edge Gate","Route 47","Cliff Cave","Route 48","Safari Zone Gate","Safari Zone","Route 42","Mt. Mortar","Mahogany Town","Rocket Hideout","Route 43","Lake of Rage","Route 44","Ice Path","Blackthorn City","Dragon's Den","Route 45","Dark Cave 2","Route 46"
,"Route 27","Tohjo Falls","Route 26","Victory Road","Indigo Plateau","Vermillion City","Route 6","Saffron City","Route 5","Route 7","Route 8","Route 10","Power Plant","Rock Tunnel","Route 9","Cerulean City","Route 24","Route 25","Route 4","Route 16","Route 17","Route 18","Fuschia City","Route 15","Route 14","Route 13","Route 12","Route 11","Diglett's Cave","Route 2","Pewter City","Route 3","Mt Moon","Viridian City","Route 1","Pallet Town","Route 21","Cinnabar Island","Route 20","Route 19","Route 22","Route 28","Mt. Silver","Cerulean Cave"]

;Omitted Lighthouse, S.S. Aqua, Radio Tower, Goldenrod City Underground, Mahogany Town, Reception Gate, Route 23, Saffron City, Lavendar Town, Seafoam Islands
;Power Plant is Trade

Gen2R_Ruins_of_Alph:=["Outside","Inside"]
Gen2R_Sprout_Tower:=["Floor 2","Floor 3"]
Gen2R_Union_Cave:=["Floor 1","Lower Floor 1","Lower Floor 2"]
Gen2R_Slowpoke_Well:=["Floor 1","Lower Floor 1"]
Gen2R_Burned_Tower:=["Floor 1","Lower Floor 1"]
Gen2R_Bell_Tower:=["Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Floor 7","Floor 8","Floor 9","Floor 10","Top"]
;Gen2R_Whirl_Islands:=["Upper Left","Upper Right","Lower Left","Lower Right","Lower Floor 1","Lower Floor 1 Middle","Lower Floor 2","Lower Floor 2 Inner"]
Gen2R_Whirl_Islands:=["Floor 1","Lower Floor 1","Lower Floor 2","Lower Floor 3","Bottom"]
Gen2R_Ice_Path:=["Floor 1","Lower Floor 1","Lower Floor 2","Lower Floor 3"]
Gen2R_Victory_Road:=["Floor 1","Floor 2","Floor 3"]
Gen2R_Rock_Tunnel:=["Floor 1","Lower Floor 1"]
Gen2R_Mt_Moon:=["Floor 1","Floor 2","Outside"]
Gen2R_Mt_Silver:=["Outside","Floor 1","Floor 1 Top","Floor 2","Floor 3","Floor 4","Mountainside","Snowy Peak"]
Gen2R_Cliff_Cave:=["Floor 1","Floor 2","Lower Floor 1"] ; Have to add these 4 to additionals
Gen2R_Safari_Zone:=["Plains","Meadow","Savannah","Peak","Rocky Beach","Wetland","Forest","Swamp","Marshland","Wasteland","Mountain","Desert"]
Gen2R_Cerulean_Cave:=["Floor 1","Floor 2","Lower Floor 1"]

Gen2R_Additionals:=[Gen2R_Ruins_of_Alph,Gen2R_Sprout_Tower,Gen2R_Union_Cave,Gen2R_Slowpoke_Well,Gen2R_Burned_Tower,Gen2R_Bell_Tower,Gen2R_Whirl_Islands,Gen2R_Ice_Path,Gen2R_Victory_Road,Gen2R_Rock_Tunnel,Gen2R_Mt_Moon,Gen2R_Mt_Silver,Gen2R_Cliff_Cave,Gen2R_Safari_Zone,Gen2R_Cerulean_Cave]

Extender("Gen2R")



Gen5:=["Nuvema Town","Route 1","Accumula Town","Route 2","Striaton City","Dreamyard","Route 3","Wellspring Cave","Nacrene City","Pinwheel Forest","Castelia City","Route 4","Desert Resort","Relic Castle","Route 16","Route 5","Driftveil Drawbridge","Driftveil City","Cold Storage","Route 6","Mistralton Cave","Chargestone Cave","Route 7","Celestial Tower","Twist Mountain","Iccirus City","Dragonspiral Tower","Route 8","Moor of Icirrus","Route 9","Route 10","Victory Road","Route 11","Village Bridge","Route 12","Route 13","Undella Town","Undella Bay","Route 14","Abundant Shrine","White Forest","Route 15","Marvelous Bridge","Lostlorn Forest","Route 17","Route 18","P2 Laboratory","Liberty Garden"]

; Route 16 might require HMs to actually encounter Pokemon, making it a late game Nuzlocke Route, preceeding Route 17

; Omitted Accumula Town, Nimbasa City, Mistralton City, Abyssal Ruins, Tubeline Bridge, Opelucid City, Lacunosa Town, Black City, 
; Gifts: Nacrene City, Castelia City
; Trades: Nacrene City

Gen5_Dreamyard:=["","Basement"]
Gen5_Wellspring_Cave:=["Floor 1","Lower Floor 1"]
Gen5_Pinwheel_Forest:=["Outside","Inside","Rumination Field"]
Gen5_Desert_Resort:=["Entrance",""]
Gen5_Relic_Castle:=["Floor 1","Lower Floor 1","Lower FLoor 2","Lower Floor 3","Lower Floor 4","Lower Floor 5","Lower Floor 6","Maze","Maze End"]
Gen5_Mistralton_Cave:=["Floor 1","Floor 2","Guidance Chamber"]
Gen5_Chargestone_Cave:=["Floor 1","Lower Floor 1","Lower Floor 2"]
Gen5_Celestial_Tower:=["Floor 2","Floor 3","Floor 4","Floor 5"]
Gen5_Twist_Mountain:=["Floor 1","Floor 2","Floor 3","Lower Floor 1"] ; Serebii says there's an "Extra"
Gen5_Dragonspiral_Tower:=["Entrance","Outside","Floor 1","Floor 2","Floor 7"]
Gen5_Victory_Roadd:=["Outside","Floor 1","Floor 2","Floor 3","Floor 4","Floor 5","Floor 6","Floor 7","Trial Chamber"]

Gen5_Additionals:=[Gen5_Dreamyard,Gen5_Wellspring_Cave,Gen5_Pinwheel_Forest,Gen5_Desert_Resort,Gen5_Relic_Castle,Gen5_Mistralton_Cave,Gen5_Chargestone_Cave,Gen5_Celestial_Tower,Gen5_Twist_Mountain,Gen5_Dragonspiral_Tower,Gen5_Victory_Road]

Extender("Gen5")

Gen52:=["Aspertia City","Route 19","Floccesy Town","Route 20","Floccesy Ranch","Aspertia Gym","Virbank City","Virbank Complex","Castelia City","Castelia Sewers","Relic Passage","Route 4","Desert Resort","Relic Castle","Route 16","Lostlorn Forest","Route 5","Driftveil Drawbridge","Driftveil City","Route 6","Mistralton Cave","Chargestone Cave","Route 7","Celestial Tower","Reversal Mountain","Strange House","Undella Town","Undella Bay","Route 13","Route 12","Village Bridge","Route 11","Route 9","Seaside Cave","Route 21","Humilau City","Route 22","Giant Chasm","Route 23","Victory Road","Old Victory Road","Marvelous Bridge","Route 15","Route 14","Abundant Shrine","Moor of Icirrus","Icirrus City","Dragonspiral Tower","Twist Mountain","Clay Tunnel","Underground Ruins","Pinwheel Forest","Nacrene City","Route 3","Wellspring Cave","Striaton City","Dreamyard","Route 2","Accumula Town","Route 1","Route 17","Route 18","P2 Laboratory","Nature Preserve"]

; Omitted Skyarrow Bridge, Liberty Garden, Nimbasa City, Mistralton City, Lentimas Town, Abyssal Ruins, Tubeline Bridge, Opelucid City, Marine Tube, Lacunosa Town, Black City/White Forest, Plasma Frigate, Cave of Being, N's Castle, Nuvema Town
; Gifts: Nacrene City, Castelia City
; Trades: Accumla Town, 

Gen52_Dreamyard:=["","Basement"]
Gen52_Wellspring_Cave:=["Floor 1","Lower Floor 1"]
Gen52_Pinwheel_Forest:=["Outside","Inside"]
Gen52_Virbank_Complex:=["Outside","Inside"]
Gen52_Desert_Resort:=["Entrance",""]
Gen52_Relic_Passage:=["Room 1","Room 2","Room 3"]
Gen52_Relic_Castle:=["Floor 1","Lower Floor 1","Maze","Maze End"]
Gen52_Clay_Tunnel:=["Room 1","Room 2","Room 3"]
Gen52_Underground_Ruins:=["Entrance","Ruins","Rock Peak Chamber","Iceberg Chamber","Iron Chamber"]
Gen52_Chargestone_Cave:=["Floor 1","Lower Floor 1","Lower Floor 2"]
Gen52_Celestial_Tower:=["Floor 2","Floor 3","Floor 4","Floor 5"]
Gen52_Reversal_Mountain:=["Outside","Room 1","Room 2","Room 3","Heatran Room","Room 4","Lower Floor 1"]
Gen52_Strange_House:=["Floor 1","Lower Floor 1"]
Gen52_Twist_Mountain:=["Floor 1","Floor 2","Floor 3","Lower Floor 1","Extension"] ; Serebii says there's an "extra"
Gen52_Dragonspiral_Tower:=["Entrance","Outside","Floor 1","Floor 2","Floor 7"]
Gen52_Seaside_Cave:=["Floor 1","Lower Floor 1"]
Gen52_Giant_Chasm:=["Outside","Cave","Plains","Inner Cave","Deepest Cave"]
Gen52_Victory_Road:=["Floor 1","Outside","Forest","Cliffside","Floor 2","Floor 3","Floor 4","N's Castle Entrance"]

Gen52_Additionals:=[Gen52_Dreamyard,Gen52_Wellspring_Cave,Gen52_Pinwheel_Forest,Gen52_Virbank_Complex,Gen52_Desert_Resort,Gen52_Relic_Passage,Gen52_Relic_Castle,Gen52_Clay_Tunnel,Gen52_Underground_Ruins,Gen52_Chargestone_Cave,Gen52_Celestial_Tower,Gen52_Reversal_Mountain,Gen52_Strange_House,Gen52_Twist_Mountain,Gen52_Dragonspiral_Tower,Gen52_Seaside_Cave,Gen52_Giant_Chasm,Gen52_Victory_Road]

Extender("Gen52")



Gen6:=["Aquacorde Town","Route 2","Santalune Forest","Route 3","Route 22","Route 4","Lumiose City","Route 5","Route 6","Parfum Palace","Route 7","Battle Chateau","Connecting Cave","Route 8","Ambrette Town","Route 9","Glittering Cave","Cyllage City","Route 10","Route 11","Reflection Cave","Shalour City","Tower of Mystery","Route 12","Azure Bay","Route 13","Route 14","Laverre City","Route 15","Lost Hotel","Route 16","Frost Cavern","Route 17","Team Flare Secret HQ","Route 18","Couriway Town","Route 19","Route 20","Pokemon Village","Route 21","Victory Road","Terminus Cave","Sea Spirit's Den","Friend Safari"]

; Omitted Vaniville Town, Route 1, Santalune City, Lysandre Labs, Camphrier Town, Geosenge Town, Coumarine City, Kalos Power Plant, Poke Ball Factory, Dendemille Town, Anistar City, Snowbelle City, Kiloude City, Battle Maison
; Lumiose is a gift (second starters)
; Tower of Mystery is a Gift (Lucario)


Gen6_Glittering_Cave:=["3D Area","Floor 1"]
Gen6_Reflection_Cave:=["Floor 1","Lower Floor 1","Lower Floor 2","Lower Floor 3"]
Gen6_Frost_Cavern:=["Outside","Floor 1","Floor 2","Floor 3"]
Gen6_Pokemon_Village:=["","Unknown Dungeon"]
Gen6_Victory_Road:=["Outside","Room 1","Outside West","Room 2","Outside East","Room 3","Outside Far East","Room 4"]
Gen6_Terminus_Cave:=["Floor 1","Lower Floor 1","Floor 2 Left","Floor 2 Right","Lower Floor 2","Lower Floor 3"]

Gen6_Additionals:=[Gen6_Glittering_Cave,Gen6_Reflection_Cave,Gen6_Frost_Cavern,Gen6_Pokemon_Village,Gen6_Victory_Road,Gen6_Terminus_Cave]

Extender("Gen6")



Gen7:=["Hau'oli Outskirts","Iki Town","Route 1","Melemele Sea","Hau'oli City","Route 2","Berry Fields","Verdant Cavern","Hau'oli Cemetery","Route 3","Melemele Meadow","Seaward Cave","Kala'e Bay","Ten Carat Hill"
,"Hano Beach","Route 4","Paniola Town","Paniola Ranch","Route 5","Brooklet Hill","Route 6","Route 7","Wela Volcano Park","Route 8","Fossil Restoration Center","Lush Jungle","Diglett's Tunnel","Route 9","Konikoni City","Memorial Hill","Akala Outskirts"
,"Malie City","Malie Garden","Route 10","Mount Hokulani","Route 11","Route 12","Secluded Shore","Blush Mountain","Route 13","Haina Desert","Tapu Village","Route 15","Aether House","Route 14","Thrifty Megamart","Route 16","Ula'ula Meadow","Lake of the Moone/Sunne","Route 17","Shady House",
,"Seafolk Village","Poni Wilds","Ancient Poni Path","Poni Breaker Coast","Exeggutor Island","Vast Poni Canyon","Altar of the Moone/Sunne"
,"Mount Lanakila"
,"Poni Grove","Poni Plains","Poni Meadow","Resolution Cave","Poni Coast","Poni Gauntlet"
,"Ruins of Conflict","Ruins of Life","Ruins of Abundance","Ruins of Hope"]


;Omitted Heahea City, Royal Avenue, probably some others I didn't track, Po Town, 

;Trades are Konikoni City, Maile City

Gen7_Ten_Carat_Hill:=["Cave","Farthest Hollow","Undersea Cave"]
Gen7_Brooklet_Hill:=["","Sealevel Den"]
Gen7_Lush_Jungle:=["South","West","North","Cave"]
Gen7_Vast_Poni_Canyon:=["Entrance","Inside","Top","Floor 2","Floor 2 Deep","Floor 3","Under Tree","Lower Floor 1"]
Gen7_Mount_Lanakila:=["Mountainside","Cave","Snowcaps"]
Gen7_Resolution_Cave:=["Floor 1","Lower Floor 1"]

Gen7_Additionals:=[Gen7_Ten_Carat_Hill,Gen7_Brooklet_Hill,Gen7_Lush_Jungle,Gen7_Vast_Poni_Canyon,Gen7_Mount_Lanakila,Gen7_Resolution_Cave]

Extender("Gen7")


; This is just a way for counting how many areas are in each region/generation
; This is a troubleshooting tool to identify where there may be typos resulting in areas not loading when using the Extended sets for Floor/Area clause

For k, v in Gen1_Additionals
Gen1var+=v.length()-1
Gen1var+=Gen1.Length()

For k, v in Gen2_Additionals
Gen2var+=v.length()-1
Gen2var+=Gen2.Length()

For k, v in Gen3_Additionals
Gen3var+=v.length()-1
Gen3var+=Gen3.Length()

For k, v in Gen1R_Additionals
Gen1Rvar+=v.length()-1
Gen1Rvar+=Gen1R.Length()

For k, v in Gen4_Additionals
Gen4var+=v.length()-1
Gen4var+=Gen4.Length()

For k, v in Gen2R_Additionals
Gen2Rvar+=v.length()-1
Gen2Rvar+=Gen2R.Length()

For k, v in Gen5_Additionals
Gen5var+=v.length()-1
Gen5var+=Gen5.Length()

For k, v in Gen52_Additionals
Gen52var+=v.length()-1
Gen52var+=Gen52.Length()

For k, v in Gen6_Additionals
Gen6var+=v.length()-1
Gen6var+=Gen6.Length()

For k, v in Gen3R_Additionals
Gen3Rvar+=v.length()-1
Gen3Rvar+=Gen3R.Length()

For k, v in Gen7_Additionals
Gen7var+=v.length()-1
Gen7var+=Gen7.Length()

;MsgBox Gen1:`t%Gen1var%`nGen2:`t%Gen2var%`nGen3:`t%Gen3var%`nGen1R:`t%Gen1Rvar%`nGen4:`t%Gen4var%`nGen5:`t%Gen5var%`nGen52:`t%Gen52var%`nGen6:`t%Gen6var%`nGen3R:`t%Gen3Rvar%`nGen7:`t%Gen7var%

/*
MsgBox % "Games `t Without Clause `t With Floor/Area Clause`n"
. "RBY" "`t" Gen1.Length() "`t`t" Gen1var "`n"
. "GSC" "`t" Gen2.Length() "`t`t" Gen2var "`n" 
. "RSE" "`t" Gen3.Length() "`t`t" Gen3var "`n" 
. "FRLG" "`t" Gen1R.Length() "`t`t" Gen1Rvar "`n" 
. "DPP" "`t" Gen4.Length() "`t`t" Gen4var "`n" 
. "HGSS" "`t" Gen2R.Length() "`t`t" Gen2Rvar "`n" 
. "BW" "`t`" Gen5.Length() "`t`t" Gen5var "`n" 
. "BW2" "`t" Gen52.Length() "`t`t" Gen52var "`n" 
. "XY" "`t" Gen6.Length() "`t`t" Gen6var "`n" 
. "ORAS" "`t" Gen3R.Length() "`t`t" Gen3Rvar "`n" 
. "SM" "`t" Gen7.Length() "`t`t" Gen7var
*/

translator:={"RBY":"Gen1","GSC":"Gen2","RSE":"Gen3","FRLG":"Gen1R","DPP":"Gen4","HGSS":"Gen2R","BW":"Gen5","BW2":"Gen52","XY":"Gen6","ORAS":"Gen3R","SM":"Gen7"} ; Arrays above are prefixed by Gen__, while I decided that games would be best in the menu below. This is used for that.

Gui, Select:New
Gui, Select:Default
;Gui, Add, DropDownList, vSelectGen, Gen1|Gen2|Gen3|Gen1R|Gen4|Gen2R|Gen5|Gen52|Gen6|Gen3R|Gen7
Gui, Add, DropDownList, vSelectGen, RBY|GSC|RSE|FRLG|DPP|HGSS|BW|BW2|XY|ORAS|SM
Gui, Add, Checkbox, vExt, Floor/Area Clause?
Gui, Add, Text, section, Maximum Columns?
   stream_1:=a_loopfilefullpath ":maxi_colu"
   FileRead, maxiColu, %stream_1%
Gui, Add, Edit, x+5 w25 vMaxCol Number, % maxiColu
Gui, Add, Button, xs gSelectSubmit,&Submit
Menu, InitialMenu, Add, &Open
Menu, InitialMenu, Add, A&bout
Gui, Menu, InitialMenu
Gui, Show
return

SelectSubmit:
Gui, Select:Submit, NoHide
If !SelectGen
   {
   Loop 6
      {
       GuiControl, % Mod(A_Index,2)?"Disable":"Enable", SelectGen
       Sleep 100
	   }
   GuiControl, Focus, SelectGen
   return
   }
selection:=translator[SelectGen] . (Ext?"Ext":"") ; see the translator array a dozen or so lines up
;selection:=SelectGen (Ext?"Ext":"")


SkipSelect:
Gui, Select:Submit ; in case this originates from &Open, we'll want this GUI submitted to grab the value of MaxCol
Gui, Select:Destroy
Gui, Tracker:New
Gui, Tracker:Default
FileDelete, %stream_1%
FileAppend, % MaxCol, %stream_1% ; this updates the value for the Maximum Columns
maxGUIColumns:=MaxCol?MaxCol:Floor(WorkAreaWidth/295) ; WorkAreaWidth obtained at the top, and this determines how many columns fit on screen
r:=Ceil(%selection%.Length()/maxGUIColumns) ; This determines how many rows should be in a column
Loop % %selection%.Length()
   {
   Gui, Add, Text, % (A_Index=1?"":(Mod(A_Index,r)=1)?" Section ys x+50":" xs") " w105 r2", % %selection%[A_Index] ; This creates the names for our locations, where 
   If (CurrFile) ; CurrFile should only have a value if we are opening a file.. But it could have one if we Save, then go New... No it can't, because New Reloads and depletes all variables.
   IniRead, PriorEdit, %CurrFile%, NET, % %selection%[A_Index] ; If there was a value saved previously, it's put into variable PriorEdit. If there was not, it's made blank.
   Gui, Add, Edit, xp+105 w140 vEdit%A_Index%, % PriorEdit ; This adds the edit field next to the Text controls added at the top of the loop. The default value is in variable PriorEdit which is used for opening a file
   }
Gui, +Resize +0x300000 -SysMenu -Border ; The 0x300000 adds the horizontal and vertical scrollbars
Gui, Show, Hide , %title% ; We're doing some manipulating to see if the GUI window fits the screen or not. If it's larger than the screen, we will shrink it to be full screen.
DetectHiddenWindows, On
WinGetPos, X_Client, Y_Client, Width_Client, Height_Client, %title% ; we are capturing values for the GUI client area
;Sleep 5000
Gui, +SysMenu +Border
Menu, MyMenu, Add, &Save ; Here we start adding in all the menus. Find the associated labels below
Menu, MyMenu, Add, Save&As
Menu, MyMenu, Add, &Open
Menu, MyMenu, Add, &New
Menu, MyMenu, Add, A&bout
Gui, Menu, MyMenu

Gui, Show, Hide AutoSize, %title%
WinGetPos, X_Full, Y_Full, Width_Full, Height_Full, %title% ; we are now capturing values for the full GUI to see if it will fit on screen or not. We'll use these for expressions, but we'll use the Client as values for the GUI, Show below

; WorkAreaWidth and WorkAreaHeight are obtained at the top of script:
Gui, Show, % "x" (actualX:=(Width_Full-X_Full>WorkAreaWidth?0:X_Client)) " y" (actualY:=(Height_Full-Y_Full>WorkAreaHeight?0:Y_Client)) " w" (actualWidth:=(Width_Full>WorkAreaWidth?WorkAreaWidth-(Width_Full-Width_Client)-25:Width_Client-25)) " h" (actualHeight:=(Height_Full>WorkAreaHeight?WorkAreaHeight-(Height_Full-Height_Client)-25:Height_Client-25)) ; Minus 25 to make it fit better. I don't know why. It just is
; And if the height would normally exceed the screen, we take WorkAreaHeight and subtract the difference of the non-client areas of the GUI (Menu bar, Titlebar).
; Saves to actual_ variables just in case they're needed at some point in development.
;Listvars

If (CurrFile)  ; This is not done as an If/else against the Gui, Show above because client area shenanigans
{
IniRead, savedX, %CurrFile%, Meta, X
IniRead, savedY, %CurrFile%, Meta, Y
IniRead, savedW, %CurrFile%, Meta, W
IniRead, savedH, %CurrFile%, Meta, H
WinMove, %title%, , %savedX%, %savedY%, %savedW%, %savedH%
}
return

Save&As:
FileSelectFile, CurrFile, S,%PreviousDir%,,*.ini
If ErrorLevel
    return
GoSub IniExtCheck
IniWrite, %selection%, %CurrFile%, Meta, Generation

&Save:
If !CurrFile
   GoTo Save&As
WinGetPos, currX, currY, currW, currH, %title%
IniWrite, %version%, %CurrFile%, Meta, Version
IniWrite, %currX%, %CurrFile%, Meta, X
IniWrite, %currY%, %CurrFile%, Meta, Y
IniWrite, %currW%, %CurrFile%, Meta, W
IniWrite, %currH%, %CurrFile%, Meta, H
Gui, Tracker:Submit, NoHide
Loop % %selection%.Length()
	IniWrite, % Edit%A_Index%, %CurrFile%, NET, % %selection%[A_Index]
return

&Open:
FileSelectFile, CurrFile, 1,,,*.ini
If !CurrFile
   return
GoSub, IniExtCheck
IniRead, SectionCheck, %CurrFile%
If (SectionCheck!="Meta`nNET") 
   {
   MsgBox Unsupported or corrupt file!
   return
   }
IniRead, selection, %CurrFile%, Meta, Generation
IniRead, fileversion, %CurrFile%, Meta, Version, Unknown
If (fileversion!=version)
{
MsgBox, 49,,Caution!`n`nYou are using a new version (v%version%) of the software than the last time this file was saved (v%fileversion%). It is possible that typo corrections or other changes to location names - or any change for that matter - within the software may result in incomplete loading of your data.`n`nContinue?
IfMsgBox, OK
   {
   GoSub, SkipSelect
   return
   }
else
   return
}
GoSub, SkipSelect
return

&New:
MsgBox,3,,Would you like to save changes before closing?
IfMsgBox, No
   Reload
IfMsgBox, Yes
   {
   GoSub &Save
   Reload
   }
return

IniExtCheck:
SplitPath, CurrFile,,RecentDir,IniExt
If (IniExt="ini")
  return
else if !(IniExt)
   CurrFile:=CurrFile ".ini"
else
   MsgBox Incorrect File Extension
return

A&bout:
MsgBox Version %version%`nAuthor /u/Exaskryz
return

Extender(g) {
Global
%g%Ext:=[]
Loop, % %g%.Length()
{
t:=g "_" NameConversion(%g%[A_Index])
If IsObject(%t%)
   {
   t_Index:=A_Index
   Loop % %g%_Additionals.Length()
      {
	  If (%g%_Additionals[A_Index]=%t%)
	  Loop % %t%.Length()
	     %g%Ext.Push(%g%[t_Index] " " %t%[A_Index])
	  }
   }
else
   %g%Ext.Push(%g%[A_Index])
}
}

NameConversion(a){
StringReplace, a, a, /,,1
StringReplace, a, a, ',,1
StringReplace, a, a, .,,1
StringReplace, a, a, (,,1
StringReplace, a, a, ),,1
StringReplace, a, a, `,,,1
StringReplace, a, a, %A_Space%, _, 1
return a
}

TrackerGuiSize: ; Built-in GUI Event that is called when resizing the window
    UpdateScrollBars(A_Gui, A_GuiWidth, A_GuiHeight)
return


WheelScroll:
    ; SB_LINEDOWN=1, SB_LINEUP=0, WM_HSCROLL=0x114, WM_VSCROLL=0x115
    OnScroll(InStr(A_ThisHotkey,"Down") ? 1 : 0, 0, GetKeyState("Shift") ? 0x114 : 0x115, WinExist())
return

; http://www.autohotkey.com/board/topic/26033-scrollable-gui-proof-of-concept/#entry168174

UpdateScrollBars(GuiNum, GuiWidth, GuiHeight)
{
    static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1
    
    Gui, %GuiNum%:Default
    Gui, +LastFound
    
    ; Calculate scrolling area.
    Left := Top := 9999
    Right := Bottom := 0
    WinGet, ControlList, ControlList
    Loop, Parse, ControlList, `n
    {
        GuiControlGet, c, Pos, %A_LoopField%
        if (cX < Left)
            Left := cX
        if (cY < Top)
            Top := cY
        if (cX + cW > Right)
            Right := cX + cW
        if (cY + cH > Bottom)
            Bottom := cY + cH
    }
    Left -= 8
    Top -= 8
    Right += 8
    Bottom += 8
    ScrollWidth := Right-Left
    ScrollHeight := Bottom-Top
    
    ; Initialize SCROLLINFO.
    VarSetCapacity(si, 28, 0)
    NumPut(28, si) ; cbSize
    NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask
    
    ; Update horizontal scroll bar.
    NumPut(ScrollWidth, si, 12) ; nMax
    NumPut(GuiWidth, si, 16) ; nPage
    DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1)
    
    ; Update vertical scroll bar.
;     NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask
    NumPut(ScrollHeight, si, 12) ; nMax
    NumPut(GuiHeight, si, 16) ; nPage
    DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1)
    
    if (Left < 0 && Right < GuiWidth)
        x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left)
    if (Top < 0 && Bottom < GuiHeight)
        y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top)
    if (x || y)
        DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0)

}

OnScroll(wParam, lParam, msg, hwnd)
{
    static SIF_ALL=0x17
	SCROLL_STEP:=(msg=0x115)?32:295 ; made a change to this so horizontal scrolling is larger
    
    bar := msg=0x115 ; SB_HORZ=0, SB_VERT=1
    
    VarSetCapacity(si, 28, 0)
    NumPut(28, si) ; cbSize
    NumPut(SIF_ALL, si, 4) ; fMask
    if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si)
        return
    
    VarSetCapacity(rect, 16)
    DllCall("GetClientRect", "uint", hwnd, "uint", &rect)
    
    new_pos := NumGet(si, 20, "int") ; nPos
    
    action := wParam & 0xFFFF
    if action = 0 ; SB_LINEUP
        new_pos -= SCROLL_STEP
    else if action = 1 ; SB_LINEDOWN
        new_pos += SCROLL_STEP
    else if action = 2 ; SB_PAGEUP
        new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP
    else if action = 3 ; SB_PAGEDOWN
        new_pos += NumGet(rect, 12, "int") - SCROLL_STEP
    else if (action = 5 || action = 4) ; SB_THUMBTRACK || SB_THUMBPOSITION
        new_pos := wParam>>16
    else if action = 6 ; SB_TOP
        new_pos := NumGet(si, 8, "int") ; nMin
    else if action = 7 ; SB_BOTTOM
        new_pos := NumGet(si, 12, "int") ; nMax
    else
        return

    
    min := NumGet(si, 8, "int") ; nMin
    max := NumGet(si, 12, "int") - NumGet(si, 16, "int")  ; nMax-nPage
    new_pos := new_pos > max ? max : new_pos
    new_pos := new_pos < min ? min : new_pos
    
    old_pos := NumGet(si, 20, "int") ; nPos
    
    x := y := 0
    if bar = 0 ; SB_HORZ
        x := old_pos-new_pos
    else
        y := old_pos-new_pos
    ; Scroll contents of window and invalidate uncovered area.
    DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0)
    
    ; Update scroll bar.
    NumPut(new_pos, si, 20, "int") ; nPos
    DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1)
}

GuiClose:
TrackerGuiClose:
SelectGuiClose:
ExitApp
sqlcode
Posts: 27
Joined: 02 Nov 2017, 08:55

Re: GUI Scroll

04 Mar 2018, 23:31

Thank you. This is really helpful.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], yarsis and 190 guests