Page 2 of 2

Re: Url to Button

Posted: 09 Sep 2020, 06:25
by Epialis
@DyaTactic

I'm so amazed at some of you guys lol! You all are years advanced and I thank you tremendously. I have noticed that when I do add the programs, that you can click on ANY of the empty rows and it will run the program. Not sure what is causing that... I'm lookin into it now, as well as the program name not being separate from the icon file. Feel free to just lead me to the thread or website. You made my day though lol.. tytytyty

Re: Url to Button

Posted: 09 Sep 2020, 11:36
by Epialis
Something odd going on here lol.. When I reload the program over and over, well, as you see.. it keeps shrinking every time I load it. :headwall: :headwall:

Re: Url to Button

Posted: 09 Sep 2020, 19:33
by Epialis
Just wanted to give an update on my program. This is how it's working thus far. I might try to make a section below it for Windows Commands and have it under a new heading. So all window commands would be in one area, while programs in another. It's a work in progress. Thank you all for help. I will keep this thread going with updates and ask for help when I need it. Thanks to all who have participated; I am honored. Is there a way to remove the highlight though? Bandicam turns white, and it looks awful lol

Re: Url to Button

Posted: 10 Sep 2020, 00:07
by Epialis
Okay... I have worked with this code to try and sort my rows in order to search. Basically I"m trying to keep the same GUI and listview and just find the search and have them populate in the same listview. Is this possible? I know C+ is possible to hid all the programs and icons and just put your searches in the same listview. Any thoughts?

Code: Select all

Gui, Font,S10 bold cred, Verdana 
Gui, Add, Edit, x100 y785 w316 xm vKeyword HWNDhEdit gSearchLV  hwndThree
SetEditCueBanner(Three, "Program Search")

ImportFile:
FileName := "MovieList.txt"
Return
SearchLV:
GuiControlGet, Keyword

GuiControl, -Redraw, %hLV%

for i, arrRow in FileName
{
		for i, v in arrRow
		{
			if InStr(v, Keyword)
			{
				LV_Add("", arrRow*)
				Break
			}
		}
	}

	GuiControl, +Redraw, %hLV%

Edit_SetCueBanner(HWND, Cue) {
	Static EM_SETCUEBANNER := (0x1500 + 1)
	Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)
}

Re: Url to Button

Posted: 10 Sep 2020, 02:47
by DyaTactic
Epialis wrote:
09 Sep 2020, 19:33
Is there a way to remove the highlight though?
You can use +LV0x8000 in the ListView options (when you add it to the GUI) to prevent the icon from being heighlighted. And with -0x8 in the options the selection is no longer visible after the ListView loses keyboard focus.
In my example below I also added -Hdr, I thought you might like it since you only have one column maybe you like the header being hidden too.

Code: Select all

Gui, Add, ListView, xm r20 w700 Grid sort -ReadOnly  +hscroll +BackgroundTrans Color cAqua vMyListView gListViewHandler -Hdr -0x8 +LV0x8000, Name | FilePath | IcoPath	;0x4000=Column header, 0x8=Selection visible when deactive, LV0x8000=Border heighlight instead of fill.

Re: Url to Button

Posted: 10 Sep 2020, 23:40
by Epialis
DyaTactic wrote:
10 Sep 2020, 02:47
Epialis wrote:
09 Sep 2020, 19:33
Is there a way to remove the highlight though?
You can use +LV0x8000 in the ListView options (when you add it to the GUI) to prevent the icon from being heighlighted. And with -0x8 in the options the selection is no longer visible after the ListView loses keyboard focus.
In my example below I also added -Hdr, I thought you might like it since you only have one column maybe you like the header being hidden too.

Code: Select all

Gui, Add, ListView, xm r20 w700 Grid sort -ReadOnly  +hscroll +BackgroundTrans Color cAqua vMyListView gListViewHandler -Hdr -0x8 +LV0x8000, Name | FilePath | IcoPath	;0x4000=Column header, 0x8=Selection visible when deactive, LV0x8000=Border heighlight instead of fill.
Thanks, works better. :)

Re: Url to Button

Posted: 11 Sep 2020, 02:17
by DyaTactic
Good to hear that.
The question about the search function is still open. I do not know about such a function to hide rows or something. Maybe someone else or Google knows some DLLCall() that's does the trick?

Re: Url to Button

Posted: 11 Sep 2020, 02:18
by Epialis
DyaTactic wrote:
11 Sep 2020, 02:17
Good to hear that.
The question about the search function is still open. I do not know about such a function to hide rows or something. Maybe someone else or Google knows some DLLCall() that's does the trick?
yeah, I"m still working on a search feature. It's difficult for me, as I have to have the search field show the search in the same listview. I have it where I can search the text file that holds the information, but that won't do, as I need the search to search the program and run it. Using another listview for the search is not feasible with what I 'm wanting. I'll get there... thank you.

