Runs on one computer, but not on another

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

BillB
Newbie
Posts: 9
Joined: Tue Oct 16, 2007 1:31 pm

Runs on one computer, but not on another

Post by BillB » Tue Oct 16, 2007 2:14 pm

Hi,

I have successfully written a script that works on my computer. However, when I use it on another computer (also Windows XP) I find that though most of it works, SHift Del, and Shift Ins are not working. The log file records them as having been 'used' - but nothing actually happens. I have had a similar problem on more than one machine.

I have tried using Ctrl C, Ctrl V, and that does not work either

Can you tell me what might be causing it?
Bill_no_expert

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 16, 2007 2:23 pm

You need to post your script for us really. Otherwise we have nothing to go on.

But:

1. Make sure you use lower case:
Press CTRL
Send>c
Release CTRL

2. 99.9% of issues like this are timing related. The script might work fine on yours, but may need more time on the other machine. You need to code your script to try not to use static wait times but intelligently wait for events to complete before trying to issue the next. The keysends could be happening too early. Might be fine on your PC but not on another. Make sure you are using commands like WaitWindowOpen/WaitWindowClosed etc. If you don't have any of this and only static waits then it will be unreliable.

3. Which OS is it? Could try setting SK_LEGACY to 1.

But post your script and we can then make recommendations for improvements.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BillB
Newbie
Posts: 9
Joined: Tue Oct 16, 2007 1:31 pm

Post by BillB » Thu Oct 18, 2007 12:15 pm

Marcus,

Thanks for the reply. I do think I am in the 0.1%!

The OS in both cases is windows XP.

I have written a short macro for Notepad, and even with no waits at all it works perfectly, as expected, on both computers. The second computer is a lot faster as well.

I know the code is not brilliant - but it does work on the slow laptop - but not on the fast desktop.

So the code is:

Code: Select all

label>Setfolder
//enter folder to save to: Browse, copy filename, write folder, pastefilename, save
	  Wait>1
	  MouseMove>792,573
	  Wait>1
	  LClick
	  Wait>1
	  MouseMove>528,541
	  wait>1
	  LDblClick
	  wait>1
	  Let>SK_LEGACY=1
	  Press Shift
	  Wait>1
	  Let>SK_LEGACY=1
	  Press Del
	  Wait>1
	  Release Shift
	  Wait>1
	  if>c=1
	  Wait>1
	  Send Character/Text>%outputfolder%\cam01\
	  Wait>1
	  endif
	  Wait>1
	  if>c=2
	  Wait>1
	  Send Character/Text>%outputfolder%\cam02\
	  Wait>1
	  endif
	  Wait>1
	  if>c=3
	  Wait>1
	  Send Character/Text>%outputfolder%\cam03\
	  Wait>1
	  endif
	  Wait>1
	  if>c=4
	  Wait>1
	  Send Character/Text>%outputfolder%\cam04\
	  Wait>1
	  endif
	  Wait>1
	  Let>SK_LEGACY=1
	  Press Shift
	  Wait>1
	  Let>SK_LEGACY=1
	  Press Ins
	  Wait>1
	  Release Shift


The application it is being used in is a viewing/editing app for security video recordings. It is not a 'standard looking' windows app.

Thanks,
Bill_no_expert

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Oct 18, 2007 12:32 pm

Humour me. Add this line to the top of the script:

Let>SCRIPT_DELAY=2000

It will slow the script down no end. So what. Let's just see if it makes any difference on this other machine. If it does we know we need to work on the timing somewhere and we can then narrow it down.

Have you watched the script run? Are you certain the correct window/s is/are focused? Is the window always in the same position? You are relying on absolute mouse positions so this is important. Is the resolution the same on the target computer to yours? If not, use MouseMoveRel or try to avoid using mouse events altogether. You have no SetFocus commands before sending keystrokes. How can you be sure the correct window is focused?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BillB
Newbie
Posts: 9
Joined: Tue Oct 16, 2007 1:31 pm

Post by BillB » Thu Oct 18, 2007 2:05 pm

I've tried that. No success.

I have watched the script run - the cursor is blinking with the text highlighted that I want to copy - and nothing happens! The window is always in the same position. I have even tried manually reselecting the text using mouse movements - that works, but still the copy paste sequence (and even the Send) does not work. I have just tried with a setfocus command - but this did did not work.

The macro begins by checking the resolution of the screen, and will only run at 1024 x 768.


