<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Быстрое обрамление текста]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6079&amp;type=atom" />
	<updated>2017-05-31T11:39:59Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6079</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Быстрое обрамление текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=116267#p116267" />
			<content type="html"><![CDATA[<p>В win7 x64 меню не захотело разделяться на колонки.<br />На форуме autohotkey.com нашел ответ.<br />В скрипте нужно поменять блок:</p><div class="codebox"><pre><code>
;  Create menu column
   MenuHandle := GetMenuHandle(&quot;mHTML&quot;)
   VarSetCapacity(mii,48,0),NumPut(48,mii)
   NumPut(0x100,mii,4) ; fMask = MIIM_FTYPE
   NumPut(0x20,mii,8)  ; fType = MFT_MENUBARBREAK
   DllCall(&quot;SetMenuItemInfo&quot;,&quot;uint&quot;,MenuHandle,&quot;uint&quot;,MenuBreakItem01,&quot;uint&quot;,1,&quot;uint&quot;,&amp;mii)
   DllCall(&quot;SetMenuItemInfo&quot;,&quot;uint&quot;,MenuHandle,&quot;uint&quot;,MenuBreakItem02,&quot;uint&quot;,1,&quot;uint&quot;,&amp;mii)
</code></pre></div><p>на:<br /></p><div class="codebox"><pre><code>
;  Create menu column
   MenuHandle := GetMenuHandle(&quot;mHTML&quot;)
   VarSetCapacity(mii, cb:=16+8*A_PtrSize, 0) ; A_PtrSize is used for 64-bit compatibility.
   NumPut(cb, mii, &quot;uint&quot;)
   NumPut(0x100, mii, 4, &quot;uint&quot;) ; fMask = MIIM_FTYPE
   NumPut(0x20, mii, 8, &quot;uint&quot;) ; fType = MFT_MENUBARBREAK
   DllCall(&quot;SetMenuItemInfo&quot;,&quot;ptr&quot;,MenuHandle,&quot;uint&quot;,MenuBreakItem01,&quot;int&quot;,1,&quot;ptr&quot;,&amp;mii)
   DllCall(&quot;SetMenuItemInfo&quot;,&quot;ptr&quot;,MenuHandle,&quot;uint&quot;,MenuBreakItem02,&quot;int&quot;,1,&quot;ptr&quot;,&amp;mii)
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[monsoon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=6758</uri>
			</author>
			<updated>2017-05-31T11:39:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=116267#p116267</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Быстрое обрамление текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=100016#p100016" />
			<content type="html"><![CDATA[<p>Скрипт напомнил утилиту SpecChar, которой раньше пользовался. Её минусы: нельзя было сделать обрамление текста тегами и у меня почему-то не вставлялись длинные составные теги, например, quote<br />Cкрипт <strong>DD</strong> хорош, но не устраивало, что он делает замену в буфере. Если текст не выделен и буфер не пуст, для меня лучше было бы вставлять теги. Ну и еще в SpecChar было несколько столбцов. </p><p>Попробовал переделать под себя. Вот так пока выглядит окно:<br /><span class="postimg"><img src="http://s1.bild.me/bilder/030315/4997178tegs.JPG" alt="http://s1.bild.me/bilder/030315/4997178tegs.JPG" /></span></p><p>Скрипт:<br /></p><div class="codebox"><pre><code>#SingleInstance force

^sc052::      ;Ctrl + Num 0

menuHTMLify =
(
«Франц. елочки»%A_Tab%Alt+0171/0187
«(&amp;c&amp;)»`t`t&amp;laquo;(&amp;c&amp;)&amp;raquo;
„Нем. лапки“%A_Tab%Alt+0132/0147
„(&amp;c&amp;)“`t`t&amp;bdquo;(&amp;c&amp;)&amp;ldquo;
“Англ. двойные”%A_Tab%Alt+0147/0148
“(&amp;c&amp;)”`t`t&amp;ldquo;(&amp;c&amp;)&amp;rdquo;
‘Англ. одинарные’%A_Tab%Alt+0145/0146
‘(&amp;c&amp;)’`t`t&amp;lsquo;(&amp;c&amp;)&amp;rsquo;
Ударение%A_Tab%́
́
Среднее тире%A_Tab%–
–
Длинное тире%A_Tab%—
—
Параграф%A_Tab%§   Alt+21
§
Градус%A_Tab%°
°
Символ пробела%A_Tab%(нижняя скобка)
␣
&amp;Bold
[b](&amp;c&amp;)[/b]`t`t&lt;b&gt;(&amp;c&amp;)&lt;/b&gt;
&amp;Italic
[i](&amp;c&amp;)[/i]`t`t&lt;i&gt;(&amp;c&amp;)&lt;/i&gt;
&lt;p&gt;
&lt;p&gt;(&amp;c&amp;)&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;
&lt;strong&gt;(&amp;c&amp;)&lt;/strong&gt;
&lt;pre&gt;
&lt;pre&gt;(&amp;c&amp;)&lt;/pre&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;(&amp;c&amp;)&lt;/blockquote&gt;
©
©
∞
∞
≈
≈
±
±
≠
≠
≤ / ≥
≤`t`t≥
×
×
÷
÷
√
√
∑
∑
) ; и прочая, и прочая, и прочая...

MenuBreakItem01:=10
MenuBreakItem02:=21

   ControlGetFocus, CurControl, A

   VarSetCapacity(SelStart, 4), VarSetCapacity(SelEnd, 4)
   SendMessage, 0xB0, &amp;SelStart, &amp;SelEnd, %CurControl%, A  ;EM_GETSEL

   SelStart := NumGet(SelStart), SelEnd := NumGet(SelEnd)

   ClipSave:=ClipboardAll     ; Save original clipboard 
   Clipboard =                ;   

   ; Send Ctrl+C, to copy selection to clipboard
   Send, {CTRL DOWN}{sc02E}{CTRL UP}  ;c
   Sleep 200   ; Wait to be sure there is something copied

;  Create a menu
   CreateMenu(&quot;mHTML&quot;, menuHTMLify, &quot;HTMLify&quot;)

;  Create menu column
   MenuHandle := GetMenuHandle(&quot;mHTML&quot;)
   VarSetCapacity(mii,48,0),NumPut(48,mii)
   NumPut(0x100,mii,4) ; fMask = MIIM_FTYPE
   NumPut(0x20,mii,8)  ; fType = MFT_MENUBARBREAK
   DllCall(&quot;SetMenuItemInfo&quot;,&quot;uint&quot;,MenuHandle,&quot;uint&quot;,MenuBreakItem01,&quot;uint&quot;,1,&quot;uint&quot;,&amp;mii)
   DllCall(&quot;SetMenuItemInfo&quot;,&quot;uint&quot;,MenuHandle,&quot;uint&quot;,MenuBreakItem02,&quot;uint&quot;,1,&quot;uint&quot;,&amp;mii)
   
   ; And show it
   Menu mHTML, Show

   Clipboard:=ClipSave
   
 ExitApp
Return

HTMLify:
   ; Go here when choosing a menu item
   RunMenuItem(menuHTMLify, A_ThisMenuItemPos)

   If (SelStart&gt;0 and SelStart!=SelEnd)
   {
     PostMessage, 0xB1, SelStart, SelStart + StrLen(Clipboard), %CurControl%, A   ; EM_SETSEL
     PostMessage, 0xB7,,, %CurControl%, A    ; EM_SCROLLCARET  
   }
Return

CreateMenu(_menuName, _menuDef, _menuLabel)
{
   Loop Parse, _menuDef, `n
   {
      If (Mod(A_Index, 2) = 1) ; Odd
        Menu %_menuName%, Add, %A_LoopField%, %_menuLabel%
   }
}

RunMenuItem(_menuDef, _index)
{
   Loop Parse, _menuDef, `n
   {
      If (_index * 2 = A_Index)
      {
         If GetKeyState(&quot;Shift&quot;)
         {
            html := A_LoopField
            html := RegExReplace(html, &quot;.*\t\t&quot;, &quot;$2&quot;)

            pos := 0
            If Clipboard =
              pos := StrLen(html)-Instr(html,&quot;(&amp;c&amp;)&quot;)-4

            StringReplace html, html, (&amp;c&amp;), %Clipboard%, All
            Clipboard := html

            Sleep 200   ; Wait to be sure there is something copied
            Send, {Ctrl Down}{sc02F}{Ctrl Up}  ;v
;           Send ^{vk56sc02F} ; Ctrl+V

            If (pos&gt;0)
              Send, {Left %pos%}

            Break
            Return
         }

         ; Get HTML
         html := A_LoopField
         html := RegExReplace(html, &quot;\t.*&quot;, &quot;$2&quot;)

         pos := 0
         If Clipboard =
           pos := StrLen(html)-Instr(html,&quot;(&amp;c&amp;)&quot;)-4

         ; Substitute special tag with clipboard content
         StringReplace html, html, (&amp;c&amp;), %Clipboard%, All
         ; Update the clipboard
         Clipboard := html

         Sleep 200   ; Wait to be sure there is something copied
         Send, {Ctrl Down}{sc02F}{Ctrl Up}  ;v
;         Send ^{vk56sc02F} ; Ctrl+V

         If (pos&gt;0)
           Send, {Left %pos%}

         Break
      }
   }
}

GetMenuHandle(menu_name) ;from MenuIcons v2
{
    static   h_menuDummy
    ; v2.2: Check for !h_menuDummy instead of h_menuDummy=&quot;&quot; in case init failed last time.
    If !h_menuDummy
    {
        Menu, menuDummy, Add
        Menu, menuDummy, DeleteAll

        Gui, 99:Menu, menuDummy
        ; v2.2: Use LastFound method instead of window title. [Thanks animeaime.]
        Gui, 99:+LastFound

        h_menuDummy := DllCall(&quot;GetMenu&quot;, &quot;uint&quot;, WinExist())

        Gui, 99:Menu
        Gui, 99:Destroy
       
        ; v2.2: Return only after cleaning up. [Thanks animeaime.]
        if !h_menuDummy
            return 0
    }

    Menu, menuDummy, Add, :%menu_name%
    h_menu := DllCall( &quot;GetSubMenu&quot;, &quot;uint&quot;, h_menuDummy, &quot;int&quot;, 0 )
    DllCall( &quot;RemoveMenu&quot;, &quot;uint&quot;, h_menuDummy, &quot;uint&quot;, 0, &quot;uint&quot;, 0x400 )
    Menu, menuDummy, Delete, :%menu_name%
   
    return h_menu
}
</code></pre></div><p>Итог отличается от указанного на скриншоте, т.к. пришлось поудалять примеры для тегов code, url, img&nbsp; и quote и не помогало обрамление текста тегами pre.<br />Для составного пункта меню вызов осуществляется при зажатом Shift, а не Ctrl, уже не помню почему переделал.<br />Если текст не выделен, то при вставке кавычек или двойного тега (открывающего и закрывающего) курсор устанавливается после открывающей кавычки (тега).<br />Если текст выделен и выбран одиночный тег или символ, он заместит выделенное.<br />После обрамления выделенного текста тегами, он снова выделяется уже с ними для случая, когда текст нужно обрамить несколькими тегами.<br />Еще хорошо было бы вынести содержимое меню в отдельный ini-файл, чтобы было проще пользоваться другим и как было в SpecChar, в нем добавить спецсимволы, указывающие, откуда начинать новый столбец. Но в этом не силен. Не знаю, как оно вообще заработало. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Может быть кто-то возьмется &quot;допилить&quot;.</p>]]></content>
			<author>
				<name><![CDATA[monsoon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=6758</uri>
			</author>
			<updated>2015-12-29T11:48:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=100016#p100016</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Быстрое обрамление текста]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=50333#p50333" />
			<content type="html"><![CDATA[<p>Скрипт <strong><a href="http://www.autohotkey.com/forum/topic12881.html&amp;highlight=menuhtmlify">PhiLho</a></strong> незабвенного.<br />Обрамляет выделенный или буферный текст чем угодно: кавычками, тегами, завитками, усиками... Не удержался, по старой привычке от того чтобы не добавить своей ложки... т.е., конечно же, капли мёда: при крепко зажатом Ctrl возможен дополнительный неоценимый сервис. Вот пример: клик по пункту меню — и выбранный текст запижонил в HTML тегах, с удержанным Ctrl — в тегах bbCode щеголяет.</p><div class="codebox"><pre><code>#SingleInstance force

menuHTMLify =
(
Франц. «елочки»%A_Tab%Alt+0171/0187
«(&amp;c&amp;)»`t`t&amp;laquo;(&amp;c&amp;)&amp;raquo;
Нем. „лапки“%A_Tab%Alt+0132/0147
„(&amp;c&amp;)“`t`t&amp;bdquo;(&amp;c&amp;)&amp;ldquo;
“Англ. двойные”%A_Tab%Alt+0147/0148
“(&amp;c&amp;)”`t`t&amp;ldquo;(&amp;c&amp;)&amp;rdquo;
‘Англ. одинарные’%A_Tab%Alt+0145/0146
‘(&amp;c&amp;)’`t`t&amp;lsquo;(&amp;c&amp;)&amp;rsquo;
&amp;Bold
&lt;b&gt;(&amp;c&amp;)&lt;/b&gt;`t`t[b](&amp;c&amp;)[/b]
&amp;Italic
&lt;i&gt;(&amp;c&amp;)&lt;/i&gt;`t`t[i](&amp;c&amp;)[/i]
) ; и прочая, и прочая, и прочая...





^sc052::        ;Ctrl + Num 0
QLinesMenu:
   ; Send Ctrl+C, to copy selection to clipboard
   Send, {CTRL DOWN}{sc02E}{CTRL UP}  ;c
   Sleep 200   ; Wait to be sure there is something copied
   If ErrorLevel
   {
      CoordMode, ToolTip, Screen
      ToolTip, !! Sorry, cannot copy the selection !!,0,0
      Sleep, 3000
      tooltip
      Return
   }
   ; Create a menu
   CreateMenu(&quot;mHTML&quot;, menuHTMLify, &quot;HTMLify&quot;)
   ; And show it
   Menu mHTML, Show
Return

HTMLify:
   ; Go here when choosing a menu item
   RunMenuItem(menuHTMLify, A_ThisMenuItemPos)
Return

CreateMenu(_menuName, _menuDef, _menuLabel)
{
   Loop Parse, _menuDef, `n
   {
      If (Mod(A_Index, 2) = 1) ; Odd
      {
         Menu %_menuName%, Add, %A_LoopField%, %_menuLabel%
      }
   }
}

RunMenuItem(_menuDef, _index)
{
   Loop Parse, _menuDef, `n
   {
      If (_index * 2 = A_Index)
      {

         If GetKeyState(&quot;Ctrl&quot;)
         {
            html := A_LoopField
            html := RegExReplace(html, &quot;.*\t\t&quot;, &quot;$2&quot;)
            StringReplace html, html, (&amp;c&amp;), %Clipboard%, All
            Clipboard := html
            Send, {Ctrl Down}{sc02F}{Ctrl Up}  ;v
            Break
            Return
         }

         ; Get HTML
         html := A_LoopField
         html := RegExReplace(html, &quot;\t.*&quot;, &quot;$2&quot;)
         ; Substitute special tag with clipboard content
         StringReplace html, html, (&amp;c&amp;), %Clipboard%, All
         ; Update the clipboard
         Clipboard := html
         Send, {Ctrl Down}{sc02F}{Ctrl Up}  ;v
         Break
      }
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-08-01T20:29:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=50333#p50333</id>
		</entry>
</feed>