Re: Url to Button

Posted: 11 Sep 2020, 18:42
by Epialis
Okay... why this error? I have the file that is mentioned in the same directory as the include. No reason why it shouldn't work?

Not sure what code to give.

Re: Url to Button

Posted: 11 Sep 2020, 19:03
by Epialis
DyaTactic wrote:
09 Sep 2020, 05:31
I choose a program that I want to add to the listview, then I choose the icon for that program, then I click the add button to show the icon and the program in the listview.
Alright, so you kinde use the buttons from right to left^^. My intuition wanted to use them from left to right, so first the Add button and then the rest. It works now how you said.
About the Icons. I made it ignore the ChooseIcon button when no rows were selected. Fixed it now. I also hid the 2nd and the 3rd column.

Let me know what you think.

Code: Select all

SendMode Input  																	; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  														; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance,Force
#Include LV_EX.ahk

Gui, Add, Button, hidden x5 y5 gExecute, Execute
gui, Color, c000000 RGB ; Background of the GUI, not the ListView
Gui +AlwaysOnTop +resize
Gui, Font,S10, Verdana ; Font Size of Fields
Gui, Show, x100 y100 w500 h500


Gui, Add, ListView, xm r20 w700 Grid sort -ReadOnly  +hscroll +BackgroundTrans Color cAqua vMyListView gListViewHandler, Name | FilePath | IcoPath

gui, Color,, 0xEAFAF1
Gui, Font,S10 bold cblack, Verdana 
Gui, Add, Edit, x100 y5 w200 ys vProgram hwndOne
SetEditCueBanner(One, "Program Name")

Gui, Font,S10 bold cred, Verdana 
Gui, Add, Edit, x100 y475 w600 xm vSearch gSearch hwndThree
SetEditCueBanner(Three, "Program Search")

Gui, Add, Button, x600 y5 gAddItem,% "Add"

Gui, Add, Button, x650 y5  gAddexe,% "File Location"

Gui, Add, Button, x757 y5 gAddicon,% "Choose Icon"


OnExit, UpdateFile
SelectedRow := 0


IconWidth    := 50
IconHeight   := 50
IconBitDepth := 24
InitialCount :=  1	; The starting Number of Icons available in ImageList
ImageListID := DllCall( "ImageList_Create", Int,IconWidth,    Int,IconHeight
                                          , Int,IconBitDepth, Int,InitialCount
                                          , Int,GrowCount )
LV_SetImageList( ImageListID, 1 )	; 0 for large icons, 1 for small icons



If FileExist("MovieList.txt") {														; Add data from MovieList.txt to ListView
	;FileCopy, MovieList.txt, MovieList%A_Now%.txt									;incremental backup
	
	Loop, Read, MovieList.txt
	{
		If (A_index = 1 && SubStr(A_LoopReadLine, 1, 1) = "x")	{
			WinPos := A_LoopReadLine
			Continue
		}
		Else 
		{
			Loop, Parse, A_LoopReadLine , CSV
				RowData%A_Index% := A_LoopField
			NewIcon := IL_Add(ImageListID, RowData3)
			LV_Add("Icon" . NewIcon, RowData1,RowData2,RowData3)
			
		}
	}
}

SizeCols()

Menu, MyContextMenu, Add, Edit, EditItem
Menu, MyContextMenu, Add, Delete, DeleteItem
Menu, Tray, Add, Show MovieList, ShowMovieList

If FileExist("MovieList.txt") {
    Gui, Show, %WinPos% , MovieList
}
Else
{
    WinGetPos,X1,Y1,W1,H1,Program Manager
    X2 := W1-800
    Gui, Show, x%x2% y50 , MovieList
}

Hotkey, ^!a, ShowMovieList
Return

ShowMovieList:
	Gui, Show,, MovieList
	Return

MyListView:
	If (A_GuiEvent = e)																;Finished editing first field of a row
		LV_ModifyCol(2,"Sort")
	If (A_GuiEvent = ColClick)														;Clicked column header
	{
	If A_EventInfo = 2    ;Number of column header clicked
		LV_ModifyCol(2,"SortDesc")
	}
	UpdateFile()
	Return

GuiContextMenu:																		; Launched in response to a right-click or press of the Apps key.
	If A_GuiControl <> MyListView  													; Display the menu only for clicks inside the ListView.
		Return
	LV_GetText(ColText, A_EventInfo,1)    											;Gather column data in string EditText
	EditText := ColText
	Loop 3
	{
		LV_GetText(ColText, A_EventInfo, A_Index+1)
		EditText := EditText . "|" . ColText
	}
	Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
	Return

