save coordinate to ini file

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bittencourt318
Posts: 90
Joined: 16 Apr 2020, 10:57

save coordinate to ini file

22 Aug 2022, 01:45

I got this code from another post could someone tell me how I could make it save the screen coordinates in a .ini file



Code: Select all

; First press only RButton and define the area.
; Whenever the LButton is pressed additionally, the area can be moved.
; When RButton is released, the coordinates are displayed.
Mbutton:: ;FirstKey
ToolTip,% SelectArea("ms",SecondKey:="Button") ;ms = CoordMode Screen
Return
SelectArea(Options:="",SecondKey:="")
{ ; from Learning one, slightly modified
		/*
		Returns selected area. Return example: 22|13|243|543
		Options: (White space separated)
		- c color. Default: Blue.
		- t transparency. Default: 50.
		- g GUI number. Default: 99.
		- m CoordMode. Default: s. s = Screen, r = Relative
		Examples: SelectArea() , SelectArea("cLime t100 g55 mr")
		*/
	CoordMode, Mouse, Relative
	MouseGetPos, rMX, rMY
	CoordMode, Mouse, Screen
	MouseGetPos, MX, MY
	loop, parse, Options, %A_Space%
	{
		Field := A_LoopField
		FirstChar := SubStr(Field,1,1)
		if FirstChar contains c,t,g,m
		{
			StringTrimLeft, Field, Field, 1
			%FirstChar% := Field
		}
	}
	c := (c = "") ? "Blue" : c, t := (t = "") ? "50" : t, g := (g = "") ? "99" : g , m := (m = "") ? s : m
	Gui %g%: Destroy
	Gui %g%: +AlwaysOnTop -caption +Border +ToolWindow +LastFound
	WinSet, Transparent, %t%
	Gui %g%: Color, %c%
	;Hotkey := RegExReplace(A_ThisHotkey,"^(\w* & |\W*)")
	RegExMatch(A_ThisHotkey, "\W$|\w*$", Hotkey)
	While, (GetKeyState(Hotkey, "p"))
	{
		Sleep, 10
		MouseGetPos, MXend, MYend
		IF GetKeyState(SecondKey,"P")
			MX += MXend - MXOld, MY += MYend - MYOld
		w := Abs(MX - MXend), h := Abs(MY - MYend)
		X := Min(MX, MXOld:=MXend), Y := Min(MY, MYOld:=MYend)
		Gui %g%: Show, x%X% y%Y% w%w% h%h% NA
	}
	Gui %g%: Destroy
	if m = s ; Screen
	{
		MouseGetPos, MXend, MYend
		If (MX > MXend)
			temp := MX, MX := MXend, MXend := temp
		If (MY > MYend)
			temp := MY, MY := MYend, MYend := temp
		Return MX " " MY " " MXend " " MYend
	}
	else ; Relative
	{
		CoordMode, Mouse, Relative
		MouseGetPos, rMXend, rMYend
		If (rMX > rMXend)
			temp := rMX, rMX := rMXend, rMXend := temp
		If (rMY > rMYend)
			temp := rMY, rMY := rMYend, rMYend := temp
		Return rMX " " rMY " " rMXend " " rMYend
	}
}
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: save coordinate to ini file

22 Aug 2022, 02:57

Well, you replace the 'Return' line(s), ie...
Return rMX " " rMY " " rMXend " " rMYend
...with four INIWrite commands.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: bobstoner289, Google [Bot], peter_ahk and 329 guests