<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK (HelpToAHK_L): ShellFileOperation]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8155&amp;type=atom" />
	<updated>2013-03-18T13:02:22Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8155</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK (HelpToAHK_L): ShellFileOperation]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=70428#p70428" />
			<content type="html"><![CDATA[<p>Эврика:</p><div class="codebox"><pre><code>ShellFileOperation( fileO=0x0, fSource=&quot;&quot;, fTarget=&quot;&quot;, flags=0x0, ghwnd=0x0 )     
{
    
    If ( SubStr(fSource,0) != &quot;|&quot; )
        fSource := fSource . &quot;|&quot;

    If ( SubStr(fTarget,0) != &quot;|&quot; )
        fTarget := fTarget . &quot;|&quot;
    
    char_size := A_IsUnicode ? 2 : 1
    char_type := A_IsUnicode ? &quot;UShort&quot; : &quot;Char&quot;
    
    fsPtr := &amp;fSource
    Loop % StrLen(fSource)
        if NumGet(fSource, (A_Index-1)*char_size, char_type) = 124
            NumPut(0, fSource, (A_Index-1)*char_size, char_type)

    ftPtr := &amp;fTarget
    Loop % StrLen(fTarget)
        if NumGet(fTarget, (A_Index-1)*char_size, char_type) = 124
            NumPut(0, fTarget, (A_Index-1)*char_size, char_type)
    
    VarSetCapacity( SHFILEOPSTRUCT, 60, 0 )                 ; Encoding SHFILEOPSTRUCT
    NextOffset := NumPut( ghwnd, &amp;SHFILEOPSTRUCT )          ; hWnd of calling GUI
    NextOffset := NumPut( fileO, NextOffset+0    )          ; File operation
    NextOffset := NumPut( fsPtr, NextOffset+0    )          ; Source file / pattern
    NextOffset := NumPut( ftPtr, NextOffset+0    )          ; Target file / folder
    NextOffset := NumPut( flags, NextOffset+0, 0, &quot;Short&quot; ) ; options

    DllCall( &quot;Shell32\SHFileOperation&quot; . (A_IsUnicode ? &quot;W&quot; : &quot;A&quot;), UInt,&amp;SHFILEOPSTRUCT )
    
    Return NumGet( NextOffset+0 )
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2013-03-18T13:02:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=70428#p70428</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK (HelpToAHK_L): ShellFileOperation]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=70425#p70425" />
			<content type="html"><![CDATA[<p><strong>creature.ws</strong>, спасибо. Но хотелось бы приноровить первоначальный код к AHK_L, потому что при копировании там можно задействовать целый ряд возможностей (переменная &quot;flags&quot;). Кроме того на нём основывается скрипт, который пытаюсь &quot;оживить&quot;.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2013-03-18T10:29:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=70425#p70425</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK (HelpToAHK_L): ShellFileOperation]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=70424#p70424" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>^vk51::
    Clipboard := &quot;&quot;
    SendInput, {Ctrl Down}{vk43}{Ctrl Up}
    ClipWait

    loop parse, Clipboard, `n, `r
    {
        Splitpath A_LoopField, name
        dest := A_Desktop &quot;\&quot; name

        if InStr(FileExist(A_LoopField), &quot;D&quot;)
            FileCopyDir % A_LoopField, % dest
        else FileCopy % A_LoopField, % dest
    }
Return</code></pre></div><p>Использование DllCall делает решение любой задачи внушительнее.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-03-18T10:03:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=70424#p70424</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK (HelpToAHK_L): ShellFileOperation]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=70422#p70422" />
			<content type="html"><![CDATA[<p>Как раз забыл добавить вопрос: как оный DllCall() заставить копировать, на AHK_L он не работает.<br />По поводу посыла Ctrl+C согласен, использовал как пример, для удобства и краткости.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2013-03-18T08:49:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=70422#p70422</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK (HelpToAHK_L): ShellFileOperation]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=70416#p70416" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>По Ctrl+Q должен копировать выбранный файл на Рабочий.</p></blockquote></div><p>Должен, но не копирует. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Windows 7.</p><p>Потом, если уж используешь для копирования &quot;продвинутый&quot; DllCall(), то моветон получать выделенные файлы примитивным посылом Ctrl+C.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2013-03-17T22:33:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=70416#p70416</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK (HelpToAHK_L): ShellFileOperation]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=70412#p70412" />
			<content type="html"><![CDATA[<p>По Ctrl+Q должен копировать выбранный файл на Рабочий.</p><div class="codebox"><pre><code>
#SingleInstance force

TargetDir = %A_Desktop%\

^vk51::                                      ;Ctrl+Q
   clipboard =
   SendInput, {Ctrl Down}{vk43}{Ctrl Up}     ;Ctrl+C
   ClipWait

   GlobalFileList = %clipboard%

   flags := ( FOF_NOCONFIRMMKDIR := 0x200 ) | (FOF_NOCONFIRMATION := 0x10)
   Loop, parse, GlobalFileList, `r`n
   {
      if (A_LoopField &lt;&gt; &quot;&quot;)
      {
         ;MsgBox, Source %A_LoopField%, Target is %TargetDir%
         ShellFileOperation(0x2, A_LoopField, TargetDir, flags)
      }
   }
Return

ShellFileOperation( fileO=0x0, fSource=&quot;&quot;, fTarget=&quot;&quot;, flags=0x0, ghwnd=0x0 )     
{
 If ( SubStr(fSource,0) != &quot;|&quot; )
      fSource := fSource . &quot;|&quot;

 If ( SubStr(fTarget,0) != &quot;|&quot; )
      fTarget := fTarget . &quot;|&quot;

 fsPtr := &amp;fSource
 Loop, % StrLen(fSource)
  If ( *(fsPtr+(A_Index-1)) = 124 ) 
      DllCall( &quot;RtlFillMemory&quot;, UInt, fsPtr+(A_Index-1), Int,1, UChar,0 ) 

 ftPtr := &amp;fTarget
 Loop, % StrLen(fTarget)
  If ( *(ftPtr+(A_Index-1)) = 124 ) 
      DllCall( &quot;RtlFillMemory&quot;, UInt, ftPtr+(A_Index-1), Int,1, UChar,0 ) 

 VarSetCapacity( SHFILEOPSTRUCT, 30, 0 )                 ; Encoding SHFILEOPSTRUCT
 NextOffset := NumPut( ghwnd, &amp;SHFILEOPSTRUCT )          ; hWnd of calling GUI
 NextOffset := NumPut( fileO, NextOffset+0    )          ; File operation
 NextOffset := NumPut( fsPtr, NextOffset+0    )          ; Source file / pattern
 NextOffset := NumPut( ftPtr, NextOffset+0    )          ; Target file / folder
 NextOffset := NumPut( flags, NextOffset+0, 0, &quot;Short&quot; ) ; options

 DllCall( &quot;Shell32\SHFileOperationA&quot;, UInt,&amp;SHFILEOPSTRUCT )
 
Return NumGet( NextOffset+0 )
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2013-03-17T20:41:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=70412#p70412</id>
		</entry>
</feed>