EditItem:          																	;Move row from ListView columns into edit fields
	SelectedRow := LV_GetNext()
	StringSplit, RowData, EditText , |
	Loop, 9
		{
			GuiControl, , Rowdata%A_Index%
		}
	GuiControl, ,Button1, Update
	Return

DeleteItem:         																;Deletes selected rows
	MsgBox, 4100, Delete Program?, Delete Program? Click Yes or No?
	IfMsgBox No    																	;Don't delete
		Return
	RowNumber = 0  																	; This causes the first iteration to start the search at the top.
	Loop																			; Since deleting a row reduces the RowNumber of all other rows beneath it,
	{																			; subtract 1 so that the search includes the same row number that was previously
		RowNumber := LV_GetNext(RowNumber - 1)										; found (in case adjacent rows are selected):
		If not RowNumber  															; The above returned zero, so there are no more selected rows.
			Break
		LV_Delete(RowNumber)  														; Clear the row from the ListView.
	}
	UpdateFile()
	Return

AddItem:                 ;Add new or update ListView row
	Gui, Submit, NoHide
	
	If !NewIcon {
		NewIcon := IL_Add( ImageListID, Runexe )	; Create a new entry in the imagelist for this program.
		IconFile := Runexe
		NewIconIndex := 0	; The fist icon in the resource.
	}
	
	SelectedRow := LV_GetNext()
	If (SelectedRow = 0) {
		
		LV_Add("Icon" . NewIcon, Trim(Program),Trim(Runexe), Trim(IconFile))

	} Else {
		
		LV_Modify(SelectedRow,"Icon" . NewIcon, Program, IconFile)
		
		LV_ModifyCol(1,"Sort")
		SelectedRow := 0
		
		GuiControl, ,Button1, Add to list
		GuiControl,,edit, ;this would remove the text from Edit1 control
		
	}
Return


UpdateFile:																			;When exiting
	DetectHiddenWindows On
	UpdateFile()
	ExitApp
	Return

GuiSize:  																			; Widen or narrow the ListView in response to the user's resizing of the window.
	If (A_EventInfo = 1)  															; The window has been minimized.  No action needed.
		Return
	GuiControl, Move, MyListView, % "W" . (A_GuiWidth - 20)							; Otherwise, the window has been resized or maximized. Resize the ListView to match.
	Return


