Dropdown Issues

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Dropdown Issues

09 Dec 2020, 02:19

Hey all, blessings....

I am working on a bible program now, and I have the dropdown listing the books of the bible. Then I have the chapters that are supposed to show based on what book is chosen in the dropdown. Problem is, is it always shows the first chapter no matter what I choose. Like Genesis has 50 chapters, and Exodus has 22 I think.... Anyway, no matter which one I choose, it keeps the 50 chapters and doesn't switch. I have brainfried myself, so decided to ask for help. Thank you.

Code: Select all

; ************ READ TEXT FILE TO DETERMINE WHAT BIBLE TO LOAD AT START***************
IniRead, keyFilename, settings.txt, ActiveBook, Filename, %A_Space%
If !(keyFilename) {
	IniWrite, 1-Genesis,  settings.txt, ActiveBook, filename
	keyFilename :=	"Bible"
}
global iniPath := keyFilename . ".ini"
global DestFolder := A_ScriptDir

Gui, add, Text, x10 y4, Chapter
Gui, add, ListView, vchapter NoSortHdr -Hdr AltSubmit hwndhchapter x10 y30 w100 h450, |

Gui, add, Text, x100 y4, Verses
Gui, add, ListView, vListChapVs NoSortHdr -Hdr AltSubmit hwndhverses gListChapVs x130 y30 w550 h450, |

Gui, Show,  w700 h500, %Title% - %Version%

DefaultValue := 1
loop, Files, Books\*.ini
{
	SplitPath, A_LoopFileName,,,, FileName
	List .= FileName "|"
	If (A_LoopFileName = iniPath)
		DefaultValue := A_Index
}
List := RTrim(List, "|")
; List := StrReplace(List, "|", "||",, 1) ;default item
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************
Gui, Add, DropDownList, x2 y5 w132 vmyDropDownList gPresetChange hwndhcbx choose%DefaultValue%, % List
PostMessage, 0x153, -1, 17,, ahk_id %hcbx%; Set height of selection field.
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************

ListChapVs:

if (myDropDownList = 1-Genesis) {
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, chapter
	Loop, Read, Chapters\GenesisChapters.txt
	LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, ListChapVs
	Loop, Read, Verses\GenChap1.txt
	LV_Add("",A_LoopReadLine)
	Return
}

if (myDropDownList = 2-Exodus) {
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, chapter
	Loop, Read, Chapters\ExodusChapters.txt
	LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, ListChapVs
	Loop, Read, Verses\ExoChap1.txt
	LV_Add("",A_LoopReadLine)
	Return	
}

PresetChange:
Gui, Submit, NoHide
text :=	myDropDownList
GuiControl, +AltSubmit, myDropDownList
Gui, Submit, NoHide
GuiControl, -AltSubmit, myDropDownList
CurrentFileName = % text
IniWrite, % text, settings.txt, ActiveBook, Filename
Gui, Submit, NoHide
Reload
return


GuiEscape:
GuiClose:
GuiClose2:
ExitApp
Ps... also when I click on the scripture verses, it just flashes and adds all the verses again at the bottom. I thought using the LV_Delete() would help that but it doesn't work.

Blessings
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Dropdown Issues

09 Dec 2020, 05:11

I think I got it covered. Using LVDelete() is the solution I used too. Let me know if this works for you. I changed some paths for testing but I belive I changed them back to your original values.

For detailed infomation see my comments starting with 'Dya:'.

Code: Select all

; ************ READ TEXT FILE TO DETERMINE WHAT BIBLE TO LOAD AT START***************
IniRead, keyFilename, settings.txt, ActiveBook, Filename, %A_Space%
If !(keyFilename) {
	IniWrite, 1-Genesis,  settings.txt, ActiveBook, filename
	keyFilename :=	"Bible"
}
global iniPath := keyFilename . ".ini"
global DestFolder := A_ScriptDir

Gui, add, Text, x12 y35, Chapter
Gui, add, ListView, vchapter NoSortHdr -Hdr AltSubmit hwndhchapter x10 y50 w100 h450, |

Gui, add, Text, x132 y35, Verses
Gui, add, ListView, vListChapVs NoSortHdr -Hdr AltSubmit hwndhverses gListChapVs x130 y50 w550 h450, |

Gui, Show,  w700 h530, %Title% - %Version%

; Dya: Why don't put this on top of the first GUI comman? The DropDownList is the topmost GUI element.
DefaultValue := 1
loop, Files, Books\*.ini
{
	SplitPath, A_LoopFileName,,,, FileName
	List .= FileName "|"
	If (A_LoopFileName = iniPath)
		DefaultValue := A_Index
}
List := RTrim(List, "|")
; List := StrReplace(List, "|", "||",, 1) ;default item
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************
Gui, Add, DropDownList, x10 y10 w132 vmyDropDownList gPresetChange hwndhcbx choose%DefaultValue%, % List
;PostMessage, 0x153, -1, 17,, ahk_id %hcbx%; Set height of selection field.	
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************

ListChapVs:
GUI, Submit, NoHide	; Dya: Write the initial book choice to myDropDownList.

if (myDropDownList = "Genesis") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\GenesisChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\GenChap1.txt
		LV_Add("",A_LoopReadLine)
	Return
}

if (myDropDownList = "Exodus") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\ExodusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\ExoChap1.txt
		LV_Add("",A_LoopReadLine)
	Return	
}
Return

PresetChange:
Gui, Submit, NoHide
text :=	myDropDownList
GuiControl, +AltSubmit, myDropDownList
Gui, Submit, NoHide
GuiControl, -AltSubmit, myDropDownList
CurrentFileName = % text
IniWrite, % text, settings.txt, ActiveBook, Filename
;Gui, Submit, NoHide	; Dya: What purpose does this serve? Nothing changed in the GUI, didn't it?
;Reload	; Dya: This restarts the program and thus flashes the gui.
GoSub, ListChapVs	; Dya: Go and update the contents of the ListViews.
Return


GuiEscape:
GuiClose:
GuiClose2:
ExitApp
Let me know where you need more help.
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 05:26

@DyaTactic

Hey, thanks for the response. I was coming back just this second to say that I just added the chapters into the ini file to match the books, and then called them when the dropdown chooses the book.

Now I have to check the other things, as I should be able to do the chapters the same way in the ini file... when clicking the one listview, however, it keeps posting all the scriptures over and over and over when I hit anywhere in the listview. Maybe the lvl_delete() issue again. I'll take a look at your reply. Thx
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 05:32

DyaTactic wrote:
09 Dec 2020, 05:11
I think I got it covered. Using LVDelete() is the solution I used too. Let me know if this works for you. I changed some paths for testing but I belive I changed them back to your original values.

For detailed infomation see my comments starting with 'Dya:'.

Code: Select all

; ************ READ TEXT FILE TO DETERMINE WHAT BIBLE TO LOAD AT START***************
IniRead, keyFilename, settings.txt, ActiveBook, Filename, %A_Space%
If !(keyFilename) {
	IniWrite, 1-Genesis,  settings.txt, ActiveBook, filename
	keyFilename :=	"Bible"
}
global iniPath := keyFilename . ".ini"
global DestFolder := A_ScriptDir

Gui, add, Text, x12 y35, Chapter
Gui, add, ListView, vchapter NoSortHdr -Hdr AltSubmit hwndhchapter x10 y50 w100 h450, |

Gui, add, Text, x132 y35, Verses
Gui, add, ListView, vListChapVs NoSortHdr -Hdr AltSubmit hwndhverses gListChapVs x130 y50 w550 h450, |

Gui, Show,  w700 h530, %Title% - %Version%

; Dya: Why don't put this on top of the first GUI comman? The DropDownList is the topmost GUI element.
DefaultValue := 1
loop, Files, Books\*.ini
{
	SplitPath, A_LoopFileName,,,, FileName
	List .= FileName "|"
	If (A_LoopFileName = iniPath)
		DefaultValue := A_Index
}
List := RTrim(List, "|")
; List := StrReplace(List, "|", "||",, 1) ;default item
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************
Gui, Add, DropDownList, x10 y10 w132 vmyDropDownList gPresetChange hwndhcbx choose%DefaultValue%, % List
;PostMessage, 0x153, -1, 17,, ahk_id %hcbx%; Set height of selection field.	
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************

