clipboard contents not recognised

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

guest

clipboard contents not recognised

Post by guest » Wed Dec 18, 2002 1:48 am

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Dec 18, 2002 1:53 am

Hi Guest,

What's your Label>End?
Please help.

Armstrong Wong
Hong Kong

guest

Post by guest » Wed Dec 18, 2002 3:34 am

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.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Dec 18, 2002 5:03 am

Hi Guest,

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

Guest

Post by Guest » Wed Dec 18, 2002 5:53 am

:D Solved the problem. I had a space at the end of 'field' as the variable in the Getclipboard>
When I tried to use the variable, it wasn't recognising it because there was no space at the end.

Thanks

Ernest

Post by Ernest » Wed Dec 18, 2002 8:24 am

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Dec 18, 2002 11:44 am

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

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Dec 18, 2002 8:54 pm

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.
MJT Net Support
[email protected]

FS

Post by FS » Thu Dec 19, 2002 6:37 pm

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.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 19, 2002 6:42 pm

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.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Dec 19, 2002 6:45 pm

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.
MJT Net Support
[email protected]

Guest

Testing new Code button modification

Post by Guest » Thu Dec 19, 2002 7:47 pm

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.

FS

Post by FS » Fri Dec 20, 2002 10:22 am

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"

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Dec 20, 2002 10:49 am

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.
MJT Net Support
[email protected]

Ernest

Post by Ernest » Fri Dec 20, 2002 11:25 am

Hi,
what about a %SPACE% equivalent to %CRLF% :?:

Code: Select all

Send>Hello%SPACE%World
Ernest

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts