Jump to content

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

Pastej v0.94 - Powerful pasting


  • Please log in to reply
20 replies to this topic
sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Update: Version 0.94 is the latest version, and available through Appifyer.com (link below).

Pastej is a powerful and versatile tool for using and defining pasties - snippets of code that will let you paste stuff directly "as you want it". Regardless if you want to paste a link with formatting, just code with code-tags, or maybe an email with your customer's name inserted: The only limitation is your imagination, and of course my scripting abilities.

Posted Image

Try it out in any form you like (note however that there are dependencies - the exe is guaranteed to run though) and come back when you have. Get some ideas for pasties, and share with others. Please do. If you need some inspiration, watch the demo video, which is unusually long (might be cos I'm tired, I dunno.). I hope you enjoy this script, as I think it will become very useful in its' area of application!

As usual, no hotkeys are embedded/enforced by the script, but the script instead runs On-demand per default (but AlwaysOn if you have no applauncher). I recommend the hotkey #v, and I promise you that my applauncher is getting closer and closer to done. While making and configuring Pastej I learned yet more about how to construct a configuration GUI, which I'll apply to my applauncher. By the way, the download links on this page are formatted using a pastie, as is the image, of course.

If you have any questions &/or comments, bring'em on!

Pastej demo video (5 minutes)

Downloads

[Pastej.exe] (Appifyer.com) <--- Latest version!
[Pastej.ahk] (AHK.net)
[Pastej.zip] (AHK.net)

Requirements

Written in AHK_L(Unicode x32) and requires AHK_L. Requires ini.ahk library by Tuncay. You need to either have it in your standard library or manually #include it. The exe works for everyone.

History: PasteAs

A simple yet powerful concept that I plan to extend and improve after receiving feedback from you guys. Basically lets you paste your clipboard, but with options. For example, choosing "code" to paste with code-tags, or path to paste the copied file's path. Note that this script, as most of my scripts, is launched externally for convenience. If you want to run it as a standalone, insert a Hotkey before the Menu.

< Video introduction >

Ideas for features:
*Easy-to-add "Actions"
*Hotkeys for selecting menu items

Please suggest any improvements, or comment on which features you would like to see.

Downloads:
PasteAs.exe
PasteAs.rar
AHK code*

*I couldn't paste it using the code-tags, since the script contains codetags which then would conflict with the forum tags.



bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks for the video. It was great! :) May I ask how you produce this kind of demo videos?

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

Thanks for the video. It was great! :) May I ask how you produce this kind of demo videos?


See my signature. I offer to do it for other AHK-ers, just because I atm find it pretty fun. And I wanna promote AHK. Also, Screenr.com - I just go to that site, click a button and get a "record frame". Glad you liked it. Gonna improve the program too, when I have time. Alot going on at the moment, which is nice in a way :)

Still gladly taking requests/ideas for paste-as-functions. Planning to also integrate it with bit.lyButler for pasting shortlinks.

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Huge update, see first post. Try it, or try it again. Working on eliminating the last bugs, but I am also ready to implement additional features on request.

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks for the update! HOWEVER, I copied and passed the AHK version where I received the following error message upon trial. :roll:
Error: Supported only for the tray menu [ :shock: ]
; AUTHOR: Simon Strålberg
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force
ClipBoardSaved := ClipBoardAll
If (!FileExist("data\license.txt"))
{
	Gui, 33:Default
	Gui, +owner
	gui, font, s10, Verdana  ; Set 10-point Verdana.
	Gui, Add, Text,, This is the first time you run Pastej `n`nExtract data to "/data" directory?
	Gui, Add, Button, x10 w125 h40 gGuiInstall default, Sure!
	Gui, Add, Button, x135 w125 yp h40 gGuiNoInstall, No thanks!
	Gui, -Caption +Border
	Gui, Color, ffFFff
	Gui, Show
	return
}
PostInstall: ; Return here after installing
OnExit, Exit
IfExist, data\ico\Pastej.ico
	Menu, Tray, Icon, data\ico\Pastej.ico