ListChapVs:
GUI, Submit, NoHide	; Dya: Write the initial book choice to myDropDownList.

if (myDropDownList = "Genesis") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\GenesisChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\GenChap1.txt
		LV_Add("",A_LoopReadLine)
	Return
}

if (myDropDownList = "Exodus") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\ExodusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\ExoChap1.txt
		LV_Add("",A_LoopReadLine)
	Return	
}
Return

PresetChange:
Gui, Submit, NoHide
text :=	myDropDownList
GuiControl, +AltSubmit, myDropDownList
Gui, Submit, NoHide
GuiControl, -AltSubmit, myDropDownList
CurrentFileName = % text
IniWrite, % text, settings.txt, ActiveBook, Filename
;Gui, Submit, NoHide	; Dya: What purpose does this serve? Nothing changed in the GUI, didn't it?
;Reload	; Dya: This restarts the program and thus flashes the gui.
GoSub, ListChapVs	; Dya: Go and update the contents of the ListViews.
Return


GuiEscape:
GuiClose:
GuiClose2:
ExitApp
Let me know where you need more help.
Okay, the chapters and the verses are showing up.... I added the lvl_Deletes to where you have them added, it does stop the creating of duplicates but it won't let me select the verses individually. Here is my new code:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

Code: Select all

; ************ READ TEXT FILE TO DETERMINE WHAT PLAYLIST TO LOAD AT START***************
IniRead, keyFilename, settings.txt, ActiveBook, Filename, %A_Space%
If !(keyFilename) {
	IniWrite, 1-Genesis,  settings.txt, ActiveBook, filename
	keyFilename :=	1-Genesis
}
global iniPath := keyFilename . ".ini"
global DestFolder := A_ScriptDir

Gui, add, Text, x10 y4, Chapter
Gui, add, ListView, vchapter NoSortHdr -Hdr AltSubmit hwndhchapter x10 y30 w100 h450, |

Gui, add, Text, x100 y4, Verses
Gui, add, ListView, vListChapVs NoSortHdr -Hdr AltSubmit hwndhverses gListChapVs x130 y30 w550 h450, |

Gui, Show,  w700 h500, %Title% - %Version%

DefaultValue := 1
loop, Files, Books\*.ini
{
	SplitPath, A_LoopFileName,,,, FileName
	List .= FileName "|"
	If (A_LoopFileName = iniPath)
		DefaultValue := A_Index
}
List := RTrim(List, "|")

IniWrite, % DefaultValue, settings.txt, ActiveChapters, Chapters



; List := StrReplace(List, "|", "||",, 1) ;default item
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************
Gui, Add, DropDownList,  x2 y5 w150 vmyDropDownList gPresetChange hwndhcbx choose%DefaultValue%, % List
PostMessage, 0x153, -1, 20,, ahk_id %hcbx%; Set height of selection field.
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************

ListChapVs:
IniRead, Chapter, settings.txt, ActiveChapters, Chapters

if (myDropDownList = 1-Genesis AND Chapter = 1) {
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, chapter
	LV_Delete()
	Loop, Read, Chapters\GenesisChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, ListChapVs
	LV_Delete()
	Loop, Read, Verses\GenChap1.txt
		LV_Add("",A_LoopReadLine)
	Return
}

if (myDropDownList = 2-Exodus AND Chapter = 8) {
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, chapter
	LV_Delete()
	Loop, Read, Chapters\ExodusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, ListChapVs
	LV_Delete()
	Loop, Read, Verses\ExoChap1.txt
		LV_Add("",A_LoopReadLine)
	Return	
}


if (myDropDownList = 3-Leviticus AND Chapter = 9) {
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, chapter
	LV_Delete()
	Loop, Read, Chapters\LeviticusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	Gui, ListView, ListChapVs
	LV_Delete()
	Loop, Read, Verses\LevChap1.txt
		LV_Add("",A_LoopReadLine)
	Return	
}

