I guess you don’t realize the MyFunc() never executes. You just plopped the function definition in the middle of your hotkey subroutine. Functions don’t get executed unless they are called. You have no call, and your placement of the function definition just confuses things. You also have several sets of extraneous braces, also making the code harder to follow. If you think they perform some function, they do not. Try this:
Code: Select all
^q::
Run "C:\windows\system32\cmd.exe"
sleep, 2000 ; (wait 1 second)
MyFunc()
sleep, 8000 ; (wait 8 second)
Send {enter}
sleep, 3000 ; (wait 3 second)
Send email{enter} j
Send password{enter}
return
MyFunc()
{
static o:= 2001
Send, % "ssh -M" o ":123456"
o++
}
By the way, the lines where you send the email and password had a space before the {enter}, which I purposely removed. The space would actually get sent, which could potentially be a problem, especially for the password.
The Send line in your original version of MyFunc() has some odd spacing around the variable o. If the thinking is that it is going to add a space before the value of o, that is not the case. The first time the function executes, it will send
ssh -M2001:123456, which perhaps is intended. Just pointing it out.
Also, you posted in the v2 section (before it was moved). What you posted is not v2 code. You probably just posted in the wrong section, but if you actually have only v2 installed, then the syntax needs to be changed for v2.