1

Тема: AHK: Открыть изображение, увеличить и получить координаты под курсором

Доброго времени суток!
Не могу сообразить, возможно ли на AHK сделать что-то типа своего приложения, в котором можно будет открывать  картинку, увеличивать-уменьшать(зум колекисом мыши)  и получать координаты картинки под курсором, а не координаты изображения на мониторе.
Заранее благодарю за любую помощь.

2

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Можно!

3

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Спасибо за надежду. Не могли бы в двух словах поделиться алгоритмом или ссылкой?

4

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Уточните, что значит

получать координаты картинки под курсором, а не координаты изображения на мониторе

? Как это связано со своим приложением, в котором будете открывать картинку?

5 (изменено: ser-bilichenko, 2018-01-08 00:17:18)

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Можно и сторонние приложения, но только для просмотра(без возможности редактирования и других лишних инструментов). Чтобы можно было увеличить в области курсора, а не по центру или сдвигая все в левый верхний угол. И последнее главное это координаты курсора именно относительно изображения, например если картинка 6000*4000, то если курсор в правом нижнем углу, то и значение должно быть это, а не значение относительно разрешения монитора. Самый близкий пример это гуглкарта - увеличивается под курсором и в URL отображает координаты, если кликнуть по карте.

6

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

stealzy пишет:

Написанный на ahk просмотрщик тоже есть.

Поделитесь, пожалуйста, ссылкой.

7

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

stealzy пишет:

XnView

Я не нашел, чтобы эта программа увеличивала область изображения под курсором.

8

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Возможно мы пользуемся разными версиями, но у меня всегда увеличивает по центру и только с клавиатуры.

9

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

stealzy, нужно вроде экранной лупы что ли?

10

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Есть такой пример, тут на "1" ставится пауза, после мышкой двигаем изображение, в центре зумируется.



	;	http://forum.script-coding.com/viewtopic.php?id=11447

#NoEnv
#SingleInstance Force
#KeyHistory 0
ListLines Off
SetBatchLines,-1
OnExit("ZoomOnClose")
Try Menu, Tray, Icon, Shell32, 23
OnMessage(0xF, "WM_Paint")
OnMessage(0x214, "WM_SIZING")
OnMessage(0x0020, "WM_SETCURSOR")
Global oZoom := {}

oZoom.Zoom := 4
oZoom.Mark := "Cross"		; Cross, Square, Grid, None

WinX := 1
WinY := 1
WinW := 300
WinH := 360

Gui, Zoom: +AlwaysOnTop +Resize -DPIScale +hwndhGui +LabelZoomOn
Gui, Zoom: Font, s12
Gui, Zoom: Color, F0F0F0
Gui, Zoom: Add, Slider, vSliderZoom gSliderZoom x8 Range1-50 w176 Center AltSubmit NoTicks, % oZoom.Zoom
Gui, Zoom: Add, Text, vTextZoom Center x+10 yp+3 w36, % oZoom.Zoom
Gui, Zoom: Font
Gui, Zoom: Add, Button, gChangeMark vChangeMark x+10 yp w52, % oZoom.Mark
Gui, Dev: +HWNDhDev -Caption -DPIScale +Parent%hGui%
Gui, Dev: Add, Pic, hwndhDevCon
Gui, Dev: Show, NA
Gui, Dev: Color, ffffff

; Gui, Zoom: Show, x%WinX% y%WinY% w%WinW% h%WinH%, Magnify
Gui, Zoom: Show, NA w%WinW% h%WinH%, Magnify
Gui, Zoom: +MinSize

oZoom.hdcSrc := DllCall("GetDC", "Ptr", 0)
oZoom.hdcDest := DllCall("GetDC", "Ptr", hDevCon, "Ptr")
oZoom.hdcMemory := DllCall("CreateCompatibleDC", "Ptr", 0)
DllCall("Gdi32.Dll\SetStretchBltMode", "Ptr", oZoom.hdcDest, "Int", 4)
oZoom.hGui := hGui
oZoom.hDev := hDev
oZoom.hDevCon := hDevCon
Return

#If !oZoom.Minimize

+Up::MouseStep(0, -1)
+Down::MouseStep(0, 1)
+Left::MouseStep(-1, 0)
+Right::MouseStep(1, 0)

^Up::
^DoWn::
WheelUp::
WheelDown::ChangeZoom(InStr(A_ThisHotKey, "DoWn") ? oZoom.Zoom + 1 : oZoom.Zoom - 1)

Pause::
1:: oZoom.Pause := !oZoom.Pause

#If

Magnify() {
	If (!oZoom.Pause && !oZoom.Minimize && !oZoom.Sizing)
	{
		MouseGetPos, , , WinID
		If (WinID != oZoom.hGui)
		{
			SetTimer, Memory, Off
			DllCall("GetCursorPos", "int64P", pt)
			oZoom.MouseX := pt << 32 >> 32, oZoom.MouseY := pt >> 32
			StretchBlt(oZoom.hdcDest, 0, 0, oZoom.nWidthDest, oZoom.nHeightDest
				, oZoom.hdcSrc, oZoom.MouseX - oZoom.nXOriginSrcOffset, oZoom.MouseY - oZoom.nYOriginSrcOffset, oZoom.nWidthSrc, oZoom.nHeightSrc)
			For k, v In oZoom.oMarkers[oZoom.Mark]
				StretchBlt(oZoom.hdcDest, v.x, v.y, v.w, v.h, oZoom.hdcDest, v.x, v.y, v.w, v.h, 0x5A0049)	; PATINVERT
			SetTimer, Memory, -30
		}
	}
	SetTimer, Magnify, -10
}