PresetChange:
Gui, Submit, NoHide
text :=	myDropDownList
GuiControl, +AltSubmit, myDropDownList
Gui, Submit, NoHide
GuiControl, -AltSubmit, myDropDownList
CurrentFileName = % text
IniWrite, % text, settings.txt, ActiveBook, Filename
Gui, Submit, NoHide
GoSub, ListChapVs	; Dya: Go and update the contents of the ListViews.
return

GuiEscape:
GuiClose:
GuiClose2:
ExitApp
EDITED:
Hm.. in order to get the chapters and verses from the dropdown, I still have to reload to so do... That is the only way I know of writing it to work.
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Dropdown Issues

09 Dec 2020, 05:55

I edited more then only the LVDelted() lines. Can you try to use whole the code I send back? I belive most of it is fixed there already. Let me know.
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 06:09

DyaTactic wrote:
09 Dec 2020, 05:55
I edited more then only the LVDelted() lines. Can you try to use whole the code I send back? I belive most of it is fixed there already. Let me know.
Okay, I see that those changes did help. TYTY... Strange however that when I msgbox the scripoture I click on, it will put it into the clipboard and allow me to paste it... if I remove the msgbox, it no longer holds the scripture. The scriptures don't stay highlighted and it flashes. NOt sure why, as I've done it this way in other projects and was ok. But thank you very much, as your code was great. I have included the updated script where I try and click the scripture link and paste it. I"m almost there.. TYTY

Code: Select all

; ************ READ TEXT FILE TO DETERMINE WHAT BIBLE TO LOAD AT START***************
IniRead, keyFilename, settings.txt, ActiveBook, Filename, %A_Space%
If !(keyFilename) {
	IniWrite, 1-Genesis,  settings.txt, ActiveBook, filename
	keyFilename :=	"Bible"
}
global iniPath := keyFilename . ".ini"
global DestFolder := A_ScriptDir

Gui, add, Text, x12 y35, Chapter
Gui, add, ListView, vchapter NoSortHdr -Hdr AltSubmit hwndhchapter x10 y50 w100 h450, |

Gui, add, Text, x132 y35, Verses
Gui, add, ListView, vListChapVs NoSortHdr -Hdr AltSubmit hwndhverses gListChapVs x130 y50 w550 h450, |

Gui, Show,  w700 h530, %Title% - %Version%

; Dya: Why don't put this on top of the first GUI comman? The DropDownList is the topmost GUI element.
DefaultValue := 1
loop, Files, Books\*.ini
{
	SplitPath, A_LoopFileName,,,, FileName
	List .= FileName "|"
	If (A_LoopFileName = iniPath)
		DefaultValue := A_Index
}
List := RTrim(List, "|")
IniWrite, % DefaultValue, settings.txt, ActiveChapters, Chapters

; List := StrReplace(List, "|", "||",, 1) ;default item
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************
Gui, Add, DropDownList, x10 y10 w132 vmyDropDownList gPresetChange hwndhcbx choose%DefaultValue%, % List
;PostMessage, 0x153, -1, 17,, ahk_id %hcbx%; Set height of selection field.	
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************

ListChapVs:
GUI, Submit, NoHide	; Dya: Write the initial book choice to myDropDownList.

IniRead, Chapter, settings.txt, ActiveChapters, Chapters

if (myDropDownList = "1-Genesis") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\GenesisChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\GenChap1.txt
		LV_Add("",A_LoopReadLine)
	
	
		
	Fileread,section, Verses\GenChap1.txt
	var = %section%
	array := strsplit(var, "`n")
	file = Verses\GenChap1.txt
	
	Gui, ListView, scripture
	
	FileReadLine, line, %file%, lineNum := A_Index + 0
	
	line := % array[A_EventInfo] 
	clipboard = %line%	
	
	Gui, ListView, scripture
	
	
	Return
}

if (myDropDownList = "2-Exodus") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\ExodusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\ExoChap1.txt
		LV_Add("",A_LoopReadLine)
	Return	
}
Return