; #v:: ADD HOTKEY HERE! (If you want one)
ini_load(Pasties, "data\pasties.ini")
SectionNames := ini_getAllSectionNames(Pasties)
Sort, SectionNames, D`, ; Alphabetical order
Loop, Parse, SectionNames, `, ; Get all Pasties
{
	Menu, PasteMenu, Add, %A_LoopField%, Paste
		ini_read(Icon, Pasties, A_LoopField, "Icon", "data\ico\default.ico")
	IfExist, %icon%
		Menu, PasteMenu, Icon, %A_LoopField%, %icon%,, 32
	else
		Menu, PasteMenu, Icon, %A_LoopField%, data\ico\default.ico,, 32
}
Menu, PasteMenu, Add
Menu, PasteMenu, Add, Manage Pasties..., Manage
Menu, PasteMenu, Show
return

Paste:
; Pasties are in the format of [url=@ins@]@clip@[/url] where "@ins@" gets replaced by any Prompt input, and @clip@ by the Clipboard
ini_read(Prompt, Pasties, A_ThisMenuItem, "Prompt", "")
If (Prompt)
{
	ini_read(PromptDefault, Pasties, A_ThisMenuItem, "Promptdefault", "")
	If (PromptDefault = "@clip@")
		PromptDefault := Clipboard
	InputBox, Input, Pastej:, %Prompt%,,300,140,,,,, %PromptDefault%
	If (Errorlevel)
		return
}
ini_read(String, Pasties, A_ThisMenuItem, "String", "")
StringReplace, String, String, @ins@, %Input%, All
StringReplace, String, String, @clip@, %Clipboard%, All
Clipboard := String
Send ^v

Sleep 200
Gosub, Exit
; Uncomment if you want to keep running (add a hotkey, too)
; ClipBoard := ClipBoardSaved
; return

Manage: ; Guis should be in an #include file, probably
;~ Gui, Add, Text, x10, Icon
;~ Gui, Add, Text, yp x50, Pastie
Gui, Add, Text, x150 gGuiStringHelp, String (?)
Gui, Add, Text, yp x550 gGuiPromptHelp, Prompt (?)
SectionNames := ini_getAllSectionNames(Pasties)
Sort, SectionNames, D`, ; Alphabetical order
Loop, Parse, SectionNames, `, ; List pasties
{
	Section := variableSafe(A_LoopField)
	ini_read(Icon, Pasties, A_LoopField, "Icon", "data\ico\default.ico")
	IfExist, %icon%
		Gui, Add, Picture, x10 w32 h32 gGuiChangeIcon vIcon_%Section%, %icon%
	else
		Gui, Add, Picture, x10 w32 h32 gGuiChangeIcon vIcon_%Section%, data\ico\default.ico
	
	Gui, Add, Text, yp+10 x50 w85 gGuiChangeName v%Section%, %A_LoopField%
		
	Gui, Add, Text, yp x135 gGuiRemovePastie vRemove_%Section%, (x)
	
	ini_read(String, Pasties, A_LoopField, "String", "")
	Gui, Add, Edit, yp-2 x150 w400 vString_%Section%, %String%
	Gui, Add, Button, yp x560 vPrompt_%Section% gGuiChangePrompt, ...	
	Gui, Add, Button, yp x580 vPromptDefault_%Section% gGuiChangePromptDefault, D
	; Default values
	Icon_%Section% := (FileExist(Icon) ? Icon : "data\ico\default.ico")
	String_%Section% := String
	Prompt_%Section% := Prompt
	PromptDefault_%Section% := PromptDefault
}
Gui, Add, Button, x10 h40 w90 gGuiAddPastie, &Add pastie
Gui, Add, Button, yp x105 h40 w40 gGuiHelp, &Help
Gui, Add, Button, yp x150 h40 w400 gGuiSubmit, &Save && close
Gui, Show
return

GuiAddPastie:
Gui, Submit, Nohide
Gosub, GuiSubmitNohide
InputBox, SectionName, New pastie:, New pastie name,,300,100,,,,, My pastie
If Errorlevel
	return
If (SectionName = "")
{
	MsgBox, 48, Error: No name, You must give your pastie a name!
	return
}
AllSections := ini_getAllSectionNames(Pasties)
If (InStr(AllSections, SectionName))
{
	MsgBox, 48, Error: Duplicate, Pastie exists! You must use a unique name!
	return
}
ini_insertSection(Pasties, SectionName, "`r`nIcon=`r`nPrompt=`r`nPromptDefault=`r`nString=`r`n")
Gui, Destroy
Gosub, Manage
return

