i wanted to do a simple macro.. if i press 1, ctrl 1 will be entered, if i press 2 ctrl 2 wil be entered.. Below are the codes i have.. The loops isnt working. What am i doing wrong?
Label>start
If> Send> = 1
{
Press CTRL
Send Character/Text>1
Release CTRL
Label>end
}
ELSE If> Send> = 2
{
Press CTRL
Send Character/Text>2
Release CTRL
Label>end
}
ELSE
{
Goto>start
}
Endif
problems with simple If else loop(im noob)..
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
The syntax you are using is not Macro Scheduler syntax. And you can't embed functions inside others. The Send command *SENDS* characters. It simulates the user pressing those keys. It does not detect when YOU press those keys. For that use OnEvent. You want something like:
For testing purposes try adding a MessageModal into the subroutines to see the event being fired ...
The syntax you are using is not Macro Scheduler syntax. And you can't embed functions inside others. The Send command *SENDS* characters. It simulates the user pressing those keys. It does not detect when YOU press those keys. For that use OnEvent. You want something like:
Code: Select all
OnEvent>KEY_DOWN,1,0,DoCTRL1
OnEvent>KEY_DOWN,2,0,DoCTRL2
OnEvent>KEY_DOWN,3,0,DoCTRL3
Label>main
Wait>0.2
Goto>main
SRT>DoCTRL1
Press CTRL
Send>1
Release CTRL
END>DoCTRL1
SRT>DoCTRL2
Press CTRL
Send>2
Release CTRL
END>DoCTRL2
SRT>DoCTRL3
Press CTRL
Send>3
Release CTRL
END>DoCTRL3
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
I have much the same problem, any help to get mine working will be much appreciated.
Basically what I am trying to achieve here is to have a variable that changes based upon where it is up to.
So if the BM is 0 it starts from the top, adds +1 to itself to make 0+1, then the next time round it looks to see what BM is again.
My problem is the if and else if, i dont know how to write it to make it register the else before moving on.
Currently if i force BM to be 2 instead of zero it doesn't check to see what BM is in the first set, it doesn't appear to set the envar to be the number I asked, but rather it skips them and just goes straight for the Goto>BM1
HERE is my actual MJT Script
SetEnvVar>BM,0
Label>Start
if>BM,=0
SetEnvVar>BM,1
Goto>BM1
Else>
if>BM,=1
SetEnvVar>BM,2
Goto>BM2
Else>
if>BM,=2
SetEnvVar>BM,3
Goto>BM3
Else>
if>BM,=3
SetEnvVar>BM,4
Goto>BM4
Else>
if>BM,=4
SetEnvVar>BM,5
Goto>BM5
Else>
if>BM,=5
SetEnvVar>BM,0
Goto>BM6
Endif
Endif
Endif
Endif
Endif
Endif
Label>BM1
Message>This is Bookmark One(1)
Goto>Start
Label>BM2
Message>This is Bookmark Two(2).
Goto>Start
Label>BM3
Message>This is Bookmark Three(3).
Goto>Start
Label>BM4
Message>This is Bookmark Four(4).
Goto>Start
Label>BM5
Message>This is Bookmark Five(5).
Goto>Start
Label>BM6
Message>This is Bookmark Six(6).
Goto>Start
Basically what I am trying to achieve here is to have a variable that changes based upon where it is up to.
So if the BM is 0 it starts from the top, adds +1 to itself to make 0+1, then the next time round it looks to see what BM is again.
My problem is the if and else if, i dont know how to write it to make it register the else before moving on.
Currently if i force BM to be 2 instead of zero it doesn't check to see what BM is in the first set, it doesn't appear to set the envar to be the number I asked, but rather it skips them and just goes straight for the Goto>BM1
HERE is my actual MJT Script
SetEnvVar>BM,0
Label>Start
if>BM,=0
SetEnvVar>BM,1
Goto>BM1
Else>
if>BM,=1
SetEnvVar>BM,2
Goto>BM2
Else>
if>BM,=2
SetEnvVar>BM,3
Goto>BM3
Else>
if>BM,=3
SetEnvVar>BM,4
Goto>BM4
Else>
if>BM,=4
SetEnvVar>BM,5
Goto>BM5
Else>
if>BM,=5
SetEnvVar>BM,0
Goto>BM6
Endif
Endif
Endif
Endif
Endif
Endif
Label>BM1
Message>This is Bookmark One(1)
Goto>Start
Label>BM2
Message>This is Bookmark Two(2).
Goto>Start
Label>BM3
Message>This is Bookmark Three(3).
Goto>Start
Label>BM4
Message>This is Bookmark Four(4).
Goto>Start
Label>BM5
Message>This is Bookmark Five(5).
Goto>Start
Label>BM6
Message>This is Bookmark Six(6).
Goto>Start
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I'm not sure why you want to use SetEnvVar. And you also don't need those gotos. You have commas in your If statements. I think you want something more like this:
I have no idea if this is really what you want to do, but this script meets your stated requirements.
Code: Select all
Let>BM=0
Label>start
if>BM=0
Let>BM=1
MessageModal>This is Bookmark One(1)
Else
if>BM=1
Let>BM=2
MessageModal>This is Bookmark Two(2)
Else
if>BM=2
Let>BM=3
MessageModal>This is Bookmark Three(3)
Else
if>BM=3
Let>BM=4
MessageModal>This is Bookmark Four(4)
Else
if>BM=4
Let>BM=5
MessageModal>This is Bookmark Five(5)
Else
if>BM=5
Let>BM=6
MessageModal>This is Bookmark Six(6)
Endif
Endif
Endif
Endif
Endif
Endif
If>BM<6>start
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
These simpler scripts achieve the exact same thing:
This one goes up to 6:
This one increments ad infinitum:
This one goes up to 6:
Code: Select all
Let>BM=0
Repeat>BM
Let>BM=BM+1
MessageModal>This is Bookmark %BM%
Until>BM=6
Code: Select all
Let>BM=0
Label>start
Let>BM=BM+1
MessageModal>This is Bookmark %BM%
Goto>start
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?