PresetChange:
Gui, Submit, NoHide
text :=	myDropDownList
GuiControl, +AltSubmit, myDropDownList
Gui, Submit, NoHide
GuiControl, -AltSubmit, myDropDownList
CurrentFileName = % text
IniWrite, % text, settings.txt, ActiveBook, Filename
;Gui, Submit, NoHide	; Dya: What purpose does this serve? Nothing changed in the GUI, didn't it?
;Reload	; Dya: This restarts the program and thus flashes the gui.
GoSub, ListChapVs	; Dya: Go and update the contents of the ListViews.
Return


GuiEscape:
GuiClose:
GuiClose2:
ExitApp
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 06:55

Well, looks like I might not be able to do this way either. Tried without a dropdown but the there's not eventinfo to click on different chapters apparently. grrrr Thank for your help. I need to figure another way to do this. Blessings.
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 07:26

Hmmm a bit further than I was before.... I can manually put the scriptures to show them individually but have to use an A_EventInfo for each one... (Sigh) lol. I"m still learning however. Below is for chapter 2 of Exodus as an example.

Code: Select all

if (myDropDownList = "2-Exodus") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\ExodusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\ExoChap1.txt
		LV_Add("",A_LoopReadLine)
	
	if (A_EventInfo = 1) {
		
		Fileread,section, Verses\ExoChap1.txt
		var = %section%
		array := strsplit(var, "`n")
		file = Verses\ExoChap1.txt
				
		FileReadLine, line, %file%, lineNum := A_Index + 0
		
		line := % array[A_EventInfo] 
		clipboard = %line%	
		MsgBox %Clipboard%
	}
	Return
}
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 07:50

Okay, I have it figured out but still not perfect.. it won't keep the verses selected but it will put them in the clipboard individually as I click on them. Much further than I was. Thank you again! now I gotta figure out how to change chapters. I"m not sure what the chapters controls are since they are pulled from the dropdown list from files in a folder. :crazy: :crazy:

Blessings!
User avatar
Epialis
Posts: 858
Joined: 02 Aug 2020, 22:44

Re: Dropdown Issues

09 Dec 2020, 08:42

Okay, maybe someone will cross this post and help me figure out what the chapters controls are. The dropdown looks into the books folder and grabs all the files there. All the books of the Bible are in there. Then you pick a book and it displays all the chapters on the left. I don't know what the drop down controls are, as all the eventinfo's have nothing to do with them as far as I'm aware. So if I use the dropdown to choose Genesis, it shows all the chapters from a file to the left. But don't know the populated dropdown controls are, so I don't know how to call them in order to use them. This is what I have.

Code: Select all

; ************ READ TEXT FILE TO DETERMINE WHAT BIBLE TO LOAD AT START***************
IniRead, keyFilename, settings.txt, ActiveBook, Filename, %A_Space%
If !(keyFilename) {
	IniWrite, 1-Genesis,  settings.txt, ActiveBook, filename
	keyFilename :=	"Bible"
}
global iniPath := keyFilename . ".ini"
global DestFolder := A_ScriptDir

Gui, add, Text, x12 y35, Chapter
Gui, add, ListView, vchapter NoSortHdr -Hdr AltSubmit hwndhchapter x10 y50 w100 h450, |

Gui, add, Text, x132 y35, Verses
Gui, add, ListView, vListChapVs NoSortHdr -Hdr AltSubmit hwndhverses gListChapVs x130 y50 w550 h450, |

Gui, Show,  w700 h530, %Title% - %Version%



; Dya: Why don't put this on top of the first GUI comman? The DropDownList is the topmost GUI element.
DefaultValue := 1
loop, Files, Books\*.ini
{
	SplitPath, A_LoopFileName,,,, FileName
	List .= FileName "|"
	If (A_LoopFileName = iniPath)
		DefaultValue := A_Index
}
List := RTrim(List, "|")
IniWrite, % DefaultValue, settings.txt, ActiveChapters, Chapters

; List := StrReplace(List, "|", "||",, 1) ;default item
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************
Gui, Add, DropDownList, x10 y10 w132 vmyDropDownList gPresetChange hwndhcbx choose%DefaultValue%, % List
;PostMessage, 0x153, -1, 17,, ahk_id %hcbx%; Set height of selection field.	
; ******************************* SET THE SIZE IN HEIGHT OF THE DROPDOWN MENU **********************************************


