Send text sleep send more text Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mikael63
Posts: 12
Joined: 24 Sep 2019, 08:47

Send text sleep send more text

Post by Mikael63 » 26 Jan 2023, 06:59

I got one main ahk-file where I got almost all of mine commandlines.

Two of them looks this:

Code: Select all

#IfWinActive ahk_class BricscadMainWindow
^!5::Send, (cmd_setenv "epcb_cmd" "PROJ_ANALYS"){ENTER}

#IfWinActive ahk_class BricscadMainWindow
^!6::Send, (cmd_setenv "epcb_cmd" "PROJ_XREF"){ENTER}
Now I want to do like

Code: Select all

#IfWinActive ahk_class BricscadMainWindow
^!5::Send, (cmd_setenv "epcb_cmd" "PROJ_ANALYS"){ENTER} Sleep 5000 Send, (cmd_setenv "epcb_cmd" "PROJ_XREF"){ENTER}
I can't get it to work, I can't figure out how to do this in one simple line?

User avatar
mikeyww
Posts: 26888
Joined: 09 Sep 2014, 18:38

Re: Send text sleep send more text

Post by mikeyww » 26 Jan 2023, 08:41

AHK commands (e.g., Send and Sleep) cannot be combined on a single line.

If you use the current version of AutoHotkey, you can do it with functions.

Mikael63
Posts: 12
Joined: 24 Sep 2019, 08:47

Re: Send text sleep send more text

Post by Mikael63 » 26 Jan 2023, 08:45

mikeyww wrote:
26 Jan 2023, 08:41
AHK commands (e.g., Send and Sleep) cannot be combined on a single line.

If you use the current version of AutoHotkey, you can do it with functions.
Okay but then how, as simple as possible?
Like

Code: Select all

#IfWinActive ahk_class BricscadMainWindow
^!5::Send, (cmd_setenv "epcb_cmd" "PROJ_ANALYS"){ENTER}
Sleep 5000
Send, (cmd_setenv "epcb_cmd" "PROJ_XREF"){ENTER}
I'm using (file)version 1.1.33.8

User avatar
mikeyww
Posts: 26888
Joined: 09 Sep 2014, 18:38

Re: Send text sleep send more text  Topic is solved

Post by mikeyww » 26 Jan 2023, 09:08

That isn't the current version. It's 2.0.2.

https://www.autohotkey.com/docs/v2/

Code: Select all

#Requires AutoHotkey v2.0
Send('a`n'), Sleep(500), Send(34)

Mikael63
Posts: 12
Joined: 24 Sep 2019, 08:47

Re: Send text sleep send more text

Post by Mikael63 » 26 Jan 2023, 09:52

mikeyww wrote:
26 Jan 2023, 09:08
That isn't the current version. It's 2.0.2
Yes, I know, I just told what I got..

Installed 2.0.2 and now I got may errors from my file :(
I'm using Send, blah blah but I understad that I need to use Send blah blah without comma.

I got illegal character error in

Code: Select all

^F1::Send *.*md;*.bak;*.lck;felrapport;*.scr;*.db;*.log;*.old*;*.tmp;*.$*mdb;Preview
and

Code: Select all

#IfWinActive ahk_class BricscadMainWindow
Missing space or operator in

Code: Select all

F1::Send {ctrl down}c{ctrl up}
and so on... :cry:

User avatar
mikeyww
Posts: 26888
Joined: 09 Sep 2014, 18:38

Re: Send text sleep send more text

Post by mikeyww » 26 Jan 2023, 12:04

My first suggestion is to run the exact script that I posted, to see if it works. That tells you if you are starting with a working script.

Mikael63
Posts: 12
Joined: 24 Sep 2019, 08:47

Re: Send text sleep send more text

Post by Mikael63 » 26 Jan 2023, 12:17

mikeyww wrote:
26 Jan 2023, 12:04
My first suggestion is to run the exact script that I posted, to see if it works. That tells you if you are starting with a working script.
Oh, of course, already done that, works just fine, thanks!

And now I found a v1 to v2 converter here, converted and my .ahk does load at least.

User avatar
mikeyww
Posts: 26888
Joined: 09 Sep 2014, 18:38

Re: Send text sleep send more text

Post by mikeyww » 26 Jan 2023, 16:19

Yeah, the syntax differs! Feel free to post any questions, along with your transformed script.

Multi-line hotkey subroutines are OK in either version.

Code: Select all

#Requires AutoHotkey v1.1.33
#If WinActive("ahk_class BricscadMainWindow")
^!5::
SendInput (cmd_setenv "epcb_cmd" "PROJ_ANALYS"){Enter}
Sleep 5000
SendInput (cmd_setenv "epcb_cmd" "PROJ_XREF"){Enter}
Return
#If
Concepts:
1. A multi-line subroutine should have a hotkey on the first line, by itself.
2. In v1, a subroutine ends with a Return command. If a command is on the same line as the hotkey, then a Return after the command is implicit.
3. Without any return, a script proceeds to the next statement.

Code: Select all

#Requires AutoHotkey v2.0
#HotIf WinActive("ahk_class BricscadMainWindow")
^!5:: {
 Send '(cmd_setenv "epcb_cmd" "PROJ_ANALYS"){Enter}'
 Sleep 5000
 Send '(cmd_setenv "epcb_cmd" "PROJ_XREF"){Enter}'
}
#HotIf

Post Reply

Return to “Ask for Help (v1)”