problems with the GUI table

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Prbumbasas
Posts: 11
Joined: 26 Apr 2021, 07:11

problems with the GUI table

Post by Prbumbasas » 26 Nov 2022, 08:25

Hello, I faced this problem, On/Off gui button doesn't work well, And does not allow to select 2 "Options" at the same time.

Code: Select all

#UseHook

Gui Font, s10, Impact
Gui Add, Text, x195 y10 w170 h26 +0x200 +BackgroundTrans, Option1.
Gui Add, Text, x195 y50 w170 h26 +0x200 +BackgroundTrans, Option2.
Gui Add, Text, x195 y90 w170 h26 +0x200 +BackgroundTrans, Option3.


Gui, Add, Button, x112 y9 w80 h30 -Multi -Wrap gButton1  vTheButton1, &On
Gui, Add, Button, x112 y49 w80 h30 -Multi -Wrap gButton2  vTheButton2, &On
Gui, Add, Button, x112 y89 w80 h30 -Multi -Wrap gButton3  vTheButton3, &On
Gui, Show
Return


Button1:
Started := !Started
If (Started)
GuiControl, , TheButton1, &Off
Else
GuiControl, , TheButton1, &On
  
Button2:
Started := !Started
If (Started)
GuiControl, , TheButton2, &Off
Else
GuiControl, , TheButton2, &On
  
Button3:
Started := !Started
If (Started)
GuiControl, , TheButton3, &Off
Else
GuiControl, , TheButton3, &On


Option1:
	Loop
	{
                ~RButton::
                sendinput {1 down}
                sendinput {1 up}
		Return

	}
	return

	
Option2:
	Loop
	{
                ~Space::
                sendinput {2 down}
                sendinput {2 up}
		Return

	}
	return




Option3:
	Loop
	{
                ~LShift::
                sendinput {3 down}
                sendinput {3 up}
		Return

	}
	return
	

GuiClose:
	ExitApp

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

Re: problems with the GUI table

Post by mikeyww » 26 Nov 2022, 09:13

Welcome to this AutoHotkey forum!

A hotkey cannot be directly defined inside a subroutine in that manner, but a GUI could be used to set a context or execute the Hotkey command.

Code: Select all

option = 1
#If (option = 1)
RButton::MsgBox, Test
#If

Code: Select all

Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, CheckBox, vc1 w230 gRegister, Option #1
Gui, Add, CheckBox, vc2      gRegister, Option #2
Gui, Add, CheckBox, vc3      gRegister, Option #3
Gui, Show, x100 y100, Options

#If c1
RButton::MsgBox, Test

#If c2
LButton::MsgBox, Test
#If

Register:
Gui, Submit, NoHide
Return

Prbumbasas
Posts: 11
Joined: 26 Apr 2021, 07:11

Re: problems with the GUI table

Post by Prbumbasas » 26 Nov 2022, 09:45

I didn't understand how I should fix my code, can you explain more clearly?

Prbumbasas
Posts: 11
Joined: 26 Apr 2021, 07:11

Re: problems with the GUI table

Post by Prbumbasas » 26 Nov 2022, 10:51

Okay, but how can I fix the On/Off function?ImageImage

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

Re: problems with the GUI table

Post by mikeyww » 26 Nov 2022, 11:12

Code: Select all

Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, Button, w50 vb1 gGo, % b1 := "On"
Gui, Add, Button, wp  vb2 gGo, % b2 := "On"
Gui, Show, x100 y100 w230, Options

#If (b1 = "On")
RButton::MsgBox, Test

#If (b2 = "On")
F3::MsgBox, Not
#If

Go:
GuiControlGet, state,, %A_GuiControl%
GuiControl,, %A_GuiControl%, % %A_GuiControl% := state = "On" ? "Off" : "On"
Return

GuiEscape:
GuiClose:
ExitApp

Post Reply

Return to “Ask for Help (v1)”