Code: Select all
if (A_ComputerName = "Acer")
{
msgbox, % A_ComputerName
^+n::
SendInput !hn
return
}
Code: Select all
if (A_ComputerName = "Acer")
{
msgbox, % A_ComputerName
^+n::
SendInput !hn
return
}
Code: Select all
#If A_ComputerName = "Acer"
{
msgbox, % A_ComputerName
^+n::
SendInput !hn
return
}
Code: Select all
#Requires AutoHotkey v1.1.35
MsgBox % A_ComputerName
#If (A_ComputerName = A_ComputerName)
a::MsgBox
#If
the msgbox appears, which means it's working as it should, but after putting in my computer name, there's no msgbox, so it could be that I keyed in the wrong "computer name", which I referenced from This PC > Properties. after checking it doesn't appear to be the case too.mikeyww wrote: ↑28 Dec 2023, 21:18"Doesn't work" is neither a description of what happens nor a description of what does not happen. It is also not a description of what should happen.
1. What actually happens?
2. What should happen instead?
3. Does the hotkey trigger? How do you know?
4. What MsgBox is displayed?
5. The following post shows an example of how the #If directive can be used.
viewtopic.php?f=76&t=114488&p=509932#p509932
A couple of things are notable: first, the directive uses no braces. Second, the directive is used only with hotkeys or hotstrings.
Code: Select all
#Requires AutoHotkey v1.1.35 MsgBox % A_ComputerName #If (A_ComputerName = A_ComputerName) a::MsgBox #If
Code: Select all
msgbox, % A_ComputerName
#If (A_ComputerName = A_ComputerName)
a::MsgBox % A_ComputerName ;RYZEN5600 was displayed
Code: Select all
#If (A_ComputerName = RYZEN5600)
a::msgbox ; no msgbox comes out
Return
Like always in expressions, literal strings should be quoted (in contrast to variable names):
Code: Select all
#If (A_ComputerName = "RYZEN5600")
Code: Select all
#Requires AutoHotkey v1.1.35
f := "x"
If f = "x"
MsgBox 1
If f = x
MsgBox 2
If (f = "x")
MsgBox 3
If (f = x)
MsgBox 4
MsgBox 64, Status, Done!
Code: Select all
#If A_ComputerName = "RYZEN5600"
Code: Select all
#If (A_ComputerName = "RYZEN5600")
Code: Select all
#If A_ComputerName = RYZEN5600
then in fact my original code was correct all along? but I still can't tell why it's not activating properly.gregster wrote: ↑29 Dec 2023, 04:13Like always in expressions, literal strings should be quoted (in contrast to variable names):Code: Select all
#If (A_ComputerName = "RYZEN5600")