GuiSubmit:
Gui, Submit
GuiSubmitNoHide: ; Submit, then gosub
Loop, Parse, SectionNames, `, ; List pasties
{
	Section := variableSafe(A_LoopField)	
	Icon := Icon_%Section%
	String := String_%Section%
	Prompt := Prompt_%Section%
	PromptDefault := PromptDefault_%Section%
	If (InStr(Icon, A_ScriptDir)) ; Add support for directory-relative icons
	{
		Dirlen := StrLen(A_ScriptDir)+1 ; +1 to remove preceding slash \
		StringTrimLeft, Icon, Icon, %DirLen%
	}
	PastieName := variableUnsafe(Section)
	ini_replaceValue(Pasties, PastieName, "Icon", Icon)
	ini_replaceValue(Pasties, PastieName, "String", String)
	ini_replaceValue(Pasties, PastieName, "Prompt", Prompt)
	ini_replaceValue(Pasties, PastieName, "PromptDefault", PromptDefault)
}
ini_save(Pasties, "data\pasties.ini")
return

GuiRemovePastie:
StringTrimLeft, Section, A_GuiControl, 7
MsgBox, 52, Delete pastie?, Are you sure you want to delete %Section% permanently?
If Errorlevel
	return
Section := VariableUnsafe(Section)
Ini_Delete(Pasties, Section, "String")
Ini_Delete(Pasties, Section)
Section := VariableSafe(Section)
GuiControl, Disable, Icon_%Section%
GuiControl, Disable, %Section%
GuiControl, Disable, Remove_%Section%
GuiControl, Disable, String_%Section%
GuiControl, Disable, Prompt_%Section%
GuiControl, Disable, PromptDefault_%Section%
/*
Icon_%Section% := 
%Section% := 
Remove_%Section% :=
String_%Section% :=
Prompt_%Section% :=
PromptDefault_%Section% :=
*/
return

GuiChangeIcon:
FileSelectFile, NewIcon, S, data\ico, Select icon..., *.ico
If Errorlevel
	return
StringTrimLeft, PastieName, A_GuiControl, 5 ; Get Pastiename (varsafe)
PastieName := VariableSafe(PastieName)
GuiControl,, %A_GuiControl%, %NewIcon%
Icon_%PastieName% := NewIcon
return

GuiChangeName:
InputBox, NewName, Pastie name:, Change Pastie name,,300,100,,,,, %A_GuiControl%
If Errorlevel
	return
GuiControl,, %A_GuiControl%, %NewName%
;~ ini_write(Icon, Pasties, A_GuiControl, "Icon")
return

GuiChangePrompt:
StringTrimLeft, PastieName, A_GuiControl, 7 ; Gets the Pastiename
PastieName := VariableUnsafe(PastieName)
ini_read(Prompt, Pasties, PastieName, "Prompt", "")
InputBox, NewPrompt, Prompt:, Enter pastie prompt,,300,100,,,,, %Prompt%
If Errorlevel
	return
ini_replaceValue(Pasties, PastieName, "Prompt", NewPrompt)
Section := VariableSafe(PastieName)
Prompt_%Section% := NewPrompt ; Set the GUI value
return

GuiChangePromptDefault: 
StringTrimLeft, PastieName, A_GuiControl, 14 ; Gets the Pastiename
PastieName := VariableUnsafe(PastieName)
ini_read(PromptDefault, Pasties, PastieName, "Promptdefault", "")
InputBox, NewPromptDefault, Prompt default:, Enter prompt default value,,300,100,,,,, %PromptDefault%
If Errorlevel
	return
ini_replaceValue(Pasties, PastieName, "PromptDefault", NewPromptDefault)
Section := VariableSafe(PastieName)
PromptDefault_%Section% := NewPromptDefault ; Set the GUI value
return

GuiHelp:
;~ TrayTip, Help:, Pastej (TM) was made by Simon Strålberg 2011.`nIt lets you paste your clipboard in set formats`, to speed up everyday tasks. You can freely define your own pasties using the builtin tool and format., 20
MsgBox, 64, Pastej Help, Pastej (TM) was made by Simon Strålberg in 2011.`n`nIt lets you paste your clipboard more richly`, to speed up everyday tasks. You can freely define your own pasties using the builtin tool.
return

