My script is not working needs help!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
liamchop1
Posts: 1
Joined: 16 Aug 2022, 21:59

My script is not working needs help!

Post by liamchop1 » 16 Aug 2022, 22:02

Code: Select all

^q::  
Run "C:\windows\system32\cmd.exe" 
sleep, 2000 ; (wait 1 second)
{
MyFunc() 
{
	static o:= 2001
	Send,  % "ssh -M"  o ":123456"  
	o++
}
}
sleep, 8000 ; (wait 8 second)
{ 
Send {enter}
}
sleep, 3000 ; (wait 3 second)
{
Send email {enter} 
}
{
Send password {enter} 
}
return

[Mod action: Topic moved from v2 section of "Ask For Help" (this is v1 code). Added [code][/code] tags.]

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: My script is not working needs help!

Post by boiler » 17 Aug 2022, 04:46

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.

Post Reply

Return to “Ask for Help (v1)”