Memory() {
	SysGet, VirtualScreenX, 76
	SysGet, VirtualScreenY, 77
	SysGet, VirtualScreenWidth, 78
	SysGet, VirtualScreenHeight, 79
	oZoom.nXOriginSrc := oZoom.MouseX - VirtualScreenX, oZoom.nYOriginSrc := oZoom.MouseY - VirtualScreenY
	hBM := DllCall("Gdi32.Dll\CreateCompatibleBitmap", "Ptr", oZoom.hdcSrc, "Int", VirtualScreenWidth, "Int", VirtualScreenHeight)
	DllCall("Gdi32.Dll\SelectObject", "Ptr", oZoom.hdcMemory, "Ptr", hBM), DllCall("DeleteObject", "Ptr", hBM)
	BitBlt(oZoom.hdcMemory, 0, 0, VirtualScreenWidth, VirtualScreenHeight, oZoom.hdcSrc, VirtualScreenX, VirtualScreenY)
	oZoom.VirtualScreenWidth := VirtualScreenWidth, oZoom.VirtualScreenHeight := VirtualScreenHeight
}

Redraw() {
	StretchBlt(oZoom.hdcDest, 0, 0, oZoom.nWidthDest, oZoom.nHeightDest
		, oZoom.hdcMemory, oZoom.nXOriginSrc - oZoom.nXOriginSrcOffset, oZoom.nYOriginSrc - oZoom.nYOriginSrcOffset, oZoom.nWidthSrc, oZoom.nHeightSrc)
	For k, v In oZoom.oMarkers[oZoom.Mark]
		StretchBlt(oZoom.hdcDest, v.x, v.y, v.w, v.h, oZoom.hdcDest, v.x, v.y, v.w, v.h, 0x5A0049)	; PATINVERT
}

SetSize() {
	Critical
	Static Top := 60, Left := 0, Right := 0, Bottom := 0
	SetTimer, Magnify, Off
	GetClientPos(oZoom.hGui, GuiWidth, GuiHeight)
	Width := GuiWidth - Left - Right
	Height := GuiHeight - Top - Bottom
	Zoom := oZoom.Zoom
	conW := Mod(Width, Zoom) ? Width - Mod(Width, Zoom) + Zoom : Width
	conW := Mod(conW // Zoom, 2) ? conW : conW + Zoom
	conH := Mod(Height, Zoom) ? Height - Mod(Height, Zoom) + Zoom : Height
	conH := Mod(conH // Zoom, 2) ? conH : conH + Zoom
	conX := ((conW - Width) // 2) * -1
	conY := ((conH - Height) // 2) * -1

	oZoom.nWidthSrc := conW // Zoom
	oZoom.nHeightSrc := conH // Zoom
	oZoom.nXOriginSrcOffset := oZoom.nWidthSrc // 2
	oZoom.nYOriginSrcOffset := oZoom.nHeightSrc // 2
	oZoom.nWidthDest := nWidthDest := conW
	oZoom.nHeightDest := nHeightDest := conH
	xCenter := conW / 2 - Zoom / 2
	yCenter := conH / 2 - Zoom / 2

	oZoom.oMarkers["Cross"] := [{x:0,y:yCenter - 1,w:nWidthDest,h:1}
		, {x:0,y:yCenter + Zoom,w:nWidthDest,h:1}
		, {x:xCenter - 1,y:0,w:1,h:nHeightDest}
		, {x:xCenter + Zoom,y:0,w:1,h:nHeightDest}]

	oZoom.oMarkers["Square"] := [{x:xCenter - 1,y:yCenter,w:Zoom + 2,h:1}
		, {x:xCenter - 1,y:yCenter + Zoom + 1,w:Zoom + 2,h:1}
		, {x:xCenter - 1,y:yCenter + 1,w:1,h:Zoom}
		, {x:xCenter + Zoom,y:yCenter + 1,w:1,h:Zoom}]

	oZoom.oMarkers["Grid"] := Zoom = 1 ? oZoom.oMarkers["Square"]
		: [{x:xCenter - Zoom,y:yCenter - Zoom,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter + Zoom,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter + Zoom * 2,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter - Zoom,w:1,h:Zoom * 3}
		, {x:xCenter,y:yCenter - Zoom,w:1,h:Zoom * 3}
		, {x:xCenter + Zoom,y:yCenter - Zoom,w:1,h:Zoom * 3}
		, {x:xCenter + Zoom * 2,y:yCenter - Zoom,w:1,h:Zoom * 3}]

	SetWindowPos(oZoom.hDevCon, conX, conY, conW, conH)
	SetWindowPos(oZoom.hDev, Left, Top, Width, Height)
	Redraw()
	SetTimer, Magnify, -10
}

SetWindowPos(hWnd, x, y, w, h) {
	Static SWP_ASYNCWINDOWPOS := 0x4000, SWP_DEFERERASE := 0x2000, SWP_NOACTIVATE := 0x0010, SWP_NOCOPYBITS := 0x0100
		, SWP_NOOWNERZORDER := 0x0200, SWP_NOREDRAW := 0x0008, SWP_NOSENDCHANGING := 0x0400
		, uFlags := SWP_ASYNCWINDOWPOS|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOOWNERZORDER|SWP_NOREDRAW|SWP_NOSENDCHANGING
	DllCall("SetWindowPos"
		, "Ptr", hWnd
		, "Ptr", 0
		, "Int", x
		, "Int", y
		, "Int", w
		, "Int", h
		, "UInt", uFlags)
}

ZoomOnSize() {
	If A_EventInfo != 1
	{
		oZoom.Minimize := 0
		SetTimer, SetSize, -10
	}
	Else
		oZoom.Minimize := 1
}

SliderZoom() {
	GuiControlGet, SliderZoom, Zoom:
	ChangeZoom(SliderZoom)
}

ChangeZoom(Val) {
	If (Val < 1 || Val > 50)
		Return
	SetTimer, Magnify, Off
	GuiControl, Zoom:, TextZoom, % oZoom.Zoom := Val
	If A_GuiControl =
		GuiControl, Zoom:, SliderZoom, % oZoom.Zoom
	SetTimer, SetSize, -10
}

ChangeMark() {
	oZoom.Mark := ["Cross","Square","Grid","None"][{"Cross":2,"Square":3,"Grid":4,"None":1}[oZoom.Mark]]
	GuiControl, Zoom:, ChangeMark, % oZoom.Mark
	Redraw()
}

ZoomOnClose() {
	ZoomOnEscape:
		DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcDest)
		DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcSrc)
		DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcMemory)
		RestoreCursors()
		ExitApp
}

GetClientPos(hwnd, ByRef W, ByRef H)  {
	VarSetCapacity(pwi, 60, 0), NumPut(60, pwi, 0, "UInt")
	DllCall("GetWindowInfo", "Ptr", hwnd, "UInt", &pwi)
	W := NumGet(pwi, 28, "Int") - NumGet(pwi, 20, "Int")
	H := NumGet(pwi, 32, "Int") - NumGet(pwi, 24, "Int")
}

WM_Paint() {
	If A_GuiControl =
		SetTimer, Redraw, -30
}

WM_SIZING() {
	SetTimer, Magnify, Off
	oZoom.Sizing := 1
	SetTimer, NoSizing, 10
}

NoSizing() {
	If GetKeyState("LButton", "P")
		Return
	oZoom.Sizing := 0
	SetTimer, NoSizing, Off
	SetTimer, Magnify, -10
}

BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster = 0xC000CA) {
	Return DllCall("Gdi32.Dll\BitBlt"
		, "Ptr", dDC
		, "Int", dx
		, "Int", dy
		, "Int", dw
		, "Int", dh
		, "Ptr", sDC
		, "Int", sx
		, "Int", sy
		, "Uint", Raster)
}

StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster = 0xC000CA) {
	Return DllCall("Gdi32.Dll\StretchBlt"
		, "Ptr", dDC
		, "Int", dx
		, "Int", dy
		, "Int", dw
		, "Int", dh
		, "Ptr", sDC
		, "Int", sx
		, "Int", sy
		, "Int", sw
		, "Int", sh
		, "Uint", Raster|0x40000000)
}

	; _________________________________________________ MoveHand _________________________________________________

WM_SETCURSOR(W, L, M, H) {
	If (oZoom.SIZING)
		Return
	If (oZoom.Pause && W = oZoom.hDev && GetKeyState("LButton", "P"))
	{
		SetTimer, Hand, -1
		Return oZoom.SIZING := 1
	}
}

Hand() {
	SetTimer, Magnify, Off
	DllCall("GetCursorPos", "int64P", pt)
	oZoom.MoveHandX := pt << 32 >> 32, oZoom.MoveHandY := pt >> 32
	oZoom.MoveXSrc := oZoom.nXOriginSrc, oZoom.MoveYSrc := oZoom.nYOriginSrc
	SetSystemCursor("HAND")
	SetTimer, MoveHand, 10
	KeyWait, LButton
	SetTimer, MoveHand, Off
	RestoreCursors()
	oZoom.SIZING := 0
	SetTimer, Magnify, -10
}

MoveHand() {
	Static PrnXOriginSrc, PrnYOriginSrc
	PrnXOriginSrc := oZoom.nXOriginSrc
	PrnYOriginSrc := oZoom.nYOriginSrc
	DllCall("GetCursorPos", "int64P", pt)
	MouseX := pt << 32 >> 32, MouseY := pt >> 32
	XOdds := oZoom.MoveHandX - MouseX
	XOff := XOdds > 0 ? Floor(XOdds / oZoom.Zoom) : Ceil(XOdds / oZoom.Zoom)
	oZoom.nXOriginSrc := oZoom.MoveXSrc + XOff
	YOdds := oZoom.MoveHandY - MouseY
	YOff := YOdds > 0 ? Floor(YOdds / oZoom.Zoom) : Ceil(YOdds / oZoom.Zoom)
	oZoom.nYOriginSrc := oZoom.MoveYSrc + YOff
	If (PrnXOriginSrc <> oZoom.nXOriginSrc || PrnYOriginSrc <> oZoom.nYOriginSrc)
		LimitsOriginSrc(), Redraw()
}

MoveStep(StepX, StepY) {
	oZoom.nXOriginSrc += StepX
	oZoom.nYOriginSrc += StepY
	LimitsOriginSrc(), Redraw()
}

LimitsOriginSrc() {
	X := oZoom.nXOriginSrc
	oZoom.nXOriginSrc := X < 0 ? 0 : X > oZoom.VirtualScreenWidth - 1 ? oZoom.VirtualScreenWidth - 1 : X
	Y := oZoom.nYOriginSrc
	oZoom.nYOriginSrc := Y < 0 ? 0 : Y > oZoom.VirtualScreenHeight - 1 ? oZoom.VirtualScreenHeight - 1 : Y
}

MouseStep(x, y) {
	If !oZoom.Pause
		MouseMove, x, y, 0, R
	Else
		MoveStep(x, y)
}

