Page 1 of 1

Mouse Button Down, Ignoring Toggle

Posted: 13 Jun 2021, 18:57
by Lolifu
Hello,

Ill try and be as informational as possible and explain what I am trying accomplish.

What I want the script to do!
*Have a toggle on and off "pause" or "suspend" until I need it again.
*GUI Text pref that I can not Interact with. I have only been able to create a box but its something :P.
* WHILE the toggle is true and I have the left mouse button down, replicate that click over and over "with somewhat of a delay" until released.

I got the mouse click and the GUI but for some reason the mouse click IGNORES the if statement.


CODE!

Code: Select all

End::
ExitApp
Return


Gui, Add, Text, , Some Text

Space::
toggle := !toggle
If (toggle = true)
{

	GuiWidth := 100
	Guiheight := 10
	Guixpos := A_ScreenWidth - GuiWidth - 10
	Guiypos := A_ScreenHeight - Guiheight - 15
	Gui, 1:Show, x%guixpos% y%guiypos% h382 w120
	Gui, +AlwaysOnTop

 	LButton::
   	 While GetKeyState("LButton","P") = 1
    		{	
     			 send,{LButton}
      				sleep,25
    		}
return
}
else
{
	Gui, hide
}
return
[Mod edit: [code][/code] tags added.]

Re: Mouse Button Down, Ignoring Toggle

Posted: 13 Jun 2021, 19:11
by mikeyww
A context-sensitive ("conditional") hotkey would be defined with the #If directive, rather than the "If" command. The linked page includes examples.

Re: Mouse Button Down, Ignoring Toggle

Posted: 13 Jun 2021, 20:06
by Lolifu
mikeyww wrote:
13 Jun 2021, 19:11
A context-sensitive ("conditional") hotkey would be defined with the #If directive, rather than the "If" command. The linked page includes examples.
Hello, Thank you for the fast reply. I was looking at the documentation but to to me not making sense.

You said use Context-insensetive Hotkey, this is the example it showed.

Code: Select all

Context-insensitive Hotkey.

#If
Esc::ExitApp

I come from unity javascript so this "If statement" to me should be like a stop sign but guess not.
I tried this

Code: Select all

	#If
 	LButton::GetKeyState("LButton","P") = 1
This means when I press the key I am essential doing nothing cause I am already giving it a value of 1 by pressing it. Ill continue to see if this can be used with a while statement but figured I would update you.

Re: Mouse Button Down, Ignoring Toggle

Posted: 13 Jun 2021, 20:24
by mikeyww
Actually, I did not mention a context-insensitive hotkey at all.

One example is below.

Code: Select all

Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, Text,, Some Text

Space::
If on := !on
 Gui, Show, w220
Else Gui, Hide
Return

#If on
LButton::
SetMouseDelay, 25
While GetKeyState("LButton", "P")
 Click
Return
#If

Re: Mouse Button Down, Ignoring Toggle

Posted: 14 Jun 2021, 00:19
by Lolifu
Thank you again,

Unfourt I didn't use your code but I did find my answer in the case insensitive. You have been helpful and I am grateful I love learning new things. Now I just have to figure out how to make GUI Text with no Box or make it invisible. The work continues I suppose.

Have a great day!

Re: Mouse Button Down, Ignoring Toggle

Posted: 14 Jun 2021, 06:52
by mikeyww
You are welcome. Here is an example of text without a box.

Code: Select all

Gui, +AlwaysOnTop -Caption
Gui, Font, s10
Gui, Add, Text, w220 Center, Some Text
Gui, Show,, Test