GuiStringHelp:
TrayTip, String:, How your pastie will be pasted.`n@clip@ will be replaced by clipboard`,`n@ins@ by any insertion from the optional prompt window., 10
return

GuiPromptHelp:
TrayTip, Prompt:, If your pastie has a prompt`, you will be asked to enter input.`nYou can also add a default value for your prompt., 10
return

GuiInstall:
Gui, Destroy
Progress, Extracting...,, Pastej is extracting data
FileCreateDir, data
FileCreateDir, data\ico
FileInstall, data\ico\attachment.ico, data\ico\attachment.ico
Progress, 10
FileInstall, data\ico\attention.ico, data\ico\attention.ico
FileInstall, data\ico\code.ico, data\ico\code.ico
Progress, 20
FileInstall, data\ico\colors.ico, data\ico\colors.ico
FileInstall, data\ico\date.ico, data\ico\date.ico
Progress, 30
FileInstall, data\ico\default.ico, data\ico\default.ico
FileInstall, data\ico\document.ico, data\ico\document.ico
FileInstall, data\ico\google.ico, data\ico\google.ico
FileInstall, data\ico\help.ico, data\ico\help.ico
FileInstall, data\ico\help_green.ico, data\ico\help_green.ico
FileInstall, data\ico\html.ico, data\ico\html.ico
Progress, 40
FileInstall, data\ico\img.ico, data\ico\img.ico
FileInstall, data\ico\letter_a.ico, data\ico\letter_a.ico
FileInstall, data\ico\message_out.ico, data\ico\message_out.ico
FileInstall, data\ico\message_star.ico, data\ico\message_star.ico
FileInstall, data\ico\movie.ico, data\ico\movie.ico
Progress, 50
FileInstall, data\ico\Pastej.ico, data\ico\Pastej.ico
FileInstall, data\ico\path.ico, data\ico\path.ico
FileInstall, data\ico\picture.ico, data\ico\picture.ico
FileInstall, data\ico\script.ico, data\ico\script.ico
FileInstall, data\ico\star.ico, data\ico\star.ico
FileInstall, data\ico\star_blue.ico, data\ico\star_blue.ico
Progress, 60
FileInstall, data\ico\std.ico, data\ico\std.ico
FileInstall, data\ico\text.ico, data\ico\text.ico
FileInstall, data\ico\text2.ico, data\ico\text2.ico
Progress, 70
FileInstall, data\ico\time.ico, data\ico\time.ico
FileInstall, data\ico\url.ico, data\ico\url.ico
Progress, 80
FileInstall, data\ico\url2.ico, data\ico\url2.ico
FileInstall, data\ico\web.ico, data\ico\web.ico
Progress, 90
FileInstall, data\ico\web_search.ico, data\ico\web_search.ico
FileInstall, data\ico\icons_from.txt, data\ico\icons_from.txt
; Non-icon files
FileInstall, data\license.txt, data\license.txt
FileInstall, data\pasties.ini, data\pasties.ini
Progress, Off
Traytip, Pastej:, Finished!, 4
Gosub, PostInstall
return

GuiNoInstall:
MsgBox, 48, Pastej cannot launch, Pastej cannot launch without its' required files. Please restart Pastej and extract the files if you wish to continue.
GuiClose:
Gosub, Exit
~Esc::
Exit:
ClipBoard := ClipBoardSaved
ExitApp

variableSafe(String)
{
	StringReplace, String, String, %A_Space%, _, All
	return String
}

variableUnsafe(String)
{
	StringReplace, String, String, _, %A_Space%, All
	return String
}


sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

Thanks for the update! HOWEVER, I copied and passed the AHK version where I received the following error message upon trial. :roll:
Error: Supported only for the tray menu [ :shock: ]


Dependencies: ini.ahk by Tuncay.

As I said, it also require the data files to be intact, but I think if you take the zip you should be able to use the .ahk version. I only guarantee that the .exe will work though, and it will.

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
Thanks! I downloaded the Zip file and put the ini.ahk file in the same directory. Still, it failed.
...


Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
when using the exe version I dont know how to call it into action. It doesnt seem to have a hotkey - and with it being an exe I cant add one.
"Choose your parents wisely"

bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011
I downloaded Pastej.ahk and added #include ini.ahk as follows:
#include ini.ahk

; AUTHOR: Simon Strålberg
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force
ClipBoardSaved := ClipBoardAll
If (!FileExist("data\license.txt"))
{
	Gui, 33:Default
	Gui, +owner
	gui, font, s10, Verdana  ; Set 10-point Verdana.
	Gui, Add, Text,, This is the first time you run Pastej `n`nExtract data to "/data" directory?
	Gui, Add, Button, x10 w125 h40 gGuiInstall default, Sure!
	Gui, Add, Button, x135 w125 yp h40 gGuiNoInstall, No thanks!
	Gui, -Caption +Border
	Gui, Color, ffFFff
	Gui, Show
	return
}
PostInstall: ; Return here after installing
OnExit, Exit
IfExist, data\ico\Pastej.ico
	Menu, Tray, Icon, data\ico\Pastej.ico
; #v:: ADD HOTKEY HERE! (If you want one)
ini_load(Pasties, "data\pasties.ini")
SectionNames := ini_getAllSectionNames(Pasties)
Sort, SectionNames, D`, ; Alphabetical order
Loop, Parse, SectionNames, `, ; Get all Pasties
{
	Menu, PasteMenu, Add, %A_LoopField%, Paste
		ini_read(Icon, Pasties, A_LoopField, "Icon", "data\ico\default.ico")
	IfExist, %icon%
		Menu, PasteMenu, Icon, %A_LoopField%, %icon%,, 32
	else
		Menu, PasteMenu, Icon, %A_LoopField%, data\ico\default.ico,, 32
}
Menu, PasteMenu, Add
Menu, PasteMenu, Add, Manage Pasties..., Manage
Menu, PasteMenu, Show
return

Paste:
; Pasties are in the format of [url=@ins@]@clip@[/url] where "@ins@" gets replaced by any Prompt input, and @clip@ by the Clipboard
ini_read(Prompt, Pasties, A_ThisMenuItem, "Prompt", "")
If (Prompt)
{
	ini_read(PromptDefault, Pasties, A_ThisMenuItem, "Promptdefault", "")
	If (PromptDefault = "@clip@")
		PromptDefault := Clipboard
	InputBox, Input, Pastej:, %Prompt%,,300,140,,,,, %PromptDefault%
	If (Errorlevel)
		return
}
ini_read(String, Pasties, A_ThisMenuItem, "String", "")
StringReplace, String, String, @ins@, %Input%, All
StringReplace, String, String, @clip@, %Clipboard%, All
Clipboard := String
Send ^v

Sleep 200
Gosub, Exit
; Uncomment if you want to keep running (add a hotkey, too)
; ClipBoard := ClipBoardSaved
; return

Manage: ; Guis should be in an #include file, probably
;~ Gui, Add, Text, x10, Icon
;~ Gui, Add, Text, yp x50, Pastie
Gui, Add, Text, x150 gGuiStringHelp, String (?)
Gui, Add, Text, yp x550 gGuiPromptHelp, Prompt (?)
SectionNames := ini_getAllSectionNames(Pasties)
Sort, SectionNames, D`, ; Alphabetical order
Loop, Parse, SectionNames, `, ; List pasties
{
	Section := variableSafe(A_LoopField)
	ini_read(Icon, Pasties, A_LoopField, "Icon", "data\ico\default.ico")
	IfExist, %icon%
		Gui, Add, Picture, x10 w32 h32 gGuiChangeIcon vIcon_%Section%, %icon%
	else
		Gui, Add, Picture, x10 w32 h32 gGuiChangeIcon vIcon_%Section%, data\ico\default.ico
	
	Gui, Add, Text, yp+10 x50 w85 gGuiChangeName v%Section%, %A_LoopField%
		
	Gui, Add, Text, yp x135 gGuiRemovePastie vRemove_%Section%, (x)
	
	ini_read(String, Pasties, A_LoopField, "String", "")
	Gui, Add, Edit, yp-2 x150 w400 vString_%Section%, %String%
	Gui, Add, Button, yp x560 vPrompt_%Section% gGuiChangePrompt, ...	
	Gui, Add, Button, yp x580 vPromptDefault_%Section% gGuiChangePromptDefault, D
	; Default values
	Icon_%Section% := (FileExist(Icon) ? Icon : "data\ico\default.ico")
	String_%Section% := String
	Prompt_%Section% := Prompt
	PromptDefault_%Section% := PromptDefault
}
Gui, Add, Button, x10 h40 w90 gGuiAddPastie, &Add pastie
Gui, Add, Button, yp x105 h40 w40 gGuiHelp, &Help
Gui, Add, Button, yp x150 h40 w400 gGuiSubmit, &Save && close
Gui, Show
return

GuiAddPastie:
Gui, Submit, Nohide
Gosub, GuiSubmitNohide
InputBox, SectionName, New pastie:, New pastie name,,300,100,,,,, My pastie
If Errorlevel
	return
If (SectionName = "")
{
	MsgBox, 48, Error: No name, You must give your pastie a name!
	return
}
AllSections := ini_getAllSectionNames(Pasties)
If (InStr(AllSections, SectionName))
{
	MsgBox, 48, Error: Duplicate, Pastie exists! You must use a unique name!
	return
}
ini_insertSection(Pasties, SectionName, "`r`nIcon=`r`nPrompt=`r`nPromptDefault=`r`nString=`r`n")
Gui, Destroy
Gosub, Manage
return

GuiSubmit:
Gui, Submit
GuiSubmitNoHide: ; Submit, then gosub
Loop, Parse, SectionNames, `, ; List pasties
{
	Section := variableSafe(A_LoopField)	
	Icon := Icon_%Section%
	String := String_%Section%
	Prompt := Prompt_%Section%
	PromptDefault := PromptDefault_%Section%
	If (InStr(Icon, A_ScriptDir)) ; Add support for directory-relative icons
	{
		Dirlen := StrLen(A_ScriptDir)+1 ; +1 to remove preceding slash \
		StringTrimLeft, Icon, Icon, %DirLen%
	}
	PastieName := variableUnsafe(Section)
	ini_replaceValue(Pasties, PastieName, "Icon", Icon)
	ini_replaceValue(Pasties, PastieName, "String", String)
	ini_replaceValue(Pasties, PastieName, "Prompt", Prompt)
	ini_replaceValue(Pasties, PastieName, "PromptDefault", PromptDefault)
}
ini_save(Pasties, "data\pasties.ini")
return

