Tapatalk

Reordering templates in the list - a frustration mitigated by AHK

Reordering templates in the list - a frustration mitigated by AHK

23
Basic UserBasic User
23

    Feb 10, 2012#1

    Hi all,

    I've been frustrated for a long time by the inability to quickly re-order templates in the template list, and by the inability to go into the Te* files and make changes (they're some kind of binary mixed in with ASCII).

    In any case, I found a way to post to the template list and move templates up and down rather quickly with this AHK script (to use it go to autohotkey.com and download the program)

    Code: Select all

    SetTitleMatchMode,Regex
    GetProcAddress(dll, funcname) {
    	return DllCall("GetProcAddress", UInt, DllCall("GetModuleHandle", Str, dll) ,Str, funcname)
    }
    
    LB_GetCurrentSelection(hWnd) {
    
    	global SendMessageProc
    	LB_GETCURSEL := 0x188
    	SendMessageProc := GetProcAddress("user32", "SendMessageA")
    	Return DllCall(SendMessageProc, UInt, hWnd, UInt, LB_GETCURSEL, UInt, 0, UInt, 0)
    }
    
    postRightClick()
    {
    	LB_GETITEMRECT := 0x198
    		
    ;   GET THE WINDOW HANDLE FOR MY CONTROL (LIST BOX 5 IN THIS CASE IN ULTRAEDIT; THE TEMPLATE LIST) 		
    	ControlGet, LBhwnd, Hwnd,, ListBox5, A
    	
    ;   GET CURRENT POSITION OF LISTBOX -----------------------------
    	WinGetPos, X, Y, , , ahk_id %LBhwnd%
    ;   GET CURRENT ITEM ID -----------------------------------------
    	i := LB_GetCurrentSelection( LBHwnd)
    		
    ;   GET THE Y COORDINATE OF THE SELECTED ITEM (I) ---------------	
    	VarSetCapacity( yatl_rect, 16 )
    	DllCall( "SendMessage", UInt, LBHwnd, UInt, LB_GETITEMRECT, UInt, i, UInt, &yatl_rect )
    
    	yatl_rect_y := NumGet( yatl_rect, 4, Int )
    
    ;   SET THE X VALUE ABOUT 50 PX IN TO MAKE SURE IT HITS AN ITEM (THIS WILL VARY BY APPLICATION) 
    	cX:=50
    	cY:=yatl_rect_y
    
    ;   SEND THE RIGHT CLICK MESSAGE (0X204) ENCODING THE X AND Y COORDINATES ON THE CONTROL TO CLICK 	
    	PostMessage, 0x204, 0x8 | 0x1, cX & 0xFFFF | (cY & 0xFFFF) << 16,, ahk_id %LBhwnd%
    }
    F6::
    	postRightClick()
    	ControlSend, ListBox5, {Down 2}{Enter},A
    	
    Return
    F7::
    	postRightClick()
    	ControlSend, ListBox5, {Down 3}{Enter},A
    	
    Return
    
    

    6,685587
    Grand MasterGrand Master
    6,685587

      Feb 12, 2012#2

      Interesting that you offer this script now because UE v18.00 has a completely rewritten templates feature with templates stored in XML files - a global template file, a template file per environment and a template file per wordfile. And in the completely new written dialog for defining the templates it is quite easy to order them like the user wants it. The new templates feature in action can be seen at UltraEdit v18 Smart Templates video demo. Of course existing templates are converted to new storage format automatically by UltraEdit on first start after upgrade.

      However, your script is surely useful for all users of UltraEdit not upgrading to UE v18.00 or later.