I did most of this work months ago, and have a vague recollection of loading some software - I would say version 7 - on my computer to help scripts run... (my recollection is very vague...) But I do have a file in the folder I keep the original macroscheduer software in called MSSETup.exe - should I run this on the other machine?

I am clutching at straws (I do think it is one of the 0.1%!!

Thanks,
Bill_no_expert

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Oct 18, 2007 2:14 pm

Which is the code that you think should be doing a copy and paste? I don't see code that would do that.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BillB
Newbie
Posts: 9
Joined: Tue Oct 16, 2007 1:31 pm

Post by BillB » Thu Oct 18, 2007 2:18 pm

Sorry - I am not being precise. Shift Delete, and then Shift Insert.
Bill_no_expert

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Oct 18, 2007 2:28 pm

Have you tried CTRL+X and CTRL+V instead?

Press CTRL
Send>x
Release CTRL

Press CTRL
Send>v
Release CTRL
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Oct 18, 2007 2:54 pm

SCRIPT_DELAY may override this, but also consider using SK_DELAY. Try increasing that to a higher value.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Oct 18, 2007 3:21 pm

Hi BillB,

Old Keyboard Shortcuts:
  • SHIFT-Delete = Cut
    CTRL-Insert = Copy
    SHIFT-Insert = Paste
New Keyboard Shortcuts:
  • CTRL-x = Cut
    CTRL-c = Copy
    CTRL-v = Paste
My question would be, what is the state of the Caps Lock key on the failing machine? Make sure it is in the same state as the machine where your macro does work. If its different, that could be what's causing your problem.

Also, as Marcus recommended, why not use the newer Keyboard Shortcuts to accomplish these editting functions instead of the old? They do not make use of the SHIFT key so this eliminates any possible problems due to the unknown state of the Caps Lock key.

Hope this helps, take care.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

BillB
Newbie
Posts: 9
Joined: Tue Oct 16, 2007 1:31 pm

Post by BillB » Thu Oct 18, 2007 3:27 pm

Thanks for the suggestions. I have tried them - with no breakthrough!

CTRL x does not seem to work on my computer, let alone the faster desktop (though control V does - whatever I had last stored).
Bill_no_expert

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Oct 18, 2007 4:02 pm

BillB wrote:CTRL x does not seem to work on my computer, let alone the faster desktop (though control V does - whatever I had last stored).
That's odd, CTRL-x should perform a cut operation in Notepad. This is notepad.exe from Microsoft yes? Are you saying it does not work via the script or that it doesn't even work when you do it manually? If it doesn't even work manually, you may have bigger problems. Here's some further thoughts:

- Try CTRL-x in Notepad on another PC to prove to yourself that it does indeed work.

- Can you borrow another similar keyboard? If you can, swap it out with the problem machine to see if that makes a difference.

- Re-write your script using CTRL-c (copy) instead of CTRL-X (cut). Both will get the selected characters into the clipboard. If you actually need to delete the text after it has been copied into the clipboard, just add a separate Delete operation after copying (simulate a press of the Delete key).

- Unlikely but perhaps your notepad.exe file is damaged? Get a new copy from Microsoft's website and install.

By the way, what happens when you do CTRL-x or CTRL-c on the problem machine in Notepad? Are you getting an error message at all or is just "nothing" happening (i.e. the selected text is just not going into the clipboard)?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu Oct 18, 2007 4:32 pm

I don't think it's notepad, he wrote "The application it is being used in is a viewing/editing app for security video recordings. It is not a 'standard looking' windows app."

BillB
Newbie
Posts: 9
Joined: Tue Oct 16, 2007 1:31 pm

Post by BillB » Thu Oct 18, 2007 4:37 pm

Sorry - again I am being too brief!

Control c and x work fine on my computer when I use them manually in the application I want to control, and in notepad. They also work in a macro in Notepad. However control c does not work in the application when run by a macro - but control v does work. However shift del, and shift Ins do work on my computer in the application, even from a script. However they do not work on another desktop PC (when running in the macro - they are fine outside the macro).

The Capslock key is not on on either PC.

I have just tried ctrl c and it does not work in a script in the application on my PC.

Any more ideas??
Bill_no_expert

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Oct 18, 2007 5:10 pm

Looking at your script you are using single letter characters as variables. Specifically you are setting "c" to a value, therefore when you press ctrl then send "c" you are actually pressing ctrl plus the value of "c". Make your variables longer and more descriptive words and this might resolve some of your problems.

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