GuiRemovePastie:
StringTrimLeft, Section, A_GuiControl, 7
MsgBox, 52, Delete pastie?, Are you sure you want to delete %Section% permanently?
If Errorlevel
	return
Section := VariableUnsafe(Section)
Ini_Delete(Pasties, Section, "String")
Ini_Delete(Pasties, Section)
Section := VariableSafe(Section)
GuiControl, Disable, Icon_%Section%
GuiControl, Disable, %Section%
GuiControl, Disable, Remove_%Section%
GuiControl, Disable, String_%Section%
GuiControl, Disable, Prompt_%Section%
GuiControl, Disable, PromptDefault_%Section%
/*
Icon_%Section% := 
%Section% := 
Remove_%Section% :=
String_%Section% :=
Prompt_%Section% :=
PromptDefault_%Section% :=
*/
return

GuiChangeIcon:
FileSelectFile, NewIcon, S, data\ico, Select icon..., *.ico
If Errorlevel
	return
StringTrimLeft, PastieName, A_GuiControl, 5 ; Get Pastiename (varsafe)
PastieName := VariableSafe(PastieName)
GuiControl,, %A_GuiControl%, %NewIcon%
Icon_%PastieName% := NewIcon
return

GuiChangeName:
InputBox, NewName, Pastie name:, Change Pastie name,,300,100,,,,, %A_GuiControl%
If Errorlevel
	return
