[AHK_L]Clip_Palette tool for SciTE (beta)
#1
Posted 24 April 2012 - 02:12 PM
As i was writing some code with a moderately large number of gLabels and gVariables i realized i wanted to have two tabs open at the same time, with one containing a list of the variables ands labels i already used. Unfortunately SciTE can't have two tabs side by side and moving from one tab to the next and back quickly became annoying so i created a small palette window in AutoHotKey to hold that list.
Then i realized i could improve this palette to be more useful than just a plain text view of my variables. After some more AHK work, i have managed to get something i consider useful.
Clip_Palette is here
Description
This is a "Clipboard palette" for use with SciTE. It will store often used custom keywords like variable names, labels, functions... so you can easily access them.
How to use
[*:mx0kcly2]Call the palette with alt-space while SciTE has focus. The palette will show where the caret is (unless this would cause the palette to be off-screen).
[*:mx0kcly2]Start typing any keyword, if the string typed matches any stored item, they will be displayed in the list below the edit box.
[*:mx0kcly2]If the word you are typing is not in the list, just finish typing it and press return. The new word will be inserted in SciTE at the Caret position and added to the palette for future use.
[*:mx0kcly2]At any time, use the down arrow to move to the list. You can navigate the list with up and down arrow. You can also select an Item with your mouse. When in the list, press return and the currently highlighted item will be copied to SciTE.
[*:mx0kcly2]Escape will hide the palette without copying anything to SciTE.
[*:mx0kcly2]A Palette Collection is a .pal file stored inside the SciTE folder. A Collection can contain any number of Palettes. You can switch between palettes with left and right arrows while the palette window is visible.
[*:mx0kcly2]When in the palette window, pressing alt-space again shows the palette editor window. In the palette editor, you can rename your palettes, add new palettes to you collection or even create another collection. You can also edit the items list directly in it's raw pipe delimited format to remove items or copy-past many items at once. Use save palette if you manually modified a palette.Known Issues
When in the palette editor, dialog boxes don't respond correctly to return. If you press return rather than click OK, the editor and the dialog box will hide below the SciTE window and the palette window won't answer correctly untill you actually click OK.
There's probably ways for improvement. Also i know it doesn't work as well on every computer as it does on mine so it should be considered as a "beta" version.
It was coded in AHK_L, so it won't work with AHK_B. I will compile it for AHK_B users once i think it's stable enough.
#2
Posted 24 April 2012 - 02:25 PM
Here is some code I got off the forum a while back. I modified it a little but I tested it and it works to click and drag a borderless Gui.
Gui, add, text,,click an drag a borderless window
Gui, show,w400 h400, Palette Gui
WinGet,PaletteGuiID,ID, Palette Gui
Gui, -caption
return
~LButton:: ;move the borderless window by dragging
CoordMode, Mouse
MouseGetPos, MouseStartX, MouseStartY, MouseWin,MouseControl
if MouseWin = %PaletteGuiID% ;allow click and drag titleless window
{
SetTimer, WatchMouse, 10
Return
WatchMouse:
CoordMode, Mouse
MouseGetPos, MouseX, MouseY
DeltaX = %MouseX%
DeltaX -= %MouseStartX%
DeltaY = %MouseY%
DeltaY -= %MouseStartY%
MouseStartX = %MouseX%
MouseStartY = %MouseY%
WinGetPos, CMX, CMY,,, ahk_id %PaletteGuiID%
CMX += %DeltaX%
CMY += %DeltaY%
SetWinDelay, -1
WinMove, ahk_id %PaletteGuiID%,, %CMX%, %CMY%
GetKeyState, LButtonState, LButton, P
if LButtonState = U
{
SetTimer, WatchMouse, off
Return
}
Return
}Thanks for considering my changes.
#3
Posted 24 April 2012 - 03:54 PM
I have re-uploaded it. it should now close itself when SciTE closes. Also i have commented the #Notray so if you don't mind tray cluttering, you can quit it anytime with the tray menu.
I have also added a logging function. To enable it, just uncomment this on top of the script.
;--------------------------------------------------------------- ; global _Log := "Clip_Palette.log" ; Uncomment to allow logging ;---------------------------------------------------------------The log will record palette content, name, number as well as some key variables each time functions are called that manipulate them. Hopefullt this will help me understand why palette are duplicated sometimes.
#4
LarryC
Posted 24 April 2012 - 06:04 PM
However IMO it just has to be moveable.
I modified yr script by removing "-Caption" in the first GUI line.
Not sure if that will break the script, but so far, not as of yet.
#5
Posted 24 April 2012 - 06:18 PM
Congratulations on the good work
#6
Posted 24 April 2012 - 09:39 PM
OK. I will see how i can make it moveable.
I have re-uploaded it. it should now close itself when SciTE closes. Also i have commented the #Notray so if you don't mind tray cluttering, you can quit it anytime with the tray menu.
I have also added a logging function. To enable it, just uncomment this on top of the script.;--------------------------------------------------------------- ; global _Log := "Clip_Palette.log" ; Uncomment to allow logging ;---------------------------------------------------------------The log will record palette content, name, number as well as some key variables each time functions are called that manipulate them. Hopefullt this will help me understand why palette are duplicated sometimes.
I uncommented the log line and ran Clip Palette tool and added variables and 2 new palettes, but I can not find the Clip_Palette.log on my computer anywhere.
The latest test I added 2 new palettes. Now I have the Sample Palette plus 2 more. I added 3 variables on the 2nd Palette and saved it. On the 3rd palette I added 3 variables and saved the palette, I closed the editor. I used my right arrow key to navigate the palettes. Now on palette 3 I have 5 variables. The first 2 are duplicated from the 2nd palette and then the 3 new variables. When I exit Clip Palette and restart it, it takes the 1st variable on each palette and adds it to the end of the palette title. Then shows the remaining variables correctly in the correct Palettes. But of course with the 1st one missing and added to the title of the palette.
How do I delete a Palatte?
Has anyone else experienced anything like this?
#7
Posted 25 April 2012 - 09:54 AM
It should be in %My Documents%\Autohotkey\SciTE\Palettes. This is also the folder where palette files are stored.I uncommented the log line and ran Clip Palette tool and added variables and 2 new palettes, but I can not find the Clip_Palette.log on my computer anywhere.
Your issues are rather strange. There is clearly something wrong with the way the script works on your computer but as it does work correctly on mine i don't know why.
Currently, you can't from the editor. I didn't notice the remove function for arrays until now (palettes are stored in arrays internally).How do I delete a Palatte?
What you can do is open default.pal. It's actually nothing but a plain text file, and delete the line that holds the palette you want to remove. Just ignore the warning. Deleting a full line while the script is not running shouldn't cause any issue (i did it plenty of times during my tests)
I will add the feature for the next version along with other suggestions.
The -caption was merely added to reduce the size of the palette. I will remove it to make the palettes moveable. If i use the title bar to hold the name of the palette in use rather than a text box it shouln't be much bigger. I'll see if i can use a handle to check active window for the hotkeys.
I hope i can understand what's wrong on DataLife's computer and correct this.
#8
Posted 25 April 2012 - 01:12 PM
http://autohotkey.ne...lip_Palette.log
If you can't make heads or tales of it then can I delete all the Palettes and log file and start again.
thanks
#9
Posted 28 April 2012 - 08:32 AM
Sure you can delete the entire Palettes folder if you want. It will be automatically created by the script as if you just ran it for the first time.
I see what happened. The first pipe was omitted for some reason. This causes both duplication of entries (because autohotkey will replace a listbox content if the string passed starts with a pipe, but append to the list if it doesn't) and the loss of the first entry when saving (because when reading the saved file, the script will look for a pipe to get the separation between the name and first entry.
Not sure why it's working on my computer and not on yours. :?
I'll try and see how i can code some more robust separator handling.
#10
Posted 28 April 2012 - 08:18 PM
I deleted the contents of the Pallet folder. And recreated a couple of pallets. If I forget to put a | as the very first character when adding variables then all kinds of things get messed up.Sorry for the delay.
Sure you can delete the entire Palettes folder if you want. It will be automatically created by the script as if you just ran it for the first time.
I see what happened. The first pipe was omitted for some reason. This causes both duplication of entries (because autohotkey will replace a listbox content if the string passed starts with a pipe, but append to the list if it doesn't) and the loss of the first entry when saving (because when reading the saved file, the script will look for a pipe to get the separation between the name and first entry.
Not sure why it's working on my computer and not on yours. :?
I'll try and see how i can code some more robust separator handling.
I suppose when saving a palette check to see if the 1st char is a pipe would avoid these issues.
As long as I format the pipe delimited variable list properly I won't have any more problems.
thanks
#11
Posted 28 April 2012 - 08:38 PM
WinGet,PaletteGuiID,id, Paletteafter
Gui, Palette_:Show, x%_x% y%_y% , Palette ; Show at caret positionand
WinGet,EditorGuiID,id, Editorafter
Gui, Editor_:Show, , Editor
Then I put this at the bottom of the script.
~LButton:: ;move the borderless window by dragging
CoordMode, Mouse
MouseGetPos, MouseStartX, MouseStartY, MouseWin,MouseControl
if ( MouseWin = PaletteGuiID or MouseWin = EditorGuiID )
{
if MouseWin = %PaletteGuiID%
MoveGuiID = %PaletteGuiID%
else
MoveGuiID = %EditorGuiID%
SetTimer, WatchMouse, 10
Return
WatchMouse:
CoordMode, Mouse
MouseGetPos, MouseX, MouseY
DeltaX = %MouseX%
DeltaX -= %MouseStartX%
DeltaY = %MouseY%
DeltaY -= %MouseStartY%
MouseStartX = %MouseX%
MouseStartY = %MouseY%
WinGetPos, CMX, CMY,,, ahk_id %MoveGuiID%
CMX += %DeltaX%
CMY += %DeltaY%
SetWinDelay, -1
WinMove, ahk_id %MoveGuiID%,, %CMX%, %CMY%
GetKeyState, LButtonState, LButton, P
if LButtonState = U
{
SetTimer, WatchMouse, off
Return
}
Return
}Now I can drag both windows with no problems.
Thanks for a great program.
#12
Posted 29 April 2012 - 03:07 PM
Thanks for the tips but i prefer this :mrgreen:To enable borderless window dragging I put...
Ctrl_Title: PostMessage, 0x00A1, 2, , , ahk_id %_ID_Palette% returnand
fn_OnResizeMsg(prm_wParam, prm_lParam, prm_msg, prm_hwnd) { ; Captures resize messages and changes them to move
if prm_wParam between 10 and 17
{
PostMessage, 0x00A1, 2, , , ahk_id %prm_hwnd%
return 0
}
}
Ctrl_title is the gLabel of the small text area holding the palette name, if you click on it you can move the window. I also managed to intercept resize messages and change them into move messages so clicking the sizing border will also allow to move the palette.To be honest, this message is not my idea but one of Skan's Tips and Tricks. I only puched it a little further with an on-message function.
It will be included in the next version along with better editor and hopefully more robust separator handling.
#13
Posted 29 April 2012 - 05:24 PM
Ctrl_Title: PostMessage, 0x00A1, 2, , , ahk_id %_ID_Palette% returnand
fn_OnResizeMsg(prm_wParam, prm_lParam, prm_msg, prm_hwnd) { ; Captures resize messages and changes them to move
if prm_wParam between 10 and 17
{
PostMessage, 0x00A1, 2, , , ahk_id %prm_hwnd%
return 0
}
}
I added this to your script and it works great.
thanks




