Transform loop to settimer

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

Transform loop to settimer

Post by aliztori » 27 Nov 2022, 13:55

hello i want to transform the loop part to settimer but didnt work

Code: Select all

a::
	Thickness := 50, Offset := 0, Color := "ffae00", TFade := 4

	SysGet, W, 78
	SysGet, H, 79

	oX1 := oY1 := Offset

	oX2 := W - Offset
	oY2 := H - Offset

	iX1 := iY1 := Thickness + Offset

	iX2 := (W - Thickness) - Offset
	iY2 := (H - Thickness) - Offset

	Gui, +Lastfound +AlwaysOnTop +Toolwindow -Caption
	Gui, Color, % Color
	
	WinSet, Region, %oX1%-%oY1% %oX2%-%oY1% %oX2%-%oY2% %oX1%-%oY2% %oX1%-%oY1%  %iX1%-%iY1% %iX2%-%iY1% %iX2%-%iY2% %iX1%-%iY2% %iX1%-%iY1%
	Gui, Show, X%oX1% Y%oY1% W%W% H%H% NoActivate
	
	Loop, 25
	{
		Fade += TFade
		WinSet, Transparent, % Fade
		Sleep, 15
	}

	Loop, 25
	{
		Fade -= TFade
		WinSet, Transparent, % Fade
		Sleep, 15
	}

Return

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Transform loop to settimer

Post by mikeyww » 27 Nov 2022, 14:07

1. What did you try?
2. Why do you want to do that?

aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

Re: Transform loop to settimer

Post by aliztori » 27 Nov 2022, 15:02

mikeyww wrote:
27 Nov 2022, 14:07
1. What did you try?
2. Why do you want to do that?
Because this function works when I want to scroll the mouse(+another thing), so I have to use SetTimer

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Transform loop to settimer

Post by mikeyww » 27 Nov 2022, 16:54

It looks like you are ignoring question #1, so we'll move to question #2. Are you referring to a hotkey that is not shown in your post?

aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

Re: Transform loop to settimer

Post by aliztori » 01 Dec 2022, 03:30

mikeyww wrote:
27 Nov 2022, 16:54
It looks like you are ignoring question #1, so we'll move to question #2. Are you referring to a hotkey that is not shown in your post?
question 1 ;

aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

Re: Transform loop to settimer

Post by aliztori » 01 Dec 2022, 03:35

mikeyww wrote:
27 Nov 2022, 16:54
It looks like you are ignoring question #1, so we'll move to question #2. Are you referring to a hotkey that is not shown in your post?
question 1 : i just set timer and a countter into and put a if (counter = whatern umber) settimer,label,off
I hope you understand something like this I think this is the only way to convert a loop into a set timer

question #2 :
Yes, I have a script that controls the sound of the system when I move the mouse on the edges of the screen and scroll.
And for this reason, I want something to flash in the same areas

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Transform loop to settimer

Post by mikeyww » 01 Dec 2022, 07:13

Thank you. The essence of my question is whether your current script is broken. It seemed to work when I tested it. A loop is well suited to your idea of creating a graded or changing transparency.

aliztori
Posts: 119
Joined: 19 Jul 2022, 12:44

Re: Transform loop to settimer

Post by aliztori » 01 Dec 2022, 10:48

mikeyww wrote:
01 Dec 2022, 07:13
Thank you. The essence of my question is whether your current script is broken. It seemed to work when I tested it. A loop is well suited to your idea of creating a graded or changing transparency.
how i combine them ?

this my script:

Code: Select all

#If MouseInZone(50, "OR", "Top", "Bottom", "Left", "Right")

	WheelUp::Volume_Up
	WheelDown::Volume_Down

#If



MouseInZone(Margin, Mode, Edges*)
{
	; if !Edges.Count()
	; 	throw Exception("No edges specified", -1, Edges.Count())

	CoordMode, Mouse

	SysGet, Width, 78
	SysGet, Height, 79

	MouseGetPos, Cx, Cy
	
	Top := (Cy <= Margin), Bottom := (Cy >= Height - Margin)
	Left := (Cx <= Margin), Right := (Cx >= Width - Margin)

	isInZone := (Mode = "Or") || (Mode = "XOR") ? False : (Mode = "And") ? True

	For Each, EdgeName in Edges
	{
		Switch (Mode)
		{
			Case "OR": (isInZone |= %EdgeName%)
			Case "XOR": (isInZone ^= %EdgeName%)
			Case "AND": (isInZone &= %EdgeName%)
		}
	}
	
	; if (isInZone = "")
	; {
	; 	for each, edgeName in Edges
	; 		edgeNames .= edgeName A_Space

	; 	Throw Exception("Invalid edge name(s) specified", -1, edgeNames)
	; }

	Return (isInZone)
}

Also, if there is a problem or something wrong with this script, I will be happy to tell me

Post Reply

Return to “Ask for Help (v1)”