ListChapVs:
GUI, Submit, NoHide	; Dya: Write the initial book choice to myDropDownList.

IniRead, Chapters, settings.txt, ActiveChapters, Chapters

if (myDropDownList = "1-Genesis") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\GenesisChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\GenChap1.txt
		LV_Add("",A_LoopReadLine)

	Fileread,section, Verses\GenChap1.txt
	
	var = %section%
	array := strsplit(var, "`n")
	if (A_GuiEvent <> Normal)
	{
		file = Verses\GenChap1.txt
		
		FileReadLine, line, %file%, lineNum := A_Index
		
		line := % array[A_EventInfo] 
		clipboard = %line%	
		
	}
	IfWinActive, ahk_class AutoHotkeyGUI 
		
	;ahk_class OpusApp
	;ahk_class DlgGroupChat Window Class
	{	
		clipboard = %line%	
		
		SendEvent {Click 1}
		
		SendEvent ^c
	} 
	winactivate, ahk_class DlgGroupChat Window Class
	{			
		
		SendEvent ^v
		SendEvent {Enter}
	}	
	return
}

if (myDropDownList = "2-Exodus") {
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, chapter
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Chapters\ExodusChapters.txt
		LV_Add("",A_LoopReadLine)
	LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
	LV_ModifyCol(1, "AutoHdr")
	
	Gui, ListView, ListChapVs
	LV_Delete()	; Dya: Empty the ListView.
	Loop, Read, Verses\ExoChap1.txt
		LV_Add("",A_LoopReadLine)
	
	Fileread,section, Verses\ExoChap1.txt
	
	var = %section%
	array := strsplit(var, "`n")
	if (A_GuiEvent <> Normal)
	{
		file = Verses\ExoChap1.txt
		
		FileReadLine, line, %file%, lineNum := A_Index
		
		line := % array[A_EventInfo] 
		clipboard = %line%	
	}
	IfWinActive, ahk_class AutoHotkeyGUI 
		
	;ahk_class OpusApp
	;ahk_class DlgGroupChat Window Class
	{	
		clipboard = %line%	
		
		SendEvent {Click 1}
		
		SendEvent ^c
	} 
	winactivate, ahk_class DlgGroupChat Window Class
	{			
		
		SendEvent ^v
		SendEvent {Enter}
	}	
	return
}
		
		if (myDropDownList = "3-Leviticus") {
			LV_ModifyCol(1, "AutoHdr")
			MsgBox %A_Index%
			
			Gui, ListView, chapter
			LV_Delete()	; Dya: Empty the ListView.
			Loop, Read, Chapters\LeviticusChapters.txt
				LV_Add("",A_LoopReadLine)
			LV_ModifyCol(1, LV_GetCount()>10 ? 79:96)
			LV_ModifyCol(1, "AutoHdr")	
			Gui, ListView, ListChapVs
			LV_Delete()	; Dya: Empty the ListView.
			Loop, Read, Verses\LevChap1.txt
				LV_Add("",A_LoopReadLine)
			
			Return
		}
		
		
		PresetChange:
		Gui, Submit, NoHide
		text :=	myDropDownList
		GuiControl, +AltSubmit, myDropDownList
		Gui, Submit, NoHide
		GuiControl, -AltSubmit, myDropDownList
		CurrentFileName = % text
		IniWrite, % text, settings.txt, ActiveBook, Filename
;Gui, Submit, NoHide	; Dya: What purpose does this serve? Nothing changed in the GUI, didn't it?
		;Reload	; Dya: This restarts the program and thus flashes the gui.
GoSub, ListChapVs	; Dya: Go and update the contents of the ListViews.
		Return
GuiEscape:
GuiClose:
GuiClose2:
ExitApp
capture14.jpg
capture14.jpg (117.69 KiB) Viewed 300 times
See how chapter 6 is highlighted? but shows chapter one? :crazy: :crazy:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], emp00, Google [Bot], tranht17 and 195 guests