Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- S_Hotkey = ^+c
- f_sep = ~
- ; CONFIG: CHOOSE YOUR FAVORITES
- /*
- GENERIC <-- Do not change this string.
- <a> ~ <a href="@@">@@</a>
- $("# ")~$("#@@")
- $("#<`%= .ClientID `%>").val()~$("#<`%= @@.ClientID `%>").val()
- $(". ")~$(".@@")
- $(document)ready~$(document).ready(function(){`n @@`n });
- <div> ~ <div>`n@@`n</div>
- <ul> ~ <ul>`n@@`n</ul>
- <li> ~ <li>@@</li>
- <p>~<p>`n@@`n</p>
- <img />~<img src="<`%= ResolveUrl("~/images/@@")`%>" alt="@@" />
- <span>~<span>@@</span>
- <span green>~<span style="color:green;">@@</span>
- <blockquote>~<blockquote>@@</blockquote>
- <table>[and all that]</table>~<table>`n<tr>`n<td>`n@@`n</td>`n</tr>`n</table>
- <h1>~<h1>@@</h1>
- <h2>~<h2>@@</h2>
- <h3>~<h3>@@</h3>
- <h4>~<h4>@@</h4>
- <h5>~<h5>@@</h5>
- <b>~<b>@@</b>
- <i>~<i>@@</i>
- <strong>~<strong>@@</strong>
- <em>~<em>@@</em>
- " " ~ "@@"
- ' ' ~ '@@'
- <>~ <@@>
- ()~ (@@)
- {}~{@@}
- []~ [@@]
- <script>~<script type="text/javascript" src="@@"></script>
- <link>~<link type="text/css" href="@@" rel="StyleSheet" />
- /**/~ /*`n@@`n*/
- <!-- -->~<!--@@-->
- */
- /*
- CSHARP <-- Do not change this string.
- resolveURL~ResolveUrl("~/@@")
- " " ~ "@@"
- ' ' ~ '@@'
- <>~ <@@>
- ()~ (@@)
- {}~{@@}
- []~ [@@]
- Convert.ToInt32()~Convert.ToInt32(@@)
- try catch~ try{`n@@`n}catch(Exception Err){`n`n}
- foreach(...){}~foreach(@@){`n`n}
- foreach(){...}~foreach(){`n@@`n}
- if() ... else()~if()`n@@`nelse`n
- if(){...}else(){}~if(){`n@@`n}else{`n`n}
- #region~ #region regionName`n@@`n#endregion
- */
- /*
- ASPX <-- Do not change this string.
- <a> ~ <a href="@@">@@</a>
- $("# ")~$("#@@")
- $("#<`%= .ClientID `%>").val()~$("#<`%= @@.ClientID `%>").val()
- $(". ")~$(".@@")
- $(document)ready~$(document).ready(function(){`n @@`n });
- resolveURL~<`%= ResolveUrl("~/@@")`%>
- <div> ~ <div>`n@@`n</div>
- <ul> ~ <ul>`n@@`n</ul>
- <li> ~ <li>@@</li>
- <p>~<p>`n@@`n</p>
- <img />~<img src="<`%= ResolveUrl("~/images/@@")`%>" alt="@@" />
- <span>~<span>@@</span>
- <span green>~<span style="color:green;">@@</span>
- <blockquote>~<blockquote>@@</blockquote>
- <table>[and all that]</table>~<table>`n<tr>`n<td>`n@@`n</td>`n</tr>`n</table>
- <h1>~<h1>@@</h1>
- <h2>~<h2>@@</h2>
- <h3>~<h3>@@</h3>
- <h4>~<h4>@@</h4>
- <h5>~<h5>@@</h5>
- <b>~<b>@@</b>
- <i>~<i>@@</i>
- <strong>~<strong>@@</strong>
- <em>~<em>@@</em>
- <script>~<script type="text/javascript" src="@@"></script>
- <link>~<link type="text/css" href="@@" rel="StyleSheet" />
- " " ~ "@@"
- ' ' ~ '@@'
- <>~ <@@>
- ()~ (@@)
- {}~{@@}
- []~ [@@]
- <`%= `%>~<`%=@@`%>
- <`%= .ClientID `%>~<`%= @@.ClientID `%>
- /**/~ /*`n@@`n*/
- <!-- -->~<!--@@-->
- <`%/* */`%>~<`%/*`n@@`n */`%>
- */
- /*
- SQLSERVER <-- Do not change this string.
- CAST( as NVARCHAR(MAX))~CAST((@@) AS NVARCHAR(MAX))
- ISNULL((),'')~ISNULL((@@),'')
- ISNULL((),0)~ISNULL((@@),0)
- */
- ; END OF CONFIGURATION SECTION
- ; Do not make changes below this point unless you want to change
- ; the basic functionality of the script.
- #SingleInstance ; Needed since the hotkey is dynamically created.
- Hotkey, %S_Hotkey%, S_DisplayMenu
- StringLeft, S_HotkeyFirstChar, S_Hotkey, 1
- S_AlwaysShowMenu = y
- ; Used to reliably determine whether script is compiled:
- SplitPath, A_ScriptName,,, S_FileExt
- if S_FileExt = Exe ; Read the menu items from an external file.
- S_FavoritesFile = %A_ScriptDir%\Paster.ini
- else ; Read the menu items directly from this script file.
- S_FavoritesFile = %A_ScriptFullPath%
- ;----Read the configuration file.
- S_AtStartingPos = n
- S_MenuItemCount = 0
- Loop, Read, %S_FavoritesFile%
- {
- if S_FileExt <> Exe
- {
- if S_AtStartingPos = n
- {
- IfInString, A_LoopReadLine, GENERIC
- S_AtStartingPos = y
- continue
- }
- if A_LoopReadLine = */
- break
- }
- S_MenuItemCount++
- if A_LoopReadLine = ; Blank indicates a separator line.
- Menu, GENERIC, Add
- else
- {
- StringSplit, GS_line, A_LoopReadLine, %f_sep%
- GS_line1 = %GS_line1%
- GS_line2 = %GS_line2%
- Transform, GS_path%S_MenuItemCount%, deref, %GS_line2%
- Transform, GS_line1, deref, %GS_line1%
- Menu, GENERIC, Add, %GS_line1%, S_OpenGENERIC
- }
- }
- S_AtStartingPos = n
- S_MenuItemCount = 0
- Loop, Read, %S_FavoritesFile%
- {
- if S_FileExt <> Exe
- {
- if S_AtStartingPos = n
- {
- IfInString, A_LoopReadLine, CSHARP
- S_AtStartingPos = y
- continue
- }
- if A_LoopReadLine = */
- break
- }
- S_MenuItemCount++
- if A_LoopReadLine = ; Blank indicates a separator line.
- Menu, CSHARP, Add
- else
- {
- StringSplit, CS_line, A_LoopReadLine, `•
- CS_line1 = %CS_line1%
- CS_line2 = %CS_line2%
- Transform, CS_path%S_MenuItemCount%, deref, %CS_line2%
- Transform, CS_line1, deref, %CS_line1%
- Menu, CSHARP, Add, %CS_line1%, S_OpenCSHARP
- }
- }
- S_AtStartingPos = n
- S_MenuItemCount = 0
- Loop, Read, %S_FavoritesFile%
- {
- if S_FileExt <> Exe
- {
- if S_AtStartingPos = n
- {
- IfInString, A_LoopReadLine, ASPX
- S_AtStartingPos = y
- continue
- }
- if A_LoopReadLine = */
- break
- }
- S_MenuItemCount++
- if A_LoopReadLine = ; Blank indicates a separator line.
- Menu, ASPX, Add
- else
- {
- StringSplit, AS_line, A_LoopReadLine, `•
- AS_line1 = %AS_line1%
- AS_line2 = %AS_line2%
- Transform, AS_path%S_MenuItemCount%, deref, %AS_line2%
- Transform, AS_line1, deref, %AS_line1%
- Menu, ASPX, Add, %AS_line1%, S_OpenASPX
- }
- }
- S_AtStartingPos = n
- S_MenuItemCount = 0
- Loop, Read, %S_FavoritesFile%
- {
- if S_FileExt <> Exe
- {
- if S_AtStartingPos = n
- {
- IfInString, A_LoopReadLine, SQLSERVER
- S_AtStartingPos = y
- continue
- }
- if A_LoopReadLine = */
- break
- }
- S_MenuItemCount++
- if A_LoopReadLine = ; Blank indicates a separator line.
- Menu, SQLSERVER, Add
- else
- {
- StringSplit, SS_line, A_LoopReadLine, `•
- SS_line1 = %SS_line1% ; Trim leading and trailing spaces.
- SS_line2 = %SS_line2% ; Trim leading and trailing spaces.
- Transform, SS_path%S_MenuItemCount%, deref, %SS_line2%
- Transform, SS_line1, deref, %SS_line1%
- Menu, SQLSERVER, Add, %SS_line1%, S_OpenSQLSERVER
- }
- }
- return ;----End of auto-execute section.
- ;----Open the selected favorite
- S_OpenGENERIC:
- StringTrimLeft, GS_path, GS_path%A_ThisMenuItemPos%, 0
- if GS_path =
- return
- WinActivate, ahk_id %S_window_id% ; Because sometimes the mclick deactivates it.
- SetKeyDelay, 1 ; This will be in effect only for the duration of this thread.
- ClipSaved := ClipboardAll
- Send, ^c
- ClipWait, 2
- tempstring = %GS_path%
- StringReplace, tempstring, tempstring, @@, %clipboard%, All
- ClipBoard := tempstring
- Send, ^v
- ClipBoard := ClipSaved
- return
- S_OpenCSHARP:
- StringTrimLeft, CS_path, CS_path%A_ThisMenuItemPos%, 0
- if CS_path =
- return
- WinActivate, ahk_id %S_window_id% ; Because sometimes the mclick deactivates it.
- SetKeyDelay, 1 ; This will be in effect only for the duration of this thread.
- ClipSaved := ClipboardAll
- Send, ^c
- ClipWait, 2
- tempstring = %CS_path%
- StringReplace, tempstring, tempstring, @@, %clipboard%, All
- ClipBoard := tempstring
- Send, ^v
- ClipBoard := ClipSaved
- return
- S_OpenASPX:
- StringTrimLeft, AS_path, AS_path%A_ThisMenuItemPos%, 0
- if AS_path =
- return
- WinActivate, ahk_id %S_window_id% ; Because sometimes the mclick deactivates it.
- SetKeyDelay, 1 ; This will be in effect only for the duration of this thread.
- ClipSaved := ClipboardAll
- Send, ^c
- ClipWait, 2
- tempstring = %AS_path%
- StringReplace, tempstring, tempstring, @@, %clipboard%, All
- ClipBoard := tempstring
- Send, ^v
- ClipBoard := ClipSaved
- return
- S_OpenSQLSERVER:
- StringTrimLeft, SS_path, SS_path%A_ThisMenuItemPos%, 0
- if SS_path =
- return
- WinActivate, ahk_id %S_window_id% ; Because sometimes the mclick deactivates it.
- SetKeyDelay, 1 ; This will be in effect only for the duration of this thread.
- ClipSaved := ClipboardAll
- Send, ^c
- ClipWait, 2
- tempstring = %SS_path%
- StringReplace, tempstring, tempstring, @@, %clipboard%, All
- ClipBoard := tempstring
- Send, ^v
- ClipBoard := ClipSaved
- return
- ; Since the above didn't return, one of the following is true:
- ; 1) It's an unsupported window type but S_AlwaysShowMenu is y (yes).
- ; 2) It's a supported type but it lacks an Edit1 control to facilitate the custom
- ; action, so instead do the default action below.
- Run, Explorer %S_path% ; Might work on more systems without double quotes.
- return
- ;----Display the menu
- S_DisplayMenu:
- ; These first few variables are set here and used by S_OpenFavorite:
- WinGet, S_window_id, ID, A
- WinGetClass, S_class, ahk_id %S_window_id%
- if S_class in #32770,ExploreWClass,CabinetWClass ; Dialog or Explorer.
- ControlGetPos, S_Edit1Pos,,,, Edit1, ahk_id %S_window_id%
- if S_AlwaysShowMenu = n ; The menu should be shown only selectively.
- {
- if S_class in #32770,ExploreWClass,CabinetWClass ; Dialog or Explorer.
- {
- if S_Edit1Pos = ; The control doesn't exist, so don't display the menu
- return
- }
- else if S_class <> ConsoleWindowClass
- return ; Since it's some other window type, don't display menu.
- }
- ; Otherwise, the menu should be presented for this type of window:
- SetTitleMatchMode 2
- IfWinActive, .cs - Microsoft Visual Studio
- {
- Menu, CSHARP, show
- }
- else{
- IfWinActive, .aspx - Microsoft Visual Studio
- {
- Menu, ASPX, show
- }
- else{
- IfWinActive, .master - Microsoft Visual Studio
- {
- Menu, ASPX, show
- }
- else{
- IfWinActive, SQL Server Management Studio
- {
- Menu, SQLSERVER, show
- }
- else{
- IfWinActive, Remote Desktop
- {
- Menu, SQLSERVER, show
- }
- else{
- Menu, GENERIC, show
- }
- }
- }
- }
- }
- return
- #SingleInstance force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement