EnvSub in PMC doesn't work but does in AHK

Advanced Macro Recorder/Editor.

Moderator: Pulover

demusss
Posts: 1
Joined: 08 May 2022, 18:14

EnvSub in PMC doesn't work but does in AHK

08 May 2022, 18:25

The EnvSub function doesn't seem to work when executing the script from inside Macro Creator, but if I save the script and run it using AHK then it works.

When the script runs in PMC the difference time displayed in the MsgBox is the same as the start time.

I've had to use the Expression action to get the function in the script.

This is the script thats generated

Code: Select all

varStartTime := A_Now
Loop, 5
{
    Sleep, 5000
    varCurrentTime := A_Now
    varTimeDiff := varStartTime
    EnvSub, varTimeDiff, %varCurrentTime%, seconds
    MsgBox, 262144, a title, 
    (LTrim
    %varStartTime% - start
    %varCurrentTime% - now
    %varTimeDiff% - difference
    ), 3
}
higrm
Posts: 6
Joined: 28 Aug 2019, 05:00

Re: EnvSub in PMC doesn't work but does in AHK

09 May 2022, 20:56

demusss wrote:
08 May 2022, 18:25
The EnvSub function doesn't seem to work when executing the script from inside Macro Creator, but if I save the script and run it using AHK then it works.

When the script runs in PMC the difference time displayed in the MsgBox is the same as the start time.

I've had to use the Expression action to get the function in the script.

This is the script thats generated

Code: Select all

varStartTime := A_Now
Loop, 5
{
    Sleep, 5000
    varCurrentTime := A_Now
    varTimeDiff := varStartTime
    EnvSub, varTimeDiff, %varCurrentTime%, seconds
    MsgBox, 262144, a title, 
    (LTrim
    %varStartTime% - start
    %varCurrentTime% - now
    %varTimeDiff% - difference
    ), 3
}
It seems to work for me in PMC. Here's my PMC code:

Code: Select all

[PMC Globals]|None||
[PMC Code v5.4.1]|F23||1|Window,2,Fast,0,1,Input,-1,-1,1|1|Macro3
Context=None|
Groups=Start:1
1|[Assign Variable]|varStartTime := A_Now|1|0|Variable|Expression||||1|
2|[LoopStart]|LoopStart|5|0|Loop|||||2|
3|[Assign Variable]|varCurrentTime := A_Now|1|0|Variable|Expression||||4|
4|[Assign Variable]|varTimeDiff := varStartTime|1|0|Variable|Expression||||5|
5|EnvSub|varTimeDiff, %varCurrentTime%, seconds|1|150|EnvSub|||||6|
6|LTrim|varStartTime := varStartTime, 3|1|0|Function|||||8|
7|[MsgBox]|%varStartTime% %varTimeDiff% %varCurrentTime%|1|0|MsgBox|262144||||9|
8|[LoopEnd]|LoopEnd|1|0|Loop|||||10|
And this is the AHK code it produced:

Code: Select all

varStartTime := A_Now
Loop, 5
{
	varCurrentTime := A_Now
	varTimeDiff := varStartTime
	EnvSub, varTimeDiff, %varCurrentTime%, seconds
	Sleep, 150
	varStartTime := LTrim(varStartTime, 3)
	MsgBox, 262144, , %varStartTime% %varTimeDiff% %varCurrentTime%
}

Return to “Pulovers Macro Creator”

Who is online

Users browsing this forum: No registered users and 18 guests