SetSystemCursor(CursorName, cx = 0, cy = 0) {
	Static SystemCursors := {ARROW:32512, IBEAM:32513, WAIT:32514, CROSS:32515, UPARROW:32516, SIZE:32640, ICON:32641, SIZENWSE:32642
					, SIZENESW:32643, SIZEWE:32644 ,SIZENS:32645, SIZEALL:32646, NO:32648, HAND:32649, APPSTARTING:32650, HELP:32651}
    Local CursorHandle, hImage, Name, ID
	If (CursorHandle := DllCall("LoadCursor", Uint, 0, Int, SystemCursors[CursorName]))
		For Name, ID in SystemCursors
			hImage := DllCall("CopyImage", Ptr, CursorHandle, Uint, 0x2, Int, cx, Int, cy, Uint, 0)
			, DllCall("SetSystemCursor", Ptr, hImage, Int, ID)
}

RestoreCursors() {
	Static SPI_SETCURSORS := 0x57
	DllCall("SystemParametersInfo", UInt, SPI_SETCURSORS, UInt, 0, UInt, 0, UInt, 0)
}


По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

11

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Извините, но я не могу найти откуда загружается картинка.

12

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

ypppu, в идеале нужно повторить интерфейс гуглкарты, в том плане, что можно увеличить любое место и получить координаты любой точки при любом зуме, кликнув по изображению.

13

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

ser-bilichenko пишет:

Извините, но я не могу найти откуда загружается картинка.

С экрана.

По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

14

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

ser-bilichenko, так это программа Paint умеет.

15 (изменено: ser-bilichenko, 2018-01-08 13:14:50)

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Да именно почти как Paint, но Paint увеличивает всегда левый верхний угол и всегда активирован какой-то инструмент. Можно порисовать или стереть часть картинки. А вот с извлечением координат в StatusBar справляется идеально.

16 (изменено: serzh82saratov, 2018-01-08 13:39:38)

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Считайте что экран это картинка, после паузы можете её двигать. Вместо экрана можно и картинку открывать, используя GDI+.
Вот с координатами.


	;	http://forum.script-coding.com/viewtopic.php?id=11447

#NoEnv
#SingleInstance Force
#KeyHistory 0
ListLines Off
SetBatchLines,-1
OnExit("ZoomOnClose")
Try Menu, Tray, Icon, Shell32, 23
OnMessage(0xF, "WM_Paint")
OnMessage(0x214, "WM_SIZING")
OnMessage(0x0020, "WM_SETCURSOR")
Global oZoom := {}

oZoom.Zoom := 4
oZoom.Mark := "Cross"		; Cross, Square, Grid, None

WinX := 1
WinY := 1
WinW := 300
WinH := 360

Gui, Zoom: +AlwaysOnTop +Resize -DPIScale +hwndhGui +LabelZoomOn
Gui, Zoom: Font, s12
Gui, Zoom: Color, F0F0F0
Gui, Zoom: Add, Slider, vSliderZoom gSliderZoom x8 Range1-50 w176 Center AltSubmit NoTicks, % oZoom.Zoom
Gui, Zoom: Add, Text, vTextZoom Center x+10 yp+3 w36, % oZoom.Zoom
Gui, Zoom: Font
Gui, Zoom: Add, Button, gChangeMark vChangeMark x+10 yp w52, % oZoom.Mark
Gui, Dev: +HWNDhDev -Caption -DPIScale +Parent%hGui%
Gui, Dev: Add, Pic, hwndhDevCon
Gui, Dev: Show, NA
Gui, Dev: Color, ffffff

; Gui, Zoom: Show, x%WinX% y%WinY% w%WinW% h%WinH%, Magnify
Gui, Zoom: Show, NA w%WinW% h%WinH%, Magnify
Gui, Zoom: +MinSize

oZoom.hdcSrc := DllCall("GetDC", "Ptr", 0)
oZoom.hdcDest := DllCall("GetDC", "Ptr", hDevCon, "Ptr")
oZoom.hdcMemory := DllCall("CreateCompatibleDC", "Ptr", 0)
DllCall("Gdi32.Dll\SetStretchBltMode", "Ptr", oZoom.hdcDest, "Int", 4)
oZoom.hGui := hGui
oZoom.hDev := hDev
oZoom.hDevCon := hDevCon
Return

#If !oZoom.Minimize

+Up::MouseStep(0, -1)
+Down::MouseStep(0, 1)
+Left::MouseStep(-1, 0)
+Right::MouseStep(1, 0)

#If oZoom.Pause
^Up::
^DoWn::
WheelUp::
WheelDown::ChangeZoom(InStr(A_ThisHotKey, "DoWn") ? oZoom.Zoom + 1 : oZoom.Zoom - 1)
#If

Pause::
1:: oZoom.Pause := !oZoom.Pause

#If

Magnify() {
	If (!oZoom.Pause && !oZoom.Minimize && !oZoom.Sizing)
	{
		MouseGetPos, , , WinID
		If (WinID != oZoom.hGui)
		{
			SetTimer, Memory, Off
			DllCall("GetCursorPos", "int64P", pt)
			oZoom.MouseX := pt << 32 >> 32, oZoom.MouseY := pt >> 32
			StretchBlt(oZoom.hdcDest, 0, 0, oZoom.nWidthDest, oZoom.nHeightDest
				, oZoom.hdcSrc, oZoom.MouseX - oZoom.nXOriginSrcOffset, oZoom.MouseY - oZoom.nYOriginSrcOffset, oZoom.nWidthSrc, oZoom.nHeightSrc)
			For k, v In oZoom.oMarkers[oZoom.Mark]
				StretchBlt(oZoom.hdcDest, v.x, v.y, v.w, v.h, oZoom.hdcDest, v.x, v.y, v.w, v.h, 0x5A0049)	; PATINVERT
			Gui, Zoom: Show, NA, % "Magnify   x" oZoom.MouseX + 1 " y" oZoom.MouseY + 1
			SetTimer, Memory, -30
		}
	}
	SetTimer, Magnify, -10
}

