Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

v1.0.36 released: Gui context menus and ListView


  • Please log in to reply
24 replies to this topic
Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.36:

Fixed double syntax error for a bad function call in a block.

Improved "Process, Exist" to fetch the script's own PID when no other parameters are given. [thanks Junyx]


CHANGES FOR GUI

Added GuiContextMenu, which facilitates the display of custom Gui context menus.

Added Gui +Delimiter`n as a means to change the separator between fields.

Added A_EventInfo for use by OnClipboardChange, ListBox, GuiSize, and GuiDropFiles.

Added A_GuiEvent as a synonym for A_GuiControlEvent.

Added +/-Redraw as a means to accelerate the filling of a ListBox.

Adding new control type ListView, which is a tabular view of rows and columns. It features built-in sorting and support for displaying icons.

http://www.autohotkey.com/download/

If you've been using the alpha-test version of the ListView, "Gui, Add, Row" has been replaced by LV_Add(). Also, GetNextItem() has been renamed to GetNext(). There have also been many enhancements.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Yieeepppiiieeee,
Thanks Chris.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
In the beginning I was a little bit confused, due to the functions. It is a different style to write code compared to the rest of GUI/GUIControl commands. Since text has to be in "" and variables do not need %%, but I think I can get used to it. I see the benefit in the loops. It will result in very short code compared to normal commands.

Thanks for this new feature.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Rabiator
  • Members
  • 292 posts
  • Last active: Aug 29 2016 09:29 PM
  • Joined: 17 Apr 2005
Marvelously figured out.
Thanks!

daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
Excellent! 8)

(RichEdit and InternetExplorerContainerWindow too please :p )

Need to fiddle around with them ListView rightaway...

Rajat, I know you are having some bad days right now, but can you please add preliminary support for ListView (so that it doesn't error out) to SmartGUI?

I'm speechless...

All I really need now is some more info/teachmyself on dll calling to avoid weird errors with DLLCall :p
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

(RichEdit and InternetExplorerContainerWindow too please :p )

Those would be good additions. In case you want to use them right away, I don't think there's anything that would prevent you from using DllCall("CreateWindow"...) to create any control of your choice inside a parent GUI window. After creation, you could send the control some messages to set it up and get things back out of it.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
congrats on another big achievment Chris!

listview looks great, though the example script looks complicated and i'm kinda afraid to get my feet wet!

by the way it doesn't show the actual icons of files, so i did a li'l research and found that shell32.dll\ExtractAssociatedIcon gives the correct icon (returns the handle of an indexed icon found in a file or an icon found in an associated executable file). but to use it i need App.hInstance which i don't know much about. i'm sure there'll be ppl asking for this soon, so shouldn't this be built-in?

daonlyfreez,
i'll try to put in basic support soon. but by that time u can create a listbox in sgui and rename it to listview in script.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


dijiyd
  • Members
  • 87 posts
  • Last active: Oct 22 2005 01:29 PM
  • Joined: 31 Mar 2004
Alright! Even AutoIt's ListView doesn't have sorting.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

the example script looks complicated and i'm kinda afraid to get my feet wet!

I wanted to have both a simple and a complex example. If you wanted to reduce it to the bare minimum, the following is a fully functional ListView script that displays some files in report view:
Gui, Add, ListView, r20 w700, Name|Size (KB)
; Gather a list of file names from a folder and put them into the ListView:
Loop, %A_MyDocuments%\*.*
	LV_Add("", A_LoopFileName, A_LoopFileSizeKB)
Gui Show

i did a li'l research and found that shell32.dll\ExtractAssociatedIcon gives the correct icon

I was wondering how to do that and now I know. Thanks.

I think the following script segment can get the associated icon because ExtractAssociatedIcon() does not seem to strictly require a valid hInstance:
; Gather a list of file names from a folder and append them to the ListView:
Loop %Folder%\*.*
{
	FileName := A_LoopFileFullPath  ; Must save to writable variable for use below.
	StringReplace, FileName, FileName, \\, \  ; Due to root drive having backslash from FileSelectFolder.
	hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, str, FileName, UShortP, iIndex)
	if hIcon
	{
		DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, int, -1, UInt, hIcon)
		IconNumber := DllCall("ImageList_ReplaceIcon", UInt, ImageListID2, int, -1, UInt, hIcon) + 1  ; +1 to convert to one-based.
		DllCall("DestroyIcon", Uint, hIcon)  ; Free the memory.
	}
	else
		IconNumber = 1

	; Create the new row and assign it an icon number:
	LV_Add("Icon" . IconNumber, A_LoopFileName, A_LoopFileDir, A_LoopFileSizeKB)
}
The above is not the most efficient way to do it because it extracts the icon separately for every single file. For non-EXE files, memory and loading time could be reduced by maintaining an array of file extensions along with their associated index in the image list.

shouldn't [App.hInstance] be built-in?

If there turns out to be a need for it, perhaps it should become a built-in variable A_hInstance. But perhaps someone knows if there's a function the script can call to discover its own hInstance value.

Thanks.

Edit: Changed one comment to "Due to root drive having backslash from FileSelectFolder."

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
its slow but if icons are to be shown than random icon won't help. and the idea of maintaining an array of file extensions and imagelist is good.

thanx!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
@Rajat: Thank you for your answer. Am using the 'workaround' as you described already (I always use a copy of a script for fiddling with the GUI with your tool, and copy the generated GUI definitions to my 'real' script). Did replace ListView with ListBox to avoid erroring out yes, but please add something like: 'IfTheLineStartsWith "Gui, Add, ListView", just ignore it and put it back in when generating the resultfile' 8)

@Chris: I really like the potential power of the DLLCall command, but it's very hard to understand (for me) and also very hard to get the right 'commands' to use, and frankly the whole syntax 'scares me'....

In case you want to use them right away, I don't think there's anything that would prevent you from using DllCall("CreateWindow"...) to create any control of your choice inside a parent GUI window. After creation, you could send the control some messages to set it up and get things back out of it.


You make this sound so simple, but it's mumbo jumbo to me for now...

I hate the VB-style syntax, don't understand it, and when I look around the net to find useful DLLCalls, I always end up with finding exactly that, VB code... :(

I think we need to try to collect 'useful DLLCalls' somewhere, maybe in the 'Utilities & Resources' section? If everybody can post his/hers experiences with the different Hotkeys, PostMessages and DLLCalls in programs, that would be a great timesaver...
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

neyon
  • Members
  • 34 posts
  • Last active: Nov 25 2009 06:15 PM
  • Joined: 29 May 2005
Chris,

Another fantastic improvement! I fully agree with all the positive comments written here. Fantastic.

Thanks!

Neyon

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

i did a li'l research and found that shell32.dll\ExtractAssociatedIcon gives the correct icon

I've improved the script at the bottom of the ListView page to contain your idea. Now it gets the correct icon for the file type, just like Explorer. It also caches the icons by keeping them in an array, which makes file-loading much quicker.

You make this sound so simple, but it's mumbo jumbo to me for now...

It was only suggested in case you were needed RichEdit or other controls right away. You're right that it would definitely take some time studying the documentation at MSDN. But I don't think you would have to have any programming experience to understand most of it.

I think we need to try to collect 'useful DLLCalls' somewhere, maybe in the 'Utilities & Resources' section?

I agree. Either there or in Scripts/Functions, whichever seems more appropriate (case by case). Hopefully the collection will grow over time.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.36.01:

Fixed FileCopy and FileMove to avoid deleting a file that is copied/moved onto itself. In such a case, FileCopy still counts it as a failure but FileMove now counts it as a success. [thanks mario_a]

Fixed continuation sections so that accents and commas after the word Join don't change the behavior of accents and commas in the section. [thanks Nemroth]

Added "WinSet Top", which attempts to bring a window to the top of the stack without activating it. [thanks catweazle]

  • Guests
  • Last active:
  • Joined: --

i did a li'l research and found that shell32.dll\ExtractAssociatedIcon gives the correct icon

I've improved the script at the bottom of the ListView page to contain your idea. Now it gets the correct icon for the file type, just like Explorer. It also caches the icons by keeping them in an array, which makes file-loading much quicker.


The last example had a small portion, where you specified different shell32.dll for different OS. I would need that part now. But I have already updated. damn. Could you please post that snippet. Thanks.