GuiControl,, %A_GuiControl%, %NewName%
;~ ini_write(Icon, Pasties, A_GuiControl, "Icon")
return

GuiChangePrompt:
StringTrimLeft, PastieName, A_GuiControl, 7 ; Gets the Pastiename
PastieName := VariableUnsafe(PastieName)
ini_read(Prompt, Pasties, PastieName, "Prompt", "")
InputBox, NewPrompt, Prompt:, Enter pastie prompt,,300,100,,,,, %Prompt%
If Errorlevel
	return
ini_replaceValue(Pasties, PastieName, "Prompt", NewPrompt)
Section := VariableSafe(PastieName)
Prompt_%Section% := NewPrompt ; Set the GUI value
return

GuiChangePromptDefault: 
StringTrimLeft, PastieName, A_GuiControl, 14 ; Gets the Pastiename
PastieName := VariableUnsafe(PastieName)
ini_read(PromptDefault, Pasties, PastieName, "Promptdefault", "")
InputBox, NewPromptDefault, Prompt default:, Enter prompt default value,,300,100,,,,, %PromptDefault%
If Errorlevel
	return
ini_replaceValue(Pasties, PastieName, "PromptDefault", NewPromptDefault)
Section := VariableSafe(PastieName)
PromptDefault_%Section% := NewPromptDefault ; Set the GUI value
return

