clipboard contents not recognised
Moderators: JRL, Dorian (MJT support)
clipboard contents not recognised
I am trying to get macro scheduler to work through an excel list and stop when it recognises the value of the cell. In the example below if the cell in excel contains a 'X', the program should end but it doesn't. Any idea's what is wrong?
Label>Start
SetFocus>Microsoft Excel*
WaitWindowOpen>Microsoft Excel - Book*
Press Down
Press CTRL
Send Character/Text>c
Release CTRL
GetClipBoard>field
If>field=X,End,Continue
Label>Continue
Label>Start
SetFocus>Microsoft Excel*
WaitWindowOpen>Microsoft Excel - Book*
Press Down
Press CTRL
Send Character/Text>c
Release CTRL
GetClipBoard>field
If>field=X,End,Continue
Label>Continue
I didn't bother including the rest of the script but the label>end is at the very end so the script should stop running when it identifies that it has found an X in the next downward cell in excel. If no X is found, it should run through the rest of the commands until it hits the Goto>Start (which is before the label>end.
Hi Guest,
I re-write your script as follows:
Please let us know whether the code works fine on your PC. Good luck.
Cheers,
Armstrong Wong
Hong Kong
I re-write your script as follows:
Code: Select all
Label>Start
SetFocus>Microsoft Excel*
WaitWindowOpen>Microsoft Excel - Book*
Label>Loop1
Press Down
wait>0.15
Press CTRL
wait>0.15
Send Character/Text>c
wait>0.15
Release CTR
wait>0.15
GetClipBoard>field
If>field=X,End,Loop1
Label>Continue
....
Label>End
Please let us know whether the code works fine on your PC. Good luck.
Cheers,
Armstrong Wong
Hong Kong
Hi,
that's something what happens for whatever reason with saving a macro (I've not identified yet if it's occuring with saving via "File/Save" or the "Save-Button"). A space will be added to the Label>Name. Therefore an If>statement wich points to that Label> will fail cause the "unspaced" name won't match with the one.
It looks quite the same like the "copy code from forum"-issue, which concats an additional space at every copied line.
Bye,
Ernest
that's something what happens for whatever reason with saving a macro (I've not identified yet if it's occuring with saving via "File/Save" or the "Save-Button"). A space will be added to the Label>Name. Therefore an If>statement wich points to that Label> will fail cause the "unspaced" name won't match with the one.