Memory() {
	SysGet, VirtualScreenX, 76
	SysGet, VirtualScreenY, 77
	SysGet, VirtualScreenWidth, 78
	SysGet, VirtualScreenHeight, 79
	oZoom.nXOriginSrc := oZoom.MouseX - VirtualScreenX, oZoom.nYOriginSrc := oZoom.MouseY - VirtualScreenY
	hBM := DllCall("Gdi32.Dll\CreateCompatibleBitmap", "Ptr", oZoom.hdcSrc, "Int", VirtualScreenWidth, "Int", VirtualScreenHeight)
	DllCall("Gdi32.Dll\SelectObject", "Ptr", oZoom.hdcMemory, "Ptr", hBM), DllCall("DeleteObject", "Ptr", hBM)
	BitBlt(oZoom.hdcMemory, 0, 0, VirtualScreenWidth, VirtualScreenHeight, oZoom.hdcSrc, VirtualScreenX, VirtualScreenY)
	oZoom.VirtualScreenWidth := VirtualScreenWidth, oZoom.VirtualScreenHeight := VirtualScreenHeight
}

Redraw() {
	StretchBlt(oZoom.hdcDest, 0, 0, oZoom.nWidthDest, oZoom.nHeightDest
		, oZoom.hdcMemory, oZoom.nXOriginSrc - oZoom.nXOriginSrcOffset, oZoom.nYOriginSrc - oZoom.nYOriginSrcOffset, oZoom.nWidthSrc, oZoom.nHeightSrc)
	For k, v In oZoom.oMarkers[oZoom.Mark]
		StretchBlt(oZoom.hdcDest, v.x, v.y, v.w, v.h, oZoom.hdcDest, v.x, v.y, v.w, v.h, 0x5A0049)	; PATINVERT
}