GuiHelp:
;~ TrayTip, Help:, Pastej (TM) was made by Simon Strålberg 2011.`nIt lets you paste your clipboard in set formats`, to speed up everyday tasks. You can freely define your own pasties using the builtin tool and format., 20
MsgBox, 64, Pastej Help, Pastej (TM) was made by Simon Strålberg in 2011.`n`nIt lets you paste your clipboard more richly`, to speed up everyday tasks. You can freely define your own pasties using the builtin tool.
return

GuiStringHelp:
TrayTip, String:, How your pastie will be pasted.`n@clip@ will be replaced by clipboard`,`n@ins@ by any insertion from the optional prompt window., 10
return

GuiPromptHelp:
TrayTip, Prompt:, If your pastie has a prompt`, you will be asked to enter input.`nYou can also add a default value for your prompt., 10
return

GuiInstall:
Gui, Destroy
Progress, Extracting...,, Pastej is extracting data
FileCreateDir, data
FileCreateDir, data\ico
FileInstall, data\ico\attachment.ico, data\ico\attachment.ico
Progress, 10
FileInstall, data\ico\attention.ico, data\ico\attention.ico
FileInstall, data\ico\code.ico, data\ico\code.ico
Progress, 20
FileInstall, data\ico\colors.ico, data\ico\colors.ico
FileInstall, data\ico\date.ico, data\ico\date.ico
Progress, 30
FileInstall, data\ico\default.ico, data\ico\default.ico
FileInstall, data\ico\document.ico, data\ico\document.ico
FileInstall, data\ico\google.ico, data\ico\google.ico
FileInstall, data\ico\help.ico, data\ico\help.ico
FileInstall, data\ico\help_green.ico, data\ico\help_green.ico
FileInstall, data\ico\html.ico, data\ico\html.ico
Progress, 40
FileInstall, data\ico\img.ico, data\ico\img.ico
FileInstall, data\ico\letter_a.ico, data\ico\letter_a.ico
FileInstall, data\ico\message_out.ico, data\ico\message_out.ico
FileInstall, data\ico\message_star.ico, data\ico\message_star.ico
FileInstall, data\ico\movie.ico, data\ico\movie.ico
Progress, 50
FileInstall, data\ico\Pastej.ico, data\ico\Pastej.ico
FileInstall, data\ico\path.ico, data\ico\path.ico
FileInstall, data\ico\picture.ico, data\ico\picture.ico
FileInstall, data\ico\script.ico, data\ico\script.ico
FileInstall, data\ico\star.ico, data\ico\star.ico
FileInstall, data\ico\star_blue.ico, data\ico\star_blue.ico
Progress, 60
FileInstall, data\ico\std.ico, data\ico\std.ico
FileInstall, data\ico\text.ico, data\ico\text.ico
FileInstall, data\ico\text2.ico, data\ico\text2.ico
Progress, 70
FileInstall, data\ico\time.ico, data\ico\time.ico
FileInstall, data\ico\url.ico, data\ico\url.ico
Progress, 80
FileInstall, data\ico\url2.ico, data\ico\url2.ico
FileInstall, data\ico\web.ico, data\ico\web.ico
Progress, 90
FileInstall, data\ico\web_search.ico, data\ico\web_search.ico
FileInstall, data\ico\icons_from.txt, data\ico\icons_from.txt
; Non-icon files
FileInstall, data\license.txt, data\license.txt
FileInstall, data\pasties.ini, data\pasties.ini
Progress, Off
Traytip, Pastej:, Finished!, 4
Gosub, PostInstall
return

GuiNoInstall:
MsgBox, 48, Pastej cannot launch, Pastej cannot launch without its' required files. Please restart Pastej and extract the files if you wish to continue.
GuiClose:
Gosub, Exit
~Esc::
Exit:
ClipBoard := ClipBoardSaved
ExitApp