UpdateFile() {																		;Saves data to file when ListView updated
	
	FileDelete, MovieList.txt
	WinGet, Min, MinMax, MovieList
	If Min = -1
		WinRestore, MovieList
	WinGetPos, X, Y, Width, Height, MovieList
	Width -= 16
	Height -= 38
	FileAppend, x%x% y%y% w%Width% h%Height% `n, MovieList.txt
	Loop % LV_GetCount()
	{
		RowNum := A_Index
		Loop, 2
		{
			LV_GetText(Text, RowNum, A_Index)

			TrimText := Trim(Text)
			FileAppend, "%TrimText%"`,, MovieList.txt
		}
		LV_GetText(Text, RowNum, 3)
		TrimText := Trim(Text)
		FileAppend, "%TrimText%"`n, MovieList.txt
	}
}

SizeCols() {																		;resize all columns, hide Column 9, Column 10 NoSort
     Loop, % LV_GetCount("Column")
       {
		  LV_ModifyCol(A_Index,"AutoHdr")
       }
       LV_ModifyCol(1, 300)
       LV_ModifyCol(2, 0)
       LV_ModifyCol(3,0)	; This was "AutoHdr" but you wanted col3 to be hidden.
       LV_ModifyCol(3,"NoSort")
}


#IfWinActive, MovieList																; CTRL+A to Select All
^a::LV_Modify(0,"Select")
#IfWinActive


Addexe:
	Gui, Submit, NoHide		
	FileSelectFile, exePath, 3,, Select Program, (*.exe )		; displays a standard dialog that allows the user to choose a picture
	Runexe := exePath
	;GuiControl,, Program,% exePath
	Return


Addicon:
	;FileSelectFile, file, 32,, Pick a file to check icons., *.ico
	IconFile := FileSelectIcon(NewIconIndex, "Pick an icon.")
	
	; The imagelist already exists and linked to the listview.
	;ImageListID := IL_Create(10,10,1)  ; Create an ImageList to hold 10 small icons.
	;LV_SetImageList(ImageListID,1)    ; Assign the above ImageList to the current ListView.
	NewIcon := IL_Add(ImageListID, IconFile, 0)
	
	SelectedRow := LV_GetNext()
	If (SelectedRow = 0)
		Return
	
	LV_Modify(SelectedRow, "Icon" . NewIcon . " Col3", IconFile)
	LV_ModifyCol("Hdr")  ; Auto-adjust the column widths.
Return

OpenFile:
	MsgBox OpenFile: This lable seem to not take part in the script and is thus not updated with the changes DyaTactic made.
	LV_Delete()
	FileSelectFile, file, 32,, Pick a file to check icons., *.*
	ImageListID := IL_Create(1,1)  ; Create an ImageList to hold 10 small icons.
	LV_SetImageList(ImageListID,1)    ; Assign the above ImageList to the current ListView.
	Loop                              ; Load the ImageList with a series of icons from the DLL.
	{
		 Count := Image               ; Number of icons found
		 Image := IL_Add(ImageListID, file, A_Index)  ; Omits the DLL's path so that it works on Windows 9x too.
		
		 If (Image = 0)               ; When we run out of icons
			Break                     
	} 
	Loop, %Count%  ; Add rows to the ListView (for demonstration purposes, one for each icon).
		LV_Add("Icon" . A_Index, "     " . A_Index)
	LV_ModifyCol("Hdr")  ; Auto-adjust the column widths.
	Return

	IconNum:
	Clipboard := file . ", " . A_EventInfo
	Msgbox %Clipboard% `r     added to Clipboard! `r %A_ScriptDir%
	;  Run c:AutoHotkey/iconsext.exe /save %file% %A_ScriptDir%/icons -icons,, Hide
Return


Search:


ListViewHandler:
if A_GuiEvent = DoubleClick
{
	LV_GetText(FileName, A_EventInfo, 2) ; Get the text of the first field.
	Execute(Filename)
}
return

Execute:
Row := LV_GetNext()
If (Row) {
	LV_GetText(FileName, Row, 2)
	Execute(Filename)
}
Return

Execute(Filename) {
	Run %FileName%,, UseErrorLevel
	if ErrorLevel
		MsgBox Could not open "%FileName%".
}


SetEditCueBanner(HWND, Cue) {
	Static EM_SETCUEBANNER := (0x1500 + 1)
	Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)
	}


GuiEventEmpty() {
	GuiControlGet, ConText,, EditCon, Text
	MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, 2
	WinGetClass, ConClass, % "ahk_id" OutputVarControl	
	If ( ConText = "" ) {
		GuiControl,, EditCon, PlaceHolder
		GuiControl, Disable, EditCon
		OnMessage( 0x111, "" )
		}
	}


GuiEventLeave() {
	MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, 2
	WinGetClass, ConClass, % "ahk_id" OutputVarControl	
	
	If ( ConClass = "Edit" ) {
		GuiControl,, EditCon
		GuiControl, Enable, EditCon
		Sleep, 1000
		OnMessage( 0x111, "GuiEventEmpty" )	
	}
}

FileSelectIcon(ByRef IconIndexOut:=0, Prompt:="Choose an file with icons") {
	FileSelectFile, sIconPath, 1, , %Prompt%, Icons (*.ico; *.icl; *.exe; *.dll)
	If !sIconPath
		Return ""
	
	nIndex := 0
	GoTo SkipIconIndex	; This simplifyes the system, only allowing the first icon of a file to be selected.
	
	VarSetCapacity(wIconPath, 260 * 2)
	DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)
	DllCall("shell32\PickIconDlg", "Uint", hWnd, "str", sIconPath, "Uint", 260, "intP", nIndex)
	RegExMatch(sIconPath, "U)%\K[^\\]+(?=%)", SysVar)	; Find 'SystemRoot' in '%SystemRoot%\system32'.
	; Expand system variables if one is used.
	If SysVar {
		EnvGet ExpSysVar, %SysVar%
		sIconPath := StrReplace(sIconPath, "%" SysVar "%", ExpSysVar)
	}
	;VarSetCapacity(sIconPath, 260)
	;DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)
	
	SkipIconIndex:
	
	IconIndexOut := nIndex
	Return sIconPath
}
@DyaTactic

Okay, one issue I'm runnin across here is that I am at a point that when I add another program, one of my other ones disappear? It's like seeing a limit to around 30 programs added and then starts deleting an old one when I put a new one in? Any Idea where this would be happening in the code?

UPDATED GUI:

Re: Url to Button

Posted: 14 Sep 2020, 04:07
by DyaTactic
Are you sure it is something with a limit? Could it be that there is sill another item selected and 'Link Program' changes the selected row instead? Does the replacement happen when Linking a program or when you press the Add button?