SetSize() {
	Critical
	Static Top := 60, Left := 0, Right := 0, Bottom := 0
	SetTimer, Magnify, Off
	GetClientPos(oZoom.hGui, GuiWidth, GuiHeight)
	Width := GuiWidth - Left - Right
	Height := GuiHeight - Top - Bottom
	Zoom := oZoom.Zoom
	conW := Mod(Width, Zoom) ? Width - Mod(Width, Zoom) + Zoom : Width
	conW := Mod(conW // Zoom, 2) ? conW : conW + Zoom
	conH := Mod(Height, Zoom) ? Height - Mod(Height, Zoom) + Zoom : Height
	conH := Mod(conH // Zoom, 2) ? conH : conH + Zoom
	conX := ((conW - Width) // 2) * -1
	conY := ((conH - Height) // 2) * -1

	oZoom.nWidthSrc := conW // Zoom
	oZoom.nHeightSrc := conH // Zoom
	oZoom.nXOriginSrcOffset := oZoom.nWidthSrc // 2
	oZoom.nYOriginSrcOffset := oZoom.nHeightSrc // 2
	oZoom.nWidthDest := nWidthDest := conW
	oZoom.nHeightDest := nHeightDest := conH
	xCenter := conW / 2 - Zoom / 2
	yCenter := conH / 2 - Zoom / 2

	oZoom.oMarkers["Cross"] := [{x:0,y:yCenter - 1,w:nWidthDest,h:1}
		, {x:0,y:yCenter + Zoom,w:nWidthDest,h:1}
		, {x:xCenter - 1,y:0,w:1,h:nHeightDest}
		, {x:xCenter + Zoom,y:0,w:1,h:nHeightDest}]

	oZoom.oMarkers["Square"] := [{x:xCenter - 1,y:yCenter,w:Zoom + 2,h:1}
		, {x:xCenter - 1,y:yCenter + Zoom + 1,w:Zoom + 2,h:1}
		, {x:xCenter - 1,y:yCenter + 1,w:1,h:Zoom}
		, {x:xCenter + Zoom,y:yCenter + 1,w:1,h:Zoom}]

	oZoom.oMarkers["Grid"] := Zoom = 1 ? oZoom.oMarkers["Square"]
		: [{x:xCenter - Zoom,y:yCenter - Zoom,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter + Zoom,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter + Zoom * 2,w:Zoom * 3,h:1}
		, {x:xCenter - Zoom,y:yCenter - Zoom,w:1,h:Zoom * 3}
		, {x:xCenter,y:yCenter - Zoom,w:1,h:Zoom * 3}
		, {x:xCenter + Zoom,y:yCenter - Zoom,w:1,h:Zoom * 3}
		, {x:xCenter + Zoom * 2,y:yCenter - Zoom,w:1,h:Zoom * 3}]

	SetWindowPos(oZoom.hDevCon, conX, conY, conW, conH)
	SetWindowPos(oZoom.hDev, Left, Top, Width, Height)
	Redraw()
	SetTimer, Magnify, -10
}

SetWindowPos(hWnd, x, y, w, h) {
	Static SWP_ASYNCWINDOWPOS := 0x4000, SWP_DEFERERASE := 0x2000, SWP_NOACTIVATE := 0x0010, SWP_NOCOPYBITS := 0x0100
		, SWP_NOOWNERZORDER := 0x0200, SWP_NOREDRAW := 0x0008, SWP_NOSENDCHANGING := 0x0400
		, uFlags := SWP_ASYNCWINDOWPOS|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOOWNERZORDER|SWP_NOREDRAW|SWP_NOSENDCHANGING
	DllCall("SetWindowPos"
		, "Ptr", hWnd
		, "Ptr", 0
		, "Int", x
		, "Int", y
		, "Int", w
		, "Int", h
		, "UInt", uFlags)
}

ZoomOnSize() {
	If A_EventInfo != 1
	{
		oZoom.Minimize := 0
		SetTimer, SetSize, -10
	}
	Else
		oZoom.Minimize := 1
}

SliderZoom() {
	GuiControlGet, SliderZoom, Zoom:
	ChangeZoom(SliderZoom)
}

ChangeZoom(Val) {
	If (Val < 1 || Val > 50)
		Return
	SetTimer, Magnify, Off
	GuiControl, Zoom:, TextZoom, % oZoom.Zoom := Val
	If A_GuiControl =
		GuiControl, Zoom:, SliderZoom, % oZoom.Zoom
	SetTimer, SetSize, -10
}

ChangeMark() {
	oZoom.Mark := ["Cross","Square","Grid","None"][{"Cross":2,"Square":3,"Grid":4,"None":1}[oZoom.Mark]]
	GuiControl, Zoom:, ChangeMark, % oZoom.Mark
	Redraw()
}

ZoomOnClose() {
	ZoomOnEscape:
		DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcDest)
		DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcSrc)
		DllCall("Gdi32.Dll\DeleteDC", "Ptr", oZoom.hdcMemory)
		RestoreCursors()
		ExitApp
}

GetClientPos(hwnd, ByRef W, ByRef H)  {
	VarSetCapacity(pwi, 60, 0), NumPut(60, pwi, 0, "UInt")
	DllCall("GetWindowInfo", "Ptr", hwnd, "UInt", &pwi)
	W := NumGet(pwi, 28, "Int") - NumGet(pwi, 20, "Int")
	H := NumGet(pwi, 32, "Int") - NumGet(pwi, 24, "Int")
}

WM_Paint() {
	If A_GuiControl =
		SetTimer, Redraw, -30
}

WM_SIZING() {
	SetTimer, Magnify, Off
	oZoom.Sizing := 1
	SetTimer, NoSizing, 10
}

NoSizing() {
	If GetKeyState("LButton", "P")
		Return
	oZoom.Sizing := 0
	SetTimer, NoSizing, Off
	SetTimer, Magnify, -10
}

BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster = 0xC000CA) {
	Return DllCall("Gdi32.Dll\BitBlt"
		, "Ptr", dDC
		, "Int", dx
		, "Int", dy
		, "Int", dw
		, "Int", dh
		, "Ptr", sDC
		, "Int", sx
		, "Int", sy
		, "Uint", Raster)
}

StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster = 0xC000CA) {
	Return DllCall("Gdi32.Dll\StretchBlt"
		, "Ptr", dDC
		, "Int", dx
		, "Int", dy
		, "Int", dw
		, "Int", dh
		, "Ptr", sDC
		, "Int", sx
		, "Int", sy
		, "Int", sw
		, "Int", sh
		, "Uint", Raster|0x40000000)
}

	; _________________________________________________ MoveHand _________________________________________________

WM_SETCURSOR(W, L, M, H) {
	If (oZoom.SIZING)
		Return
	If (oZoom.Pause && W = oZoom.hDev && GetKeyState("LButton", "P"))
	{
		SetTimer, Hand, -1
		Return oZoom.SIZING := 1
	}
}

Hand() {
	SetTimer, Magnify, Off
	DllCall("GetCursorPos", "int64P", pt)
	oZoom.MoveHandX := pt << 32 >> 32, oZoom.MoveHandY := pt >> 32
	oZoom.MoveXSrc := oZoom.nXOriginSrc, oZoom.MoveYSrc := oZoom.nYOriginSrc
	SetSystemCursor("HAND")
	SetTimer, MoveHand, 10
	KeyWait, LButton
	SetTimer, MoveHand, Off
	RestoreCursors()
	oZoom.SIZING := 0
	SetTimer, Magnify, -10
}

MoveHand() {
	Static PrnXOriginSrc, PrnYOriginSrc
	PrnXOriginSrc := oZoom.nXOriginSrc
	PrnYOriginSrc := oZoom.nYOriginSrc
	DllCall("GetCursorPos", "int64P", pt)
	MouseX := pt << 32 >> 32, MouseY := pt >> 32
	XOdds := oZoom.MoveHandX - MouseX
	XOff := XOdds > 0 ? Floor(XOdds / oZoom.Zoom) : Ceil(XOdds / oZoom.Zoom)
	oZoom.nXOriginSrc := oZoom.MoveXSrc + XOff
	YOdds := oZoom.MoveHandY - MouseY
	YOff := YOdds > 0 ? Floor(YOdds / oZoom.Zoom) : Ceil(YOdds / oZoom.Zoom)
	oZoom.nYOriginSrc := oZoom.MoveYSrc + YOff
	If (PrnXOriginSrc <> oZoom.nXOriginSrc || PrnYOriginSrc <> oZoom.nYOriginSrc)
		LimitsOriginSrc(), Redraw()
	Gui, Zoom: Show, NA, % "Magnify   x" oZoom.nXOriginSrc + 1 " y" oZoom.nYOriginSrc + 1
}