variableSafe(String)
{
	StringReplace, String, String, %A_Space%, _, All
	return String
}

variableUnsafe(String)
{
	StringReplace, String, String, _, %A_Space%, All
	return String
}

I downloaded and included ini.ahk in the same directory:
ini.ahk by Tuncay from http://www.autohotkey.com/forum/viewtopic.php?t=46226
I then clicked on the script, but received the following error message:
Error: Supported only for the tray menu and pointing to
Menu, PasteMenu, Icon, %A_LoopField%, %icon%,, 32
What am I doing wrong? :lol:

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Very sorry about that both of you. Bruno, I will make the requirements clearer: Your error messasge is because it requires AHK_L, and you run AHK normal. Chicken Pie 4 Tea: I will add an "always-running" mode asap, it is however intended to be ran with an applauncher like most of my other apps. I will also finish my applauncher as soon as possible, or atleast release a public early version to the community. You can hotkey an exe by creating a shortcut to it, then hotkeying the shortcut. Ugly workaround.

I am sorry, I should fix stuff like this before sharing, I bet.

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
oh it's fine I was just a bit puzzled and I am glad you say the script version need AHK_L as I also tried the script but it didnt work, now I know why.
"Choose your parents wisely"

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Looks good, I haven't tried it out yet.

From watching your video it looked like a strain to click a menu item, then have to find the Gui/inputbox on the screen. It would be good to have the Gui center about the mouse cursor.

Edit:
Ok, I downloaded the .exe and tried it. My general thoughts are it looks nice, but only works so-so. I never had a Gui/InputBox pop up to ask me about what I wanted to do. This means many of the commands were blank in their variable parts. Also, the program doesn't exit if you don't select an option. To avoid running many copies of the program (should I hold down the hotkey), I used RunWait instead of Run. This means when I open the program, then click outside the menu, the menu exits but the program doesn't.

Tested on Win 7, 64 bit.

PS: Take this is constructive-criticism.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

Looks good, I haven't tried it out yet.

From watching your video it looked like a strain to click a menu item, then have to find the Gui/inputbox on the screen. It would be good to have the Gui center about the mouse cursor.

Edit:
Ok, I downloaded the .exe and tried it. My general thoughts are it looks nice, but only works so-so. I never had a Gui/InputBox pop up to ask me about what I wanted to do. This means many of the commands were blank in their variable parts. Also, the program doesn't exit if you don't select an option. To avoid running many copies of the program (should I hold down the hotkey), I used RunWait instead of Run. This means when I open the program, then click outside the menu, the menu exits but the program doesn't.

Tested on Win 7, 64 bit.

PS: Take this is constructive-criticism.


Of course, thanks for trying it and providing the feedback. First issue is fixed, thanks for reminding me about the second one. Update will be posted within the hour.

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Alright everyone - updated and fully functional now - links in first post are updated. However, use the "AlwaysOn" mode at your own risk (you can only exit it safely from the traymenu "Exit"). I am not sure if I regret implementing it or not (maintaining support for both modes is a hassle if you programmed with one mode in mind), well it works now. Click the traybar or edit the PastejSettings.ini file manually to achieve AlwaysOn mode. I won't remove AlwaysOnmode until my applauncher is done and can deliver the best solution ™ for your problems.

Note to self: Make new video tomorrow. Current one is too long and boresome.

From watching your video it looked like a strain to click a menu item, then have to find the Gui/inputbox on the screen. It would be good to have the Gui center about the mouse cursor.


Two hints:
1) Menu items can be pressed by pressing the first letter of the item's name on your keyboard.
2) Inputboxes have automatic focus and pressing enter will submit them.

I just use the mouse more in demos to demonstrate more clearly. It's actually pretty simple, let's say you use #v to launch Pastej in your applauncher (or mine) and wanna create a link to an AHK command:

#v -> a -> "Return" -> {Enter}

Return

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009

Alright everyone - updated and fully functional now - links in first post are updated. However, use the "AlwaysOn" mode at your own risk (you can only exit it safely from the traymenu "Exit"). I am not sure if I regret implementing it or not (maintaining support for both modes is a hassle if you programmed with one mode in mind), well it works now.


Just leave it as original if you feel its better that way, dont change it just because one person was puzzled - I might just be incredibly stupid and everyone else is fine about it. :oops:
"Choose your parents wisely"