<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15122</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15122&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: разделить слившиеся слова, при копировании с двух строк».]]></description>
		<lastBuildDate>Sun, 12 Jan 2020 14:26:45 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137244#p137244</link>
			<description><![CDATA[<p><strong>teadrinker</strong> отличная идея! Спасибо.</p><p>Сделал так.<br /></p><div class="codebox"><pre><code>var := clipboard
var1 := SubStr(var, 1, 5)
if RegExMatch(var1, &quot;[a-zA-Z]&quot;)
   lang := &quot;ru&quot;
else
  lang := &quot;en&quot; </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sun, 12 Jan 2020 14:26:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137244#p137244</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137243#p137243</link>
			<description><![CDATA[<p>Можно через RegEx проверять, есть ли в исходном тексте кириллица.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 12 Jan 2020 13:43:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137243#p137243</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137242#p137242</link>
			<description><![CDATA[<p><strong>teadrinker</strong> может вы знаете как можно определить язык скопированного текста?<br />Было бы здоров реализовать, чтобы в случае выбора русского текста переводило на английский, при выборе английского переводило на русский?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sun, 12 Jan 2020 13:42:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137242#p137242</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137233#p137233</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, понял, спасибо, буду использовать.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 11 Jan 2020 07:12:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137233#p137233</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137231#p137231</link>
			<description><![CDATA[<p>Первый вариант просто устаревший, они немного изменили форму запроса. По старому приходит неверный перевод.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 11 Jan 2020 00:16:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137231#p137231</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137230#p137230</link>
			<description><![CDATA[<p><strong>teadrinker</strong> Спасибо огромное!<br />Увидел разницу в строке<br /></p><div class="codebox"><pre><code>&quot;&amp;dt=at&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=qca&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;otf=1&amp;ssel=3&amp;tsel=3&amp;pc=1&amp;kc=2&quot;</code></pre></div><div class="codebox"><pre><code>. &quot;&amp;dt=at&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=qca&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;otf=0&amp;ssel=0&amp;tsel=0&amp;pc=1&amp;kc=1&quot;</code></pre></div><p>Очень интересно в чём фактическая разница в этих строках? Из-за неё Гугл терял частички отрицания?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Fri, 10 Jan 2020 23:32:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137230#p137230</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137223#p137223</link>
			<description><![CDATA[<div class="quotebox"><cite>OmTatSat пишет:</cite><blockquote><p>Но вообще у Google бывают странные моменты при переводе, когда он теряет отрицание и пишет утверждение.</p></blockquote></div><p>Замените:<br /></p><div class="codebox"><pre><code>SendRequest(JS, str, tl, sl, proxy) {
   ComObjError(false)
   http := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   ( proxy &amp;&amp; http.SetProxy(2, proxy) )
   http.open( &quot;POST&quot;, &quot;https://translate.google.com/translate_a/single?client=webapp&amp;sl=&quot;
      . sl . &quot;&amp;tl=&quot; . tl . &quot;&amp;hl=&quot; . tl
      . &quot;&amp;dt=at&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=qca&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;otf=0&amp;ssel=0&amp;tsel=0&amp;pc=1&amp;kc=1&quot;
      . &quot;&amp;tk=&quot; . JS.(&quot;tk&quot;).(str), 1 )

   http.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded;charset=utf-8&quot;)
   http.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0&quot;)
   http.send(&quot;q=&quot; . URIEncode(str))
   http.WaitForResponse(-1)
   Return http.responsetext
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 10 Jan 2020 15:44:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137223#p137223</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137222#p137222</link>
			<description><![CDATA[<p><strong>stealzy</strong>, тоже бывает так делаю. Но когда приходится много текстов перелопатить, то утомляет, на русском весь текст проще всё же.</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Fri, 10 Jan 2020 15:16:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137222#p137222</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137216#p137216</link>
			<description><![CDATA[<p><strong>stealzy</strong> Google тоже смог, только другую ссылку для перевода нужно использовать, я писал выше.<br />Но вообще у Google бывают странные моменты при переводе, когда он теряет отрицание и пишет утверждение. Типа если перевести оригинал должно быть &quot;...лечение не помогло...&quot; а Google иногда переводит &quot;...лечение помогло...&quot;. И это не слабо так мешает((. Благо знаю английский на уровне, при котором такие ляпы легко распознать.</p><p>Вы каким переводчиком пользуетесь? Как точность перевода?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Fri, 10 Jan 2020 13:20:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137216#p137216</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137202#p137202</link>
			<description><![CDATA[<p>Решил не заданный вопрос, но целевую задачу с переводом.<br />Заменой<br /></p><div class="codebox"><pre><code>http.open( &quot;POST&quot;, &quot;https://translate.google.com/translate_a/single?client=t&amp;sl=&quot;</code></pre></div><p>На<br /></p><div class="codebox"><pre><code>http.open( &quot;POST&quot;, &quot;https://translate.google.com/translate_a/single?client=webapp&amp;sl=&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Thu, 09 Jan 2020 16:30:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137202#p137202</guid>
		</item>
		<item>
			<title><![CDATA[AHK: разделить слившиеся слова, при копировании с двух строк]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=137201#p137201</link>
			<description><![CDATA[<p>Здравствуйте, пожалуйста помогите решить проблему.<br />Использую такой ahk переводчик.<br /></p><div class="codebox"><pre><code>#singleinstance force


~lButton &amp; RButton::
global xbut := 0
translate()
return

translate()
{
   ;ToolTip, xb %xbut%
   if xbut = 1
   {
     lang := &quot;en&quot; 
     ;xbut := 0
  }
  else
   lang := &quot;ru&quot;
   gui, destroy
	Gui +LastFound
KeyWait, lButton , u
sleep, 100
;send,{rbutton up}
;send,{lbutton up}
oCB := ClipboardAll ; save clipboard contents
Send, ^c
ClipWait,1
;ToolTip, %clipboard%
IfEqual, oCB, clipboard 
   Loop, 
   {
      Sleep, 100
      MsgBox, 1 - ==== `n %ClipboardAll% `n%clipboard%
    ToolTip, %ClipboardAll% = %clipboard% 1  
   }
until oCB != clipboard
;Send, ^c
 
;GoogleTranslate(Clipboard, &quot;auto&quot;, &quot;ru&quot;)
;MsgBox, %ClipboardAll% `n%clipboard%

global str
MsgBox, 1 - ==== `n %ClipboardAll% `n%clipboard%

t := GoogleTranslate(Clipboard, &quot;auto&quot;, lang)
if !t
   Loop, 5
   {
      Sleep, 1000
      t := GoogleTranslate(Clipboard, &quot;auto&quot;, lang)
      ;ToolTip, жду перевод
   }
until if t

Gui, Font, cFFFF00 s16 ;, Verdana
loop, parse, clipboard, `n, `r
max:=a_index

;msgbox,Total Characters=%a%
;msgbox %max%
if max &lt; 2
{
   Loop, Parse, clipboard
     a++
if a &lt; 100
   row := 1
if a &gt; 100
   row := 2
if a &gt; 200
   row := 2
if a &gt; 300
   row := 3
if a &gt; 400
   row := 4
if a &gt; 500
   row := 5 
if a &gt; 600
   row := 6
if a &gt; 700
   row := 7
if a &gt; 800
   row := 8
if a &gt; 900
   row := 9
Gui, Font, cFFFF00 s16 ;, Verdana
Gui, Add, Edit, vstr -E0x200  r%row%, %t% `n
 }
 else
{
   Gui, Font, cFFFF00 s16 ;, Verdana
   Gui, Add, Edit, vstr -E0x200  , %t% `n
}
 a :=
 row :=
sleep, 100


;Gui, Font, cFFFF00 s16, Verdana
Gui, Color, 000000, 000000
Gui, Add, Text,  x0 y0  0x9 gGuiMove  ; Use a picture control instead
;Gui Margin, 1000, 0




gui, show, AutoSize, Translit
Gui +LastFound 
WinSet, Transparent, 200
WinSet, ExStyle, ^0x80,
;WinSetTitle,test,,%a_space%
 ControlSend,,{left}, Translit
Gui,  +AlwaysOnTop +Resize + DPIScale -Caption -Border -SysMenu  -ToolWindow ;-0x400000
GuiSize:
If A_EventInfo = 1
Return
GuiControl Move, str, % &quot;H&quot; . (A_GuiHeight) . &quot; W&quot; . (A_GuiWidth)
;GuiControl Move, str1, % &quot;H&quot; . (A_GuiHeight) . &quot; W&quot; . (A_GuiWidth)
;sleep, 3000
ClipBoard := oCB ; return original Clipboard contents
return
}
return
;If ( Win_Class = &quot;Shell_TrayWnd&quot; OR Win_Class = &quot;ProgMan&quot; OR Win_Class = &quot;AltDesk1.x&quot; )
;#if !MouseIsOver(&quot;Translit&quot;)
;#IfWinExist, Translit

;( (MouseIsOver != &quot;Translit&quot;) AND (WinExist = &quot;Translit&quot;) )
#If WinExist(&quot;Translit&quot;) AND !MouseIsOver(&quot;Translit&quot;)
~lbutton::
{
if !MouseIsOver(&quot;Translit&quot;)
{
gui, destroy
return
}
}

#If WinExist(&quot;Translit&quot;)
XButton1::
;gui, destroy
global xbut := 1
translate()
return

#If WinExist(&quot;Translit&quot;) AND MouseIsOver(&quot;Translit&quot;)
rbutton::
gui, destroy
return

#If WinExist(&quot;Translit&quot;) AND MouseIsOver(&quot;Translit&quot;)
~mbutton::
if triger = 
{
gui, show, maximize, Translit
triger = 1
}
else
   {
gui, show, restore, Translit
triger = 
}
return


MouseIsOver(WinTitle) {
MouseGetPos, , , Win
return WinExist(WinTitle . &quot; ahk_id &quot; . Win)
}

GuiMove:

PostMessage, 0xA1, 2,,, A

Return





GoogleTranslate(str, from := &quot;auto&quot;, to := &quot;en&quot;)  {
   static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.(&quot;delete ActiveXObject; delete GetObject;&quot;)
   
   json := SendRequest(JS, str, to, from, proxy := &quot;&quot;)
   oJSON := JS.(&quot;(&quot; . json . &quot;)&quot;)

   if !IsObject(oJSON[1])  {
      Loop % oJSON[0].length
         trans .= oJSON[0][A_Index - 1][0]
   }
   else  {
      MainTransText := oJSON[0][0][0]
      Loop % oJSON[1].length  {
         trans .= &quot;`n+&quot;
         obj := oJSON[1][A_Index-1][1]
         Loop % obj.length  {
            txt := obj[A_Index - 1]
            trans .= (MainTransText = txt ? &quot;&quot; : &quot;`n&quot; txt)
         }
      }
   }
   if !IsObject(oJSON[1])
      MainTransText := trans := Trim(trans, &quot;,+`n &quot;)
   else
      trans := MainTransText . &quot;`n+`n&quot; . Trim(trans, &quot;,+`n &quot;)

   from := oJSON[2]
   trans := Trim(trans, &quot;,+`n &quot;)
   Return trans
}

SendRequest(JS, str, tl, sl, proxy) {
   ComObjError(false)
   http := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   ( proxy &amp;&amp; http.SetProxy(2, proxy) )
   http.open( &quot;POST&quot;, &quot;https://translate.google.com/translate_a/single?client=t&amp;sl=&quot;
      . sl . &quot;&amp;tl=&quot; . tl . &quot;&amp;hl=&quot; . tl
      . &quot;&amp;dt=at&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=qca&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;otf=1&amp;ssel=3&amp;tsel=3&amp;pc=1&amp;kc=2&quot;
      . &quot;&amp;tk=&quot; . JS.(&quot;tk&quot;).(str), 1 )

   http.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded;charset=utf-8&quot;)
   http.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0&quot;)
   http.send(&quot;q=&quot; . URIEncode(str))
   http.WaitForResponse(-1)
   Return http.responsetext
}

URIEncode(str, encoding := &quot;UTF-8&quot;)  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &amp;var, encoding)

   While code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)  {
      bool := (code &gt; 0x7F || code &lt; 0x30 || code = 0x3D)
      UrlStr .= bool ? &quot;%&quot; . Format(&quot;{:02X}&quot;, code) : Chr(code)
   }
   Return UrlStr
}

GetJScript()
{
   script =
   (
      var TKK = ((function() {
        var a = 561666268;
        var b = 1526272306;
        return 406398 + &#039;.&#039; + (a + b);
      })());

      function b(a, b) {
        for (var d = 0; d &lt; b.length - 2; d += 3) {
            var c = b.charAt(d + 2),
                c = &quot;a&quot; &lt;= c ? c.charCodeAt(0) - 87 : Number(c),
                c = &quot;+&quot; == b.charAt(d + 1) ? a &gt;&gt;&gt; c : a &lt;&lt; c;
            a = &quot;+&quot; == b.charAt(d) ? a + c &amp; 4294967295 : a ^ c
        }
        return a
      }

      function tk(a) {
          for (var e = TKK.split(&quot;.&quot;), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f &lt; a.length; f++) {
              var c = a.charCodeAt(f);
              128 &gt; c ? g[d++] = c : (2048 &gt; c ? g[d++] = c &gt;&gt; 6 | 192 : (55296 == (c &amp; 64512) &amp;&amp; f + 1 &lt; a.length &amp;&amp; 56320 == (a.charCodeAt(f + 1) &amp; 64512) ?
              (c = 65536 + ((c &amp; 1023) &lt;&lt; 10) + (a.charCodeAt(++f) &amp; 1023), g[d++] = c &gt;&gt; 18 | 240,
              g[d++] = c &gt;&gt; 12 &amp; 63 | 128) : g[d++] = c &gt;&gt; 12 | 224, g[d++] = c &gt;&gt; 6 &amp; 63 | 128), g[d++] = c &amp; 63 | 128)
          }
          a = h;
          for (d = 0; d &lt; g.length; d++) a += g[d], a = b(a, &quot;+-a^+6&quot;);
          a = b(a, &quot;+-3^+b+-f&quot;);
          a ^= Number(e[1]) || 0;
          0 &gt; a &amp;&amp; (a = (a &amp; 2147483647) + 2147483648);
          a `%= 1E6;
          return a.toString() + &quot;.&quot; + (a ^ h)
      }
   )
   Return script
}

CreateScriptObj() {
   static doc
   doc := ComObjCreate(&quot;htmlfile&quot;)
   doc.write(&quot;&lt;meta http-equiv=&#039;X-UA-Compatible&#039; content=&#039;IE=9&#039;&gt;&quot;)
   Return ObjBindMethod(doc.parentWindow, &quot;eval&quot;)
}

</code></pre></div><p>При переводе текста к примеру с этого документа https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5664031/pdf/foods-06-00092.pdf<br />В первом абзаце (и между стыком любого другого конца строки и начала следующей) при копировании текста имею &quot;...has <span style="color: red">receivedinterest</span> from both the medical/scientific...&quot;<br />Иногда гугл переводчик разъеденяет такие слившиеся слова, но также часто оставляет их слитыми - не переведенными.<br />Вопрос, как можно исправить такие слившиеся слова?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Thu, 09 Jan 2020 15:28:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=137201#p137201</guid>
		</item>
	</channel>
</rss>