It looks quite the same like the "copy code from forum"-issue, which concats an additional space at every copied line.
Bye,
Ernest
Hi Ernest,
The beauty of Macro Scheduler script language is absolute simplicity. Alas, it's also its disadvantage. In particular, it's excessively lax in variable/constant definitions. By merely looking at:
Message>Hello
no one could be sure whether Hello is a literal, or a variable unless the code above the command is carefully examined. A variable can be freely assigned with a character string or a integer or a real number,...etc.
On the other hand, it's constant and stable once the script is being debugged and tested for several times.
My solution is to examine the code in Hex mode to ensure no 20h at the end of each line.
Cheers,
Armstrong Wong
Hong Kong
The beauty of Macro Scheduler script language is absolute simplicity. Alas, it's also its disadvantage. In particular, it's excessively lax in variable/constant definitions. By merely looking at:
Message>Hello
no one could be sure whether Hello is a literal, or a variable unless the code above the command is carefully examined. A variable can be freely assigned with a character string or a integer or a real number,...etc.
On the other hand, it's constant and stable once the script is being debugged and tested for several times.
My solution is to examine the code in Hex mode to ensure no 20h at the end of each line.
Cheers,
Armstrong Wong
Hong Kong
MacroScript was designed to be easy for the non-programmer to understand and as such does not complicate the user with variable declarations and complicated ways to use them, instead allowing variables and literals to be interchanged and used in the same way. Anything that is not a variable is seen as a literal.
Naturally, therefore, it is important, especially in longer scripts, to find a way to avoid clashes between intended literals and identically named variables.
I always recommend the Hungarian notation - of which many programmers adopt a version of their own. E.g. prefixes n for numeric, str for strings and so on, like:
nDayNumber
strForeName
Or come up with your own consistent, easy to understand notation that makes it easy for the reader to know that it is a variable and what kind of data it represents. It makes your code more documented and less likely to cause confusion between variables and literals. Another thing you could do is use a special char before the variable name:
Let>$Name=Fred
Let>&k=1
&k is the variable – not k. $Name is the variable – not Name and I have used $ for strings and & for numerics. Just an idea. Use what you prefer – that’s the nice thing about Macro Scheduler – you can come up with your own naming conventions.
On the topic of the invisible control chars at the end of lines - this is often a problem when you copy from a web page. I will see if we can do something to the HTML code in the forum to avoid these chars appearing - or failing that perhaps we can make a mod to the next version of Macro Scheduler to automatically strip them out of scripts. In any case it's just an issue with copy and paste, not a problem with Macro Scheduler - and something to be aware of.
Naturally, therefore, it is important, especially in longer scripts, to find a way to avoid clashes between intended literals and identically named variables.
I always recommend the Hungarian notation - of which many programmers adopt a version of their own. E.g. prefixes n for numeric, str for strings and so on, like:
nDayNumber
strForeName
Or come up with your own consistent, easy to understand notation that makes it easy for the reader to know that it is a variable and what kind of data it represents. It makes your code more documented and less likely to cause confusion between variables and literals. Another thing you could do is use a special char before the variable name:
Let>$Name=Fred
Let>&k=1
&k is the variable – not k. $Name is the variable – not Name and I have used $ for strings and & for numerics. Just an idea. Use what you prefer – that’s the nice thing about Macro Scheduler – you can come up with your own naming conventions.
On the topic of the invisible control chars at the end of lines - this is often a problem when you copy from a web page. I will see if we can do something to the HTML code in the forum to avoid these chars appearing - or failing that perhaps we can make a mod to the next version of Macro Scheduler to automatically strip them out of scripts. In any case it's just an issue with copy and paste, not a problem with Macro Scheduler - and something to be aware of.
MJT Net Support
[email protected]
[email protected]
How can it be posible the invisible chars into variable names?
It should not be allowed. If MacroScheduler allow it, many mistakes will happen.
I think it would be better than MacroScheduler would ignore invisible chars. So there is not the problem of invisible spaces in variable names to confuse all.
It should not be allowed. If MacroScheduler allow it, many mistakes will happen.
I think it would be better than MacroScheduler would ignore invisible chars. So there is not the problem of invisible spaces in variable names to confuse all.
Sometimes you want invisible chars. What if you are sending a space character with the Send char:
Send>
There is an intended space at the end of the above line so that I can send a space.
The problem is that the HTML adds in these unwanted spaces, or they could be line breaks, into the web page.
If we made Macro Scheduler remove them we would stop valid lines like the above one from working.
What we really need to do is find a way that allows people to post their code here in a way that the darn HTML doesn't mess with it. This is an issue with posting code on a web site, not with Macro Scheduler.
My preference is to create a way for people to upload their script files. They can then post their code but provide a link to the actual script file so that you download the actual file as it is intended. You can see code here for information but then download the file if you want to use it - that might be safer. We're looking into solutions in any case.
Send>
There is an intended space at the end of the above line so that I can send a space.
The problem is that the HTML adds in these unwanted spaces, or they could be line breaks, into the web page.
If we made Macro Scheduler remove them we would stop valid lines like the above one from working.
What we really need to do is find a way that allows people to post their code here in a way that the darn HTML doesn't mess with it. This is an issue with posting code on a web site, not with Macro Scheduler.
My preference is to create a way for people to upload their script files. They can then post their code but provide a link to the actual script file so that you download the actual file as it is intended. You can see code here for information but then download the file if you want to use it - that might be safer. We're looking into solutions in any case.
MJT Net Support
[email protected]
[email protected]
Try this
//Test
MessageModal>Hello
Let>k=4
Message>k
This now works - using the html tag. We'll add some instructions on the post page.
//Test
MessageModal>Hello
Let>k=4
Message>k
This now works - using the html tag. We'll add some instructions on the post page.
MJT Net Support
[email protected]
[email protected]
Testing new Code button modification
Hi,
This is a script I pasted in and then highlighted and then pressed the 'Code' button in the posting form.
ExecuteFile>c:\program files\mjt net ltd\macro scheduler\command_ref_7.1.pdf
WaitWindowOpen>Acrobat Reader*
Press ALT
Send>fp
Release ALT
WaitWindowOpen>Print
Press Enter
WaitWindowOpen>Acrobat Reader
WaitWindowClosed>Acrobat Reader
SetFocus>Acrobat Reader*
Press ALT
Send>fx
Release ALT
This simple script prints out the PDF command reference.
This is a script I pasted in and then highlighted and then pressed the 'Code' button in the posting form.
ExecuteFile>c:\program files\mjt net ltd\macro scheduler\command_ref_7.1.pdf
WaitWindowOpen>Acrobat Reader*
Press ALT
Send>fp
Release ALT
WaitWindowOpen>Print
Press Enter
WaitWindowOpen>Acrobat Reader
WaitWindowClosed>Acrobat Reader
SetFocus>Acrobat Reader*
Press ALT
Send>fx
Release ALT
This simple script prints out the PDF command reference.
Well, for instance, BASIC does not admit spaces as part of a variable name. Nor spaces at the end of instruction. They will be ignored.
Nor DOS nor Windows allow spaces as part of filenames.
I think it would be right that MacroScheduler does not allow spaces as part of variable names.
If do not, it woul be fine that MacroScheduler Editor has the feature of "remove spaces at the end of a line".
Instead of Send> for sending spaces, it would be better an instruction like "Press Space".
Another issue, I think it would be fine an instruction that allow sending several keystrokes, something like this:
Press>Enter,ALT,F4,F7
And other instruction like "ReleaseAll"
Nor DOS nor Windows allow spaces as part of filenames.
I think it would be right that MacroScheduler does not allow spaces as part of variable names.
If do not, it woul be fine that MacroScheduler Editor has the feature of "remove spaces at the end of a line".
Instead of Send> for sending spaces, it would be better an instruction like "Press Space".
Another issue, I think it would be fine an instruction that allow sending several keystrokes, something like this:
Press>Enter,ALT,F4,F7
And other instruction like "ReleaseAll"
Hi,
Space is a character - not a command key.
Does this mean that it should not be possible to do this:
Send>Hello World
But you suggest it should now be this:
Send>Hello
Press Space
Send>World
I will take on board your other suggestions however.
Space is a character - not a command key.
Does this mean that it should not be possible to do this:
Send>Hello World
But you suggest it should now be this:
Send>Hello
Press Space
Send>World
I will take on board your other suggestions however.
MJT Net Support
[email protected]
[email protected]