<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16691&amp;type=atom" />
	<updated>2021-10-28T16:00:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16691</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150280#p150280" />
			<content type="html"><![CDATA[<p>Вот теперь четко, спасибо! Код из #7 работает так как надо. Теперь попробую еще погонять его в разных окнах и условиях потом напишу, если будут шероховатости.</p>]]></content>
			<author>
				<name><![CDATA[alpap]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42081</uri>
			</author>
			<updated>2021-10-28T16:00:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150280#p150280</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150279#p150279" />
			<content type="html"><![CDATA[<p>Добавил к коду из #5 строку<br /></p><div class="codebox"><pre><code>
XButton1:: send {LCtrl Down}V{LCtrl Up}
</code></pre></div><p>теперь копирует объекты в том количестве сколько выделено, т.е. правильно, вставить по XButton1, естественно не получается и все также нет теперь работы с текстом.</p>]]></content>
			<author>
				<name><![CDATA[alpap]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42081</uri>
			</author>
			<updated>2021-10-28T15:56:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150279#p150279</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150278#p150278" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alpap пишет:</cite><blockquote><p>вставляется только один последний объект</p></blockquote></div><p>Так не должно быть, у меня вставляется всё выделенное.<br /></p><div class="quotebox"><cite>alpap пишет:</cite><blockquote><p>теперь не работает с текстом</p></blockquote></div><p>Чтобы работало и с файлами, и с текстом, можно так:<br /></p><div class="codebox"><pre><code>XButton2::
   if fileList := Explorer_GetSelection()
      PutFilesIntoClipboard(fileList)
   else
      Send ^c
   Return
XButton1:: Send ^v

Explorer_GetSelection() {
   WinGetClass, winClass, % &quot;ahk_id&quot; . hWnd := WinExist(&quot;A&quot;)
   if !(winClass ~= &quot;^(Progman|WorkerW|(Cabinet|Explore)WClass)$&quot;)
      Return
   
   shellWindows := ComObjCreate(&quot;Shell.Application&quot;).Windows
   if (winClass ~= &quot;Progman|WorkerW&quot;)  ; IShellWindows::Item:    https://goo.gl/ihW9Gm
                                       ; IShellFolderViewDual:   https://goo.gl/gnntq3
      shellFolderView := shellWindows.Item( ComObject(VT_UI4 := 0x13, SWC_DESKTOP := 0x8) ).Document
   else {
      for window in shellWindows       ; ShellFolderView object: https://is.gd/eyZ4zG
         if (hWnd = window.HWND) &amp;&amp; (shellFolderView := window.Document)
            break
   }
   for item in shellFolderView.SelectedItems
      result .= (result = &quot;&quot; ? &quot;&quot; : &quot;`n&quot;) . item.Path
   Return result
}

PutFilesIntoClipboard(fileList) {
   static GHND := 0x42, CF_HDROP := 0xF
   fileList := Trim( RegExReplace(fileList, &quot;\R&quot;, &quot;`n&quot;), &quot; `t`r`n&quot; ), RegExReplace(fileList, &quot;\R&quot;, &quot;&quot;, count)
   VarSetCapacity(DROPFILES, size := 20 + StrLen(fileList) + count + 2, 0)
   NumPut(20, DROPFILES)
   prevLen := 0
   Loop, parse, fileList, `n
      prevLen += StrPut(A_LoopField, &amp;DROPFILES + 20 + prevLen + A_Index - 1, StrLen(A_LoopField), &quot;CP0&quot;)
   hMem := DllCall(&quot;GlobalAlloc&quot;, &quot;UInt&quot;, GHND, &quot;Ptr&quot;, size, &quot;Ptr&quot;)
   pData := DllCall(&quot;GlobalLock&quot;, &quot;Ptr&quot;, hMem, &quot;Ptr&quot;)
   DllCall(&quot;RtlMoveMemory&quot;, &quot;Ptr&quot;, pData, &quot;Ptr&quot;, &amp;DROPFILES, &quot;Ptr&quot;, size)
   DllCall(&quot;GlobalUnlock&quot;, &quot;Ptr&quot;, hMem)
   DllCall(&quot;OpenClipboard&quot;, &quot;Ptr&quot;, 0)
   DllCall(&quot;SetClipboardData&quot;, &quot;UInt&quot;, CF_HDROP, &quot;Ptr&quot;, hMem)
   DllCall(&quot;CloseClipboard&quot;)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-10-28T15:52:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150278#p150278</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150277#p150277" />
			<content type="html"><![CDATA[<p>Так XButton2 копирует файлы и/или папки, но если вставить, то вставляется только один последний объект (выделяем &quot;aaa1&quot;, &quot;aaa2&quot;, копируем, вставляем в новое место, на выходе - только &quot;aaa2&quot;). И так включилась противоположная проблема - теперь не работает с текстом.</p>]]></content>
			<author>
				<name><![CDATA[alpap]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42081</uri>
			</author>
			<updated>2021-10-28T15:46:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150277#p150277</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150275#p150275" />
			<content type="html"><![CDATA[<p>Попробуйте так:<br /></p><div class="codebox"><pre><code>XButton2:: PutFilesIntoClipboard( Explorer_GetSelection() )

Explorer_GetSelection() {
   WinGetClass, winClass, % &quot;ahk_id&quot; . hWnd := WinExist(&quot;A&quot;)
   if !(winClass ~= &quot;^(Progman|WorkerW|(Cabinet|Explore)WClass)$&quot;)
      Return
   
   shellWindows := ComObjCreate(&quot;Shell.Application&quot;).Windows
   if (winClass ~= &quot;Progman|WorkerW&quot;)  ; IShellWindows::Item:    https://goo.gl/ihW9Gm
                                       ; IShellFolderViewDual:   https://goo.gl/gnntq3
      shellFolderView := shellWindows.Item( ComObject(VT_UI4 := 0x13, SWC_DESKTOP := 0x8) ).Document
   else {
      for window in shellWindows       ; ShellFolderView object: https://is.gd/eyZ4zG
         if (hWnd = window.HWND) &amp;&amp; (shellFolderView := window.Document)
            break
   }
   for item in shellFolderView.SelectedItems
      result .= (result = &quot;&quot; ? &quot;&quot; : &quot;`n&quot;) . item.Path
   Return result
}

PutFilesIntoClipboard(fileList) {
   static GHND := 0x42, CF_HDROP := 0xF
   fileList := Trim( RegExReplace(fileList, &quot;\R&quot;, &quot;`n&quot;), &quot; `t`r`n&quot; ), RegExReplace(fileList, &quot;\R&quot;, &quot;&quot;, count)
   VarSetCapacity(DROPFILES, size := 20 + StrLen(fileList) + count + 2, 0)
   NumPut(20, DROPFILES)
   prevLen := 0
   Loop, parse, fileList, `n
      prevLen += StrPut(A_LoopField, &amp;DROPFILES + 20 + prevLen + A_Index - 1, StrLen(A_LoopField), &quot;CP0&quot;)
   hMem := DllCall(&quot;GlobalAlloc&quot;, &quot;UInt&quot;, GHND, &quot;Ptr&quot;, size, &quot;Ptr&quot;)
   pData := DllCall(&quot;GlobalLock&quot;, &quot;Ptr&quot;, hMem, &quot;Ptr&quot;)
   DllCall(&quot;RtlMoveMemory&quot;, &quot;Ptr&quot;, pData, &quot;Ptr&quot;, &amp;DROPFILES, &quot;Ptr&quot;, size)
   DllCall(&quot;GlobalUnlock&quot;, &quot;Ptr&quot;, hMem)
   DllCall(&quot;OpenClipboard&quot;, &quot;Ptr&quot;, 0)
   DllCall(&quot;SetClipboardData&quot;, &quot;UInt&quot;, CF_HDROP, &quot;Ptr&quot;, hMem)
   DllCall(&quot;CloseClipboard&quot;)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-10-28T15:23:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150275#p150275</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150273#p150273" />
			<content type="html"><![CDATA[<p><strong>alpap</strong>, ознакомьтесь, пожалуйста, с <a href="https://forum.script-coding.com/misc.php?action=rules">правилами</a>, отредактируйте свой пост. Обратите внимание на заглавные <a href="https://forum.script-coding.com/misc.php?action=rules#literacy">буквы</a> в начале предложений.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-10-28T15:12:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150273#p150273</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150272#p150272" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>если назначать на другие горячие клавиши</p></blockquote></div><p>Я как-то и не подумал попробовать ...<br />Попробовал - то же самое, копировать-вставить с помощью назначенных горячих клавиш получается только текст.</p>]]></content>
			<author>
				<name><![CDATA[alpap]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42081</uri>
			</author>
			<updated>2021-10-28T15:10:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150272#p150272</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150271#p150271" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alpap пишет:</cite><blockquote><p>Copy, Paste, назначенные на боковые кнопки мыши не видят объекты</p></blockquote></div><p>То-есть, если назначать на другие горячие клавиши, то нет проблем?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-10-28T14:57:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150271#p150271</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Copy, Paste, назначенные на боковые кнопки мыши не видят объекты]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150267#p150267" />
			<content type="html"><![CDATA[<p>День добрый!<br />При использовании такого скрипта:<br /></p><div class="codebox"><pre><code>
XButton2:: send {LCtrl Down}C{LCtrl Up}
XButton1:: send {LCtrl Down}V{LCtrl Up}
</code></pre></div><p>Т.е. на горячие боковые клавиши (4 и 5) назначены стандартные клавиатурные Copy (Ctrl+C), Paste (Ctrl+V).<br />Это работает, но только с текстом.<br />А вот копировать-вставить файлы или папки - увы. Те же комбинации Copy (Ctrl+C), Paste (Ctrl+V), назначенные с помощью программы &quot;Key Manager&quot;, работают везде и как с текстом так и объектами.<br />Есть какой-то выход при использовании AHK в данном случае?</p>]]></content>
			<author>
				<name><![CDATA[alpap]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42081</uri>
			</author>
			<updated>2021-10-28T13:37:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150267#p150267</id>
		</entry>
</feed>
