Loop, GuiControl Move Picture, on user input

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jamie1992
Posts: 3
Joined: 22 Jul 2018, 11:37

Loop, GuiControl Move Picture, on user input

14 Aug 2018, 07:57

My script has 4 check boxes. Left, right, up and down. Depending on what the user chooses a picture will move along the x or y axis of the screen.

Code: Select all

Gui, Theme: Add, CheckBox, vMvImgLeftCB, Left
Gui, Theme: Add, CheckBox, vMvImgRigtCB, Right
Gui, Theme: Add, CheckBox, vMvImgUpCB, Up
Gui, Theme: Add, CheckBox, vMvImgDownCB, Down
Gui, Theme: Add, Picture, x350 y300 vPic1, %A_ScriptDir%\Pic1.png
Gui, Theme: Add, Button, w100 h100 gGo
Gui, Theme, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight
return

Go:
GuiControlGet, MvImg1LeftCB
GuiControlGet, MvImg1RigtCB
GuiControlGet, MvImg1UpCB
GuiControlGet, MvImg1DownCB

If (MvImgLeftCB = 1) || (MvImgRigtCB = 1)
	{
		MovImgVar = 350
		
		If (MvImgLeftCB = 1)
		{
			Loop, 500
			{
				MovImgVar -= 1
				GuiControl, Move, Pic1, x%MovImgVar%			
			}
		}
		else if (MvImgRigtCB = 1)
		{
			Loop, 500
			{
				MovImgVar += 1
				GuiControl, Move, Pic1, x%MovImgVar%				
			}
		}
	}
	else If (MovImgUpCB = 1) || (MvImgDownCB = 1)
	{
		MovImgVar = 300
		
		If (MovImgUpCB = 1)
		{
			Loop, 500
			{
				MovImgVar -= 1
				GuiControl, Move, Pic1, y%MovImgVar%		
			}
		}
		else if (MvImgDownCB = 1)
		{
			Loop, 500
			{
				MovImgVar += 1
				GuiControl, Move, Pic1, y%MovImgVar%				
			}
		}
	}
return
I want to eventually add 4 images that can be enabled or disabled and also have them move. The issue is that the way I have my go label here is that it will become a big if/else block... "if image 1 is enabled and if image 1 = go left and if image 2 is enabled and if image 2 = go right and so forth".

I was wondering if I can achieve something like this:

Code: Select all

if (MvImgDownCB = 1)
	{
	var = -
	var2 = y
	}	
	
Loop, 500
{
	MovImgVar %var%= 1
	GuiControl, Move, Pic1, %var2%%MovImgVar%				
}
I cant seem to get something like this to work. Any help will be appreciated.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Giresharu, Google [Bot], icyolive, inseption86, mikeyww, songdg, Swiftly9767 and 281 guests