<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Правка распознанного теста в LibreOffice Writer]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15284&amp;type=atom" />
	<updated>2020-04-09T08:57:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15284</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138980#p138980" />
			<content type="html"><![CDATA[<p>Юзабельно получается) С обработкой областей и кареткой пока застрял, далеко не банально.<br /></p><div class="codebox"><pre><code>SetBatchLines, -1
#SingleInstance Force

pic_name_width := &quot;4&quot; 		; ширина счётчика в названиях изображений: 0001.jpg, 0002.jpg...
WidthOrNot := &quot;1&quot; 		; 0 — если названия изображений не имеют ширины: 1.jpg, 2.jpg...
pic_ext := &quot;tif&quot; 		; расширение изображений страниц
pic_pth := &quot;E:\SCANz\&quot;		; папка с изображениями страниц

oSM := ComObjCreate(&quot;com.sun.star.ServiceManager&quot;)

Gui, 2:-Caption +AlwaysOnTop +Resize +HWNDhWin  ;+Lastfound 
Gui, 2:Margin, 0, 0
Gui, 2:Add, Pic, h700 w600 vGuiPic, %pic_pth%%page%.%pic_ext%     ; x96 y20
Gui, 2:Font, s10 norm
OnMessage(0x201, &quot;WM_LBUTTONDOWN&quot;)
OnMessage(0x204, &quot;WM_RBUTTONDOWN&quot;)

loop
{
sleep 1

global pic_ext
global pic_pth
global WidthOrNot
global pic_name_width

If WinActive(&quot;ahk_exe soffice.bin&quot;)
{
   oDesk := oSM.createInstance(&quot;com.sun.star.frame.Desktop&quot;)

   page := oDesk.CurrentComponent.CurrentController.ViewCursor.getPage
   If WidthOrNot
      page := Format(&quot;{:0&quot; . pic_name_width . &quot;u}&quot;, page)

   if (oldpage != page) {
      oldpage := page
      oDesk.CurrentComponent.CurrentController.ViewSettings.ZoomType := 2
      Gui, 2:Show, NA
      GuiControl, 2:, GuiPic, %pic_pth%%page%.%pic_ext%
   }
}
else
   sleep 1000
}
return

WM_LBUTTONDOWN()
{
 WM_NCLBUTTONDOWN := 0xA1, HTCAPTION := 2
 PostMessage, WM_NCLBUTTONDOWN, HTCAPTION
}

WM_RBUTTONDOWN()
{
   Menu, Tray, NoStandard
   Menu, Tray, Add, Выход, ExitApp
   Menu, Tray, Show
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-09T08:57:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138980#p138980</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138977#p138977" />
			<content type="html"><![CDATA[<p>Можно прокручивать pgup, pgdwn и следить за кареткой:<br /></p><div class="codebox"><pre><code>setbatchlines -1
oSM := ComObjCreate(&quot;com.sun.star.ServiceManager&quot;)
oDesk := oSM.createInstance(&quot;com.sun.star.frame.Desktop&quot;)
loop
{
   page := oDesk.CurrentComponent.CurrentController.ViewCursor.getPage
   if (oldpage != page)
   {
      oldpage := page
      oDesk.CurrentComponent.CurrentController.ViewSettings.ZoomType := 2
   }
   sleep 1
} </code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-04-09T01:21:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138977#p138977</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138976#p138976" />
			<content type="html"><![CDATA[<p>Я понял, что вы сказали, надо попробовать.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T23:42:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138976#p138976</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138975#p138975" />
			<content type="html"><![CDATA[<p>По-моему, если страницы непрерывно прокручиваются — это уже нерешаемо. То есть, скрипт будет отрабатывать, будто на экране целая страница, хотя на экране будут две половины двух идущих одна за другой страниц, в разном размере. И поэтому в скрипте не пропишешь, что курсор стоит в первой половине второй страницы, или во второй половине первой страницы, потому что не опознается граница между двумя страницами. В «Файл-&gt;Просмотр печати» (Ctrl+Shift+O) есть нужная функция постраничной прокрутки, но там нет возможности замен.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T23:40:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138975#p138975</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138974#p138974" />
			<content type="html"><![CDATA[<p>Накладывайте события на перемещение курсора.<br />Если лень в это углубляться можете через ahk определять, что страница изменилась и посылать зум на всю страницу.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-04-08T22:51:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138974#p138974</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138973#p138973" />
			<content type="html"><![CDATA[<p>В этом случае страница впишется в экран вся, но при прокрутке (либо при использовании диалога поиска-замены) этот вид будет меняться и она не будет целиком видна — видна будет и часть другой страницы. Если бы прокрутка целиком сменяла страницу, тогда появилась бы возможность относительно экрана опознавать, куда относительно этой страницы поставлен курсор, чтобы вывести ту же увеличенную область на изображении страницы.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T22:21:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138973#p138973</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138972#p138972" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>Жаль, в LibreOffice нельзя настроить, чтобы страница всегда отображалась только целиком, без непрерывной прокрутки.</p></blockquote></div><div class="codebox"><pre><code>view-&gt;zoom-&gt;entire page</code></pre></div><p>?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-04-08T21:46:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138972#p138972</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138971#p138971" />
			<content type="html"><![CDATA[<p>Вот имеющийся код:<br /></p><div class="codebox"><pre><code>SetBatchLines, -1
#SingleInstance Force

pic_name_width := &quot;4&quot; 		; ширина счётчика в названиях изображений: 0001.jpg, 0002.jpg...
WidthOrNot := &quot;1&quot; 		; 0 — если названия изображений не имеют ширины: 1.jpg, 2.jpg...
pic_ext := &quot;tif&quot; 		; расширение изображений страниц
pic_pth := &quot;E:\SCANz\&quot;		; папка с изображениями страниц

oSM := ComObjCreate(&quot;com.sun.star.ServiceManager&quot;)

Gui, -Caption +AlwaysOnTop ;+Lastfound 
Gui, Margin, 0, 0
Gui, Add, Pic, h700 w600 vGuiPic, %pic_pth%%page%.%pic_ext%     ; x96 y20
OnMessage(0x201, &quot;WM_LBUTTONDOWN&quot;)

loop
{
sleep 30

global pic_ext
global pic_pth
global WidthOrNot
global pic_name_width

If WinActive(&quot;ahk_exe soffice.bin&quot;)
{
   oDesk := oSM.createInstance(&quot;com.sun.star.frame.Desktop&quot;)
   page := oDesk.CurrentComponent.CurrentController.frame.layoutmanager.getElement(&quot;private:resource/statusbar/statusbar&quot;).RealInterface.AccessibleContext.getAccessibleChild(0).Text

   page := RegExReplace(page, &quot;s)^[^\d]*(\d+) .*&quot;, &quot;$1&quot;)
   If WidthOrNot
      page := Format(&quot;{:0&quot; . pic_name_width . &quot;u}&quot;, page)
   ;tooltip %pic_pth%%page%.%pic_ext%

   If NOT (pg_tmp = page) {
      Gui, Show, NA
      GuiControl,, GuiPic, %pic_pth%%page%.%pic_ext%
      pg_tmp := page
   }
}
else
   sleep 1000
}
return

WM_LBUTTONDOWN()
{
 WM_NCLBUTTONDOWN := 0xA1, HTCAPTION := 2
 PostMessage, WM_NCLBUTTONDOWN, HTCAPTION
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T19:41:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138971#p138971</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138970#p138970" />
			<content type="html"><![CDATA[<p>Жаль, в LibreOffice нельзя настроить, чтобы страница всегда отображалась только целиком, без непрерывной прокрутки. Иначе можно было бы в зависимости от клика в определенной области экрана, показывать ту же часть на изображении страницы.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T19:28:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138970#p138970</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138966#p138966" />
			<content type="html"><![CDATA[<p>Так как у вас работает с 2 ошибками, то это<br /></p><div class="quotebox"><blockquote><p><strong>oArray</strong> := ComObjArray(0xC, 2) ;VT_VARIANT := 0xC<br />oDoc := oDesk.CurrentComponent(&quot;private:factory/<strong>simpress</strong>&quot;, &quot;_blank&quot;, 0, <strong>Array</strong>)</p></blockquote></div><p>можно заменить на это:<br /></p><div class="codebox"><pre><code>oDoc := oDesk.CurrentComponent()</code></pre></div><p>Да и нет смысла каждый раз новый ком объект создавать, достаточно будет так:<br /></p><div class="codebox"><pre><code>oSM := ComObjCreate(&quot;com.sun.star.ServiceManager&quot;)
oDesk := oSM.createInstance(&quot;com.sun.star.frame.Desktop&quot;)
f1:: msgbox % oDesk.CurrentComponent.CurrentController.frame.layoutmanager.getElement(&quot;private:resource/statusbar/statusbar&quot;).RealInterface.AccessibleContext.getAccessibleChild(0).Text</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-04-08T02:53:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138966#p138966</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138965#p138965" />
			<content type="html"><![CDATA[<p>А-а, вот оно, спасибо<br /></p><div class="codebox"><pre><code>1::
oSM := ComObjCreate(&quot;com.sun.star.ServiceManager&quot;)
oDesk := oSM.createInstance(&quot;com.sun.star.frame.Desktop&quot;)
oArray := ComObjArray(0xC, 2) ;VT_VARIANT := 0xC
oDoc := oDesk.CurrentComponent(&quot;private:factory/simpress&quot;, &quot;_blank&quot;, 0, Array)

msgbox % oDoc.CurrentController.frame.layoutmanager.getElement(&quot;private:resource/statusbar/statusbar&quot;).RealInterface.AccessibleContext.getAccessibleChild(0).Text
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T02:43:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138965#p138965</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138964#p138964" />
			<content type="html"><![CDATA[<p>Если вы внимательно почитаете примеры кодов по вашим же ссылкам, то поймете как подсоединяться к открытому документу.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-04-08T02:38:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138964#p138964</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138963#p138963" />
			<content type="html"><![CDATA[<p>Что-то наклевывается). Вот так получается создать/открыть новый документ и получить инфу о страницах, — а надо бы получать из уже открытого — <br /></p><div class="codebox"><pre><code>1::
oSM := ComObjCreate(&quot;com.sun.star.ServiceManager&quot;)
oDesk := oSM.createInstance(&quot;com.sun.star.frame.Desktop&quot;)
oArray := ComObjArray(0xC, 2) ;VT_VARIANT := 0xC
oDoc := oDesk.loadComponentFromURL(&quot;private:factory/swriter&quot;, &quot;_blank&quot;, 0, oArray)

msgbox % oDoc.CurrentController.frame.layoutmanager.getElement(&quot;private:resource/statusbar/statusbar&quot;).RealInterface.AccessibleContext.getAccessibleChild(0).Text
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-08T02:17:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138963#p138963</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138962#p138962" />
			<content type="html"><![CDATA[<p>Не то ищите. <br />Вам нужно получить объектную модель документа.<br />После чего получить нужную часть статус бара:<br /></p><div class="codebox"><pre><code>msgbox % oDoc.CurrentController.frame.layoutmanager.getElement(&quot;private:resource/statusbar/statusbar&quot;).RealInterface.AccessibleContext.getAccessibleChild(0).Text</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-04-08T01:46:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138962#p138962</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Правка распознанного теста в LibreOffice Writer]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138959#p138959" />
			<content type="html"><![CDATA[<p>Смотрел примеры работы с этим api:</p><p><a href="https://www.autohotkey.com/boards/viewtopic.php?f=76&amp;t=26570">https://www.autohotkey.com/boards/viewt … mp;t=26570</a><br /><a href="https://www.autohotkey.com/boards/viewtopic.php?f=76&amp;t=23885">https://www.autohotkey.com/boards/viewt … mp;t=23885</a></p><p>С <a href="https://api.libreoffice.org/docs/idl/ref/annotated.html">api.libreoffice.org</a> отобрал скорее всего относящиеся к номеру страницы команды:<br /></p><div class="codebox"><pre><code>sun::star::ui::dialogs::XWizardPage
sun::star::drawing::PageShape
sun::star::text::textfield</code></pre></div><p>которые в скрипте надо записывать через точку:<br /></p><div class="codebox"><pre><code>sun.star.ui.dialogs.XWizardPage
sun.star.drawing.PageShape
sun.star.text.textfield</code></pre></div><p>В итоге как запускать скрипт, чтобы в вывод попала активная страница?<br /></p><div class="codebox"><pre><code>1::
page := ComObjCreate(&quot;com.sun.star.drawing.PageShape&quot;)
MsgBox, % page
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2020-04-07T20:59:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138959#p138959</id>
		</entry>
</feed>
