I am planning for a script and I would like to use both
LBUTTON::
and
~LBUTTON::
Both in the same script but they will do different things. AHK throws a duplicate error.
My question is two things;;
a- IS there a way (maybe with the suspend on command?) to use both?
b- IF not, what are my options?
My goal is that sometimes in my program when I press the left mouse button I want to continue as usual but display a message. Other times, I want to display the message but not allow the button to be clicked.
I am not looking to disable buttons or using other methods for now. I want to know if this can be done using LBUTTON and ~LBUTTON in one script or is there another way to detect this using a different method that would give a duplicate error?
Thank you everyone for any insight in this situation.
Is this even possible with AHK Topic is solved
Re: Is this even possible with AHK
Hallo,
switch with F4:
switch with F4:
Code: Select all
F4::only_message:=!only_message
~LButton::ToolTip, LButton + message
#If only_message
LButton::ToolTip, only message
#If
Re: Is this even possible with AHK
As mentioned above - You can use #If condition to make same hotkey work in various situations.
Use
Code: Select all
[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
Re: Is this even possible with AHK Topic is solved
thank You,Rohwedder wrote:Hallo,
switch with F4:Code: Select all
F4::only_message:=!only_message ~LButton::ToolTip, LButton + message #If only_message LButton::ToolTip, only message #If
I tested and found that the #if is executed once when the script loads. This means, if I have a condition
Code: Select all
#if (rohwedder = 1)
~LButton::ToolTip, LButton + message
#if (rohwedder = 2)
LButton::ToolTip, only message
#If
Is there an #if that keeps checking? I tried throwing it into a timer but that did not work.
One last question, do you know if the #if can check for many things before activating the LBUTTON::
For example
1 #if (rohwedder = 1)
2 go to this
3 then that
4 and if such and such = true
5 LBUTTON::
6 some action
I was going to do all those items on line 2 3 and 4 outside of the #if and then set some variable like rohwedder = 1. My thing is I am open to ideas and flexible, a little guidance goes a long way.
Thank you
Re: Is this even possible with AHK
Why not evaluate the if inside the actual hotkey? Eg
Code: Select all
A::
If condition
Msgbox, condition true
Else
{
Msgbox, condition false
Suspend, on
Send A
Suspend, off
}
Return
B::
Condition := !Condition
Return
Re: Is this even possible with AHK
Hallo,
an #If [, Expression ] keeps checking all the time, not only when the script is loaded!
Try:Every second the #If [, Expression ] toggles between ~LButton :: and LButton ::
an #If [, Expression ] keeps checking all the time, not only when the script is loaded!
Try:
Code: Select all
~LButton::ToolTip, LButton + message
#If Mod(A_TickCount,2000) < 1000
LButton::ToolTip, only message
#If
Re: Is this even possible with AHK
Thank you, can you explain why this code fails to switch?Rohwedder wrote:Hallo,
an #If [, Expression ] keeps checking all the time, not only when the script is loaded!
Try:Every second the #If [, Expression ] toggles between ~LButton :: and LButton ::Code: Select all
~LButton::ToolTip, LButton + message #If Mod(A_TickCount,2000) < 1000 LButton::ToolTip, only message #If
Code: Select all
tildechar =
settimer, tildetest, 1000
tildetest:
tildechar = 1
sleep, 5000
tildechar = 2
return
#If (tildechar = 1)
~LButton::ToolTip, LButton + message
#If (tildechar = 2)
LButton::ToolTip, only message
#If
return
ESC::ExitApp
Re: Is this even possible with AHK
Hallo,
the update (= Period) of the timer was every second, so the 5 second sleep within the timer could never was ended.
Try:
the update (= Period) of the timer was every second, so the 5 second sleep within the timer could never was ended.
Try:
Code: Select all
tildechar =
settimer, tildetest, 10000 ;Period 10 seconds
tildetest:
tildechar = 1
ToolTip, % "tildechar: "tildechar " Line: " A_LineNumber
sleep, 5000 ;Sleep 5 seconds
tildechar = 2
ToolTip, % "tildechar: "tildechar " Line: " A_LineNumber
return
#If (tildechar = 1)
~LButton::ToolTip, LButton + message
#If (tildechar = 2)
LButton::ToolTip, only message
#If
return
ESC::ExitApp
Re: Is this even possible with AHK
I would like to thank you from the bottom of my heart. You helped a lot and everything works now. Thanks!!!Rohwedder wrote:Hallo,
the update (= Period) of the timer was every second, so the 5 second sleep within the timer could never was ended.
Try:Code: Select all
tildechar = settimer, tildetest, 10000 ;Period 10 seconds tildetest: tildechar = 1 ToolTip, % "tildechar: "tildechar " Line: " A_LineNumber sleep, 5000 ;Sleep 5 seconds tildechar = 2 ToolTip, % "tildechar: "tildechar " Line: " A_LineNumber return #If (tildechar = 1) ~LButton::ToolTip, LButton + message #If (tildechar = 2) LButton::ToolTip, only message #If return ESC::ExitApp
Who is online
Users browsing this forum: Google [Bot] and 159 guests