0
votes

I am new at AutoHotKey scripting, I need some help to create conditions on variables before any of my hotstrings.

For example if the machine's A_UserName = A then variable1=chris, if A_UserName=b then variable1=mike, so on.

I would like to set it before any of my hotstrings. Here is a sample of my code.

if (A_UserName==A) {

variable1=Chris
}
else  {
variable1=Mike
}  

:#ct:: 

send, Closing ticket, please review data and let us know if you have any      
questions.Thanks %variable1%
return

The key is that i would like to set the conditions before any of my hotkeys or hotstrings so i dont have to use if else statements on all my hotstrings/hotketys.

Any help is much appreciated.

1

1 Answers

1
votes

if (A_UserName==A) suggests that A is a variable name.

In your case, you'd want to use

if (A_UserName=="A")

or

if A_UserName = A

or

A := "A"
; or: A = A
if (A_UserName==A)

PS. on your use of ==, also note the following part of the documentation:

The operators != and <> are identical in function. The == operator behaves identically to = except when either of the inputs is not a number, in which case == is always case sensitive and = is always case insensitive (the method of insensitivity depends on StringCaseSense). By contrast, <> and != obey StringCaseSense. Note: A quoted literal string such as "55" is always considered non-numeric in this context.