MoveStep(StepX, StepY) {
	oZoom.nXOriginSrc += StepX
	oZoom.nYOriginSrc += StepY
	LimitsOriginSrc(), Redraw()
}

LimitsOriginSrc() {
	X := oZoom.nXOriginSrc
	oZoom.nXOriginSrc := X < 0 ? 0 : X > oZoom.VirtualScreenWidth - 1 ? oZoom.VirtualScreenWidth - 1 : X
	Y := oZoom.nYOriginSrc
	oZoom.nYOriginSrc := Y < 0 ? 0 : Y > oZoom.VirtualScreenHeight - 1 ? oZoom.VirtualScreenHeight - 1 : Y
}

MouseStep(x, y) {
	If !oZoom.Pause
		MouseMove, x, y, 0, R
	Else
		MoveStep(x, y)
}

SetSystemCursor(CursorName, cx = 0, cy = 0) {
	Static SystemCursors := {ARROW:32512, IBEAM:32513, WAIT:32514, CROSS:32515, UPARROW:32516, SIZE:32640, ICON:32641, SIZENWSE:32642
					, SIZENESW:32643, SIZEWE:32644 ,SIZENS:32645, SIZEALL:32646, NO:32648, HAND:32649, APPSTARTING:32650, HELP:32651}
    Local CursorHandle, hImage, Name, ID
	If (CursorHandle := DllCall("LoadCursor", Uint, 0, Int, SystemCursors[CursorName]))
		For Name, ID in SystemCursors
			hImage := DllCall("CopyImage", Ptr, CursorHandle, Uint, 0x2, Int, cx, Int, cy, Uint, 0)
			, DllCall("SetSystemCursor", Ptr, hImage, Int, ID)
}

RestoreCursors() {
	Static SPI_SETCURSORS := 0x57
	DllCall("SystemParametersInfo", UInt, SPI_SETCURSORS, UInt, 0, UInt, 0, UInt, 0)
}
По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

17

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Спасибо за помощь. Почти так. Но нужны координаты не экрана, а координаты изображения.

18

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Так вы когда двигаете картинку, там и есть координаты изображения.

По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

19

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Я открыл картинку 6000*4000 и все равно показывает максимум это разрешение экрана. К сожалению возможно я делаю что-то не так.

20

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Если вы мне, то под картинкой имеется ввиду картинка экрана. Чтобы открыть файл картинки, надо конечно изменить код, может напишу если время будет.

По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

21

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

serzh82saratov, да я вам. Спасибо за помощь.
Идеально было бы,если изображение увеличивалось-уменьшалось бы под курсором при помощи колесика мыши.

22

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Вот есть тема ,незнаю подойдёт ли.Но мне кажется если чуток переделать в самый раз. Посмотрите тут

OS: Win11x64, AutoHotkey v1.1.25.01 (Unicode 64-bit).

23

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

ser-bilichenko, пробуйте:

SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
if !FileExist("AHK.png")
   URLDownloadToFile, https://autohotkey.com/assets/images/ahk-logo-no-text241x78-180.png, AHK.png

imagePath := "AHK.png"

Gui, +hwndhGui
Gui, Margin, 20, 20
Gui, Add, Pic, w600 h250 hwndhPic border
oPic := new DrawPicture(imagePath, hPic)
Gui, Show
Return

GuiClose:
   ExitApp

#If WinActive("ahk_id" . hGui)
WheelUp:: oPic.ChangeSize(10)  ; +10%
WheelDown:: oPic.ChangeSize(-9.09)  ; -9.09%
#If

class DrawPicture
{
   __New(sFile, hPic)  {
      this.hPic := hPic
      this.GDI := new GDIp
      this.pBitmap := this.GDI.BitmapFromFile(sFile)
      WinGetPos,,, W, H, ahk_id %hPic%
      this.PicWidth := W, this.PicHeight := H
      
      this.hDC := DllCall("GetDC", Ptr, hPic, Ptr)
      this.oMDC := new this.CompatibleDC(this.hDC, this.PicWidth, this.PicHeight)
      this.mDC := this.oMDC.hCDC
      this.hCBM := DllCall("CreateCompatibleBitmap", Ptr, this.hDC, Int, this.PicWidth, Int, this.PicHeight, Ptr)
      this.oBM := DllCall("SelectObject", Ptr, this.mDC, Ptr, this.hCBM, Ptr)
      
      this.GDI.GetImageDimensions(this.pBitmap, width, height)
      this.BitmapSize := { W: width, H: height }
      this.CurrentSize := this.BitmapSize.Clone()
      this.CurrentSize.X := (this.PicWidth - this.CurrentSize.W)//2
      this.CurrentSize.Y := (this.PicHeight - this.CurrentSize.H)//2
      this.Draw()
      
      OnMessage( 0xF, ObjBindMethod(this, "WM_PAINT") )
   }
   
   __Delete()  {
      this.oMDC := ""
      DllCall("DeleteDC", Ptr, this.hDC)
      this.GDI.DisposeImage(this.pBitmap)
      this.GDI := ""
   }
   
   ChangeSize(step)  {
      CoordMode, Mouse
      MouseGetPos, X, Y
      WinGetPos, X_Pic, Y_Pic,,, % "ahk_id" . this.hPic
      
      X_Mouse := X - X_Pic
      Y_Mouse := Y - Y_Pic
      
      dX := X_Mouse - this.CurrentSize.X
      dY := Y_Mouse - this.CurrentSize.Y
      
      this.CurrentSize.X -= dX/100 * step
      this.CurrentSize.Y -= dY/100 * step
      
      this.CurrentSize.W += this.CurrentSize.W/100 * step
      this.CurrentSize.H += this.CurrentSize.H/100 * step
      
      this.Draw()
   }
   
