<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7687&amp;type=atom" />
	<updated>2012-10-12T06:08:10Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7687</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64718#p64718" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Drugoy пишет:</cite><blockquote><p>Может добавить <a href="http://forum.script-coding.com/viewtopic.php?pid=64702#p64702">это</a> в коллекцию скриптов?</p></blockquote></div><p>1. Может быть. Я не могу об этом судить.<br />2. Предлагать сие имеет смысл непосредственно здесь, в теме.<br />3. Пользоваться ссылкой «Сообщить модератору» стоит по прямому назначению.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2012-10-12T06:08:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64718#p64718</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64709#p64709" />
			<content type="html"><![CDATA[<p>Спасибо огрррромнейшее!<br />Работает отлично.</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2012-10-11T15:01:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64709#p64709</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64702#p64702" />
			<content type="html"><![CDATA[<p>Поведение корректное. Ниже вариант подразумевающий активацию клавиши лишь если окно под курсором неактивно<br /></p><div class="codebox"><pre><code>#if !WinUnderMousePointerActive()
    !Lbutton::KDE_WinMove(&quot;Lbutton&quot;)
#if

WinUnderMousePointerActive()
{
    MouseGetPos,,, hWnd
    return WinActive(&quot;ahk_id&quot; hWnd)
}

KDE_WinMove(sButton)
{
    if !GetKeyState(sButton, &quot;P&quot;)
        Exit

    CoordMode, Mouse
    MouseGetPos, x1, y1, id
    WinExist(&quot;ahk_id&quot; . id)

    WinGetClass, winClass
    if (winClass == &quot;WorkerW&quot; || winClass == &quot;Progman&quot;)
        Exit

    WinGet, win, MinMax
    if (win)
        Exit

    SetWinDelay, 0
    WinGetPos, winX1, winY1
    while GetKeyState(sButton, &quot;P&quot;)
    {
        MouseGetPos, x2, y2
        x2 -= x1, y2 -= y1, winX2 := winX1 + x2, winY2 := winY1 + y2
        WinMove,,, winx2, winY2
        Sleep 15
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2012-10-11T10:31:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64702#p64702</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64701#p64701" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>creature.ws пишет:</cite><blockquote><p>Баг — это ведь «поведение обусловленное допущенной при разработке ошибкой», у вас баг в заголовке темы&nbsp; <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p></blockquote></div><p>Подправил.</p><div class="quotebox"><cite>creature.ws пишет:</cite><blockquote><p>Пример выше позволяет перемешать окна «за любую точку» при клике левой кнопкой с зажатым альт при последующем перемещении курсора при зажатой левой кнопке мыши.</p><p>Если нужно исключить возможность перемещения активных окон — достачно добавить проверку не является ли окно под курсором активным:</p></blockquote></div><p>Ммм, так намного лучше (активное окно не перемещается), но поведение всё равно не корректное: в браузере при зажатом ALT обычно можно выделять текст, а с этим скриптом - он в таком случае не выделяется.<br />Если это нельзя как-то победить, то можно, конечно, в скрипте сменить хоткей Alt на RAlt, а в браузере для выделения текста использовать левый Alt.</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2012-10-11T10:06:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64701#p64701</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64699#p64699" />
			<content type="html"><![CDATA[<p><span style="color: #008800"><strong>Drugoy</strong>, ознакомься с <a href="http://forum.script-coding.com/viewtopic.php?id=6148">этой</a> темой, отредактируй заголовок.</span></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-10-11T09:43:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64699#p64699</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64693#p64693" />
			<content type="html"><![CDATA[<p>Баг — это ведь «поведение обусловленное допущенной при разработке ошибкой», у вас баг в заголовке темы&nbsp; <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="codebox"><pre><code>; этот код в древности был утянут с оф форума.
!LButton::KDE_WinMove(&quot;LButton&quot;) ; при нажатии !Lbutton в потоке этой горячей клавиши происходит вызов процедуры KDE_WinMove с параметром «указывающем на левую кнопку мыши»

KDE_WinMove(sButton)
{
    if !GetKeyState(sButton, &quot;P&quot;) ; если посланная в качестве параметра клавиша или кнопка не нажаты выполнение подпрограммы завершается здесь.
        Exit

    SetWinDelay, 0
    CoordMode, Mouse
    MouseGetPos, x1, y1, id ; определяем координаты курсора и id окна под ним
    WinExist(&quot;ahk_id&quot; . id) ; осуществляем «поиск» этого окна чтоб установить lastfound window и не искать окно попусту в прочих командах.

    WinGetClass, winClass
    if (winClass == &quot;WorkerW&quot;) ; не пытаемся переместить рабочий стол
        Exit

    WinGet, win, MinMax ; не пытаемся переместить максимизированные окна
    if (win)
        Exit

    WinGetPos, winX1, winY1
    while GetKeyState(sButton, &quot;P&quot;) ; собственно таскаем окно при зажатой кнопке, имя которой послано данной процедуре в качестве параметра
    {
        MouseGetPos, x2, y2
        x2 -= x1, y2 -= y1, winX2 := winX1 + x2, winY2 := winY1 + y2
        WinMove,,, winx2, winY2
        Sleep 15
    }
}</code></pre></div><p>Пример выше позволяет перемешать окна «за любую точку» при клике левой кнопкой с зажатым альт при последующем перемещении курсора при зажатой левой кнопке мыши.</p><p>Если нужно исключить возможность перемещения активных окон — достачно добавить проверку не является ли окно под курсором активным:</p><div class="codebox"><pre><code>!LButton::KDE_WinMove(&quot;LButton&quot;)

KDE_WinMove(sButton)
{
    if !GetKeyState(sButton, &quot;P&quot;)
        Exit

    SetWinDelay, 0
    CoordMode, Mouse
    MouseGetPos, x1, y1, id
    WinExist(&quot;ahk_id&quot; . id)

    if WinActive() ; если найденное выше окно активно — выходим из подпрограммы горячей клавиши.
        Exit

    WinGetClass, winClass
    if (winClass == &quot;WorkerW&quot;)
        Exit

    WinGet, win, MinMax
    if (win)
        Exit

    WinGetPos, winX1, winY1
    while GetKeyState(sButton, &quot;P&quot;)
    {
        MouseGetPos, x2, y2
        x2 -= x1, y2 -= y1, winX2 := winX1 + x2, winY2 := winY1 + y2
        WinMove,,, winx2, winY2
        Sleep 15
    }
}</code></pre></div><p>Два последних блока кода в вашем примере — не используются. «Мёртвый груз»</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2012-10-11T01:22:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64693#p64693</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Исправить скрипт перемещения неактивных окон (hold alt&drag)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=64692#p64692" />
			<content type="html"><![CDATA[<p>Помогите, пожалуйста, с этим скриптом:<br /></p><div class="codebox"><pre><code>#SingleInstance,Force
SetWinDelay,0
SetBatchLines,-1
CoordMode,Mouse,Screen


!LButton::
MouseGetPos,oldmx,oldmy,mwin,mctrl

Loop
{
  GetKeyState,lbutton,LButton,P
  GetKeyState,alt,Alt,P
  If (lbutton=&quot;U&quot; Or alt=&quot;U&quot;)
    Break
  MouseGetPos,mx,my
  WinGetPos,wx,wy,ww,wh,ahk_id %mwin%
  wx:=wx+mx-oldmx
  wy:=wy+my-oldmy
  WinMove,ahk_id %mwin%,,%wx%,%wy%
  oldmx:=mx
  oldmy:=my
}
Return

99GuiClose:
  Gui,99:Destroy
  OnMessage(0x200,&quot;&quot;)
  DllCall(&quot;DestroyCursor&quot;,&quot;Uint&quot;,hCur)
Return

WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  If ctrl in Static9,Static13,Static17
    DllCall(&quot;SetCursor&quot;,&quot;UInt&quot;,hCurs)
  Return
}
Return</code></pre></div><p>Проблема заключается в том, что он срабатывает и для активного окна, а не должен бы.<br />Я наивно думал, что добавив #IfWinNotActive в начало скрипта - баг исчезнет, ан нет.<br />Также, я не очень понимаю суть последних двух блоков кода, поэтому боюсь, что сам не справлюсь и прошу помощи у вас: помогите, пожалуйста!</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2012-10-11T00:42:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=64692#p64692</id>
		</entry>
</feed>