   Draw()  {
      oMDC := new this.CompatibleDC(this.hDC, this.PicWidth, this.PicHeight)
      hMDC := oMDC.hCDC
      G := this.GDI.GraphicsFromHDC(hMDC)
      this.GDI.SetSmoothingMode(G, 4)  ; AntiAlias = 4
      DllCall("Rectangle", Ptr, hMDC, Int, -1, Int, -1, Int, this.PicWidth + 2, Int, this.PicHeight + 2)
      this.GDI.DrawImage(G, this.pBitmap, this.CurrentSize.X, this.CurrentSize.Y
                                        , this.CurrentSize.W, this.CurrentSize.H
                                        , 0, 0, this.BitmapSize.W, this.BitmapSize.H)
      this.BitBlt(this.hDC, hMDC)
      this.BitBlt(this.mDC, hMDC)
      this.GDI.DeleteGraphics(G)
   }
   
   WM_PAINT(wp, lp, msg, hwnd)  {
      hParent := DllCall("GetParent", Ptr, this.hPic)
      if (hParent = hwnd)  {
         timer := ObjBindMethod(this, "BitBlt", this.hDC, this.mDC)
         SetTimer, % timer, -10
      }
   }
   
   BitBlt(ddc, sdc)  {
      DllCall("BitBlt", Ptr, ddc, Int, 0, Int, 0, Int, this.PicWidth, Int, this.PicHeight
                      , Ptr, sdc, Int, 0, Int, 0, UInt, SRCCOPY := 0xCC0020)
   }
   
   class CompatibleDC
   {
      __New(hDC, w, h)  {
         this.hCDC := DllCall("CreateCompatibleDC", Ptr, hDC, Ptr)
         this.hCBM := DllCall("CreateCompatibleBitmap", Ptr, hDC, Int, w, Int, h, Ptr)
         this.oBM := DllCall("SelectObject", Ptr, this.hCDC, Ptr, this.hCBM, Ptr)
      }
      
      __Delete()  {
         DllCall("SelectObject", Ptr, this.hCDC, Ptr, this.oBM, Ptr)
         DllCall("DeleteDC", Ptr, this.hCDC)
         DllCall("DeleteObject", Ptr, this.hCBM)
      }
   }
}

class GDIp   {
   __New() {
      if !DllCall("GetModuleHandle", Str, "gdiplus", Ptr)
         DllCall("LoadLibrary", Str, "gdiplus")
      VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
      DllCall("gdiplus\GdiplusStartup", UPtrP, pToken, Ptr, &si, Ptr, 0)
      this.token := pToken
   }
   
   __Delete()  {
      DllCall("gdiplus\GdiplusShutdown", Ptr, this.token)
      if hModule := DllCall("GetModuleHandle", Str, "gdiplus", Ptr)
         DllCall("FreeLibrary", Ptr, hModule)
   }
   
   BitmapFromFile(sFile)  {
      DllCall("gdiplus\GdipCreateBitmapFromFile", WStr, sFile, PtrP, pBitmap)
      Return pBitmap
   }
   
   GraphicsFromHDC(hdc)  {
      DllCall("gdiplus\GdipCreateFromHDC", Ptr, hdc, PtrP, pGraphics)
      return pGraphics
   }
   
   SetSmoothingMode(pGraphics, SmoothingMode)  {
      return DllCall("gdiplus\GdipSetSmoothingMode", Ptr, pGraphics, Int, SmoothingMode)
   }
   
   DrawImage(pGraphics, pBitmap, dx, dy, dw, dh, sx, sy, sw, sh)  {
      DllCall("gdiplus\GdipDrawImageRectRect", Ptr, pGraphics, Ptr, pBitmap
                                             , Float, dx, Float, dy, Float, dw, Float, dh
                                             , Float, sx, Float, sy, Float, sw, Float, sh
                                             , Int, 2, Ptr, 0, Ptr, 0, Ptr, 0)
   }
   
   GetImageDimensions(pBitmap, ByRef Width, ByRef Height)  {
      DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, UIntP, Width)
      DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, UIntP, Height)
   }
   
   DisposeImage(pBitmap)  {
      return DllCall("gdiplus\GdipDisposeImage", Ptr, pBitmap)
   }
   
   DeleteGraphics(pGraphics)  {
      return DllCall("gdiplus\GdipDeleteGraphics", Ptr, pGraphics)
   }
}

Сейчас картинка загружается из интернета. Вы можете удалить строчки

if !FileExist("AHK.png")
   URLDownloadToFile, https://autohotkey.com/assets/images/ahk-logo-no-text241x78-180.png, AHK.png

и прописать в переменной imagePath путь к нужному изображению.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

24

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

teadrinker пишет:

пробуйте

Спасибо преогромнейшее!!! Отлично увеличивает.
Возможно я хочу очень много и сразу, но хотелось бы узнать возможно ли разворачивать (или сразу сделать по умолчанию) окно на весь экран? Возможно ли сделать регулировку или сделать чуть быстрее увеличение/уменьшение? И последнее, это извлечение координаты при клике на картинке(именно координат картинки, а не экрана).
Еще раз благодарю.

25

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Возможно, но пока времени нет.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

26

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

teadrinker пишет:

Возможно, но пока времени нет.

Желание компенсировать время было еще до этого сообщения

27

Re: AHK: Открыть изображение, увеличить и получить координаты под курсором

Тогда в личку пишите.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder