Is there "best" way to create a wrapper for press

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Is there "best" way to create a wrapper for press

Post by gdyvig » Tue Nov 04, 2008 6:51 pm

I am trying to write a wrapper subroutine that will work in a compiled script. Something like this:

SRT>DoThis
TimeStamp>%DoThis_Var_1%,%DoThis_Var_2%,...etc
MouseMove>%DoThis_Var_1%,%DoThis_Var_2%
Wait>%DoThis_Var_3%
%DoThis_Var_4%
Press %DoThis_Var_5%
Send Character/Text>%DoThis_Var_6%
Release %DoThis_Var_5%
End>Dothis

gosub>Dothis,X,Y,1,LClick,LShift,Hello Marcus

All the commands in the subroutine work except these:
%DoThis_Var_4%
Press %DoThis_Var_5%
(However, these commands do appear in the logfile)


I would rather my subroutine did not need a series of if statements to check for all the possible mouse , press or release actions.

I will have the same problem with any command whose syntax is not of the form "command>arg1,arg2,arg3..."

Is there a recommended way to do this?
Is a enhancement required?

Thanks,
Gale

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

Post by JRL » Tue Nov 04, 2008 7:01 pm

How about:

Code: Select all

SRT>DoThis
WriteLn>%temp_dir%dothis.scp,wres,TimeStamp>%DoThis_Var_1%,%DoThis_Var_2%,...etc
WriteLn>%temp_dir%dothis.scp,wres,MouseMove>%DoThis_Var_1%,%DoThis_Var_2%
WriteLn>%temp_dir%dothis.scp,wres,Wait>%DoThis_Var_3%
WriteLn>%temp_dir%dothis.scp,wres,%DoThis_Var_4%
WriteLn>%temp_dir%dothis.scp,wres,Press %DoThis_Var_5%
WriteLn>%temp_dir%dothis.scp,wres,Send Character/Text>%DoThis_Var_6%
WriteLn>%temp_dir%dothis.scp,wres,Release %DoThis_Var_5%
Macro>%temp_dir%dothis.scp
Deletefile>%temp_dir%dothis.scp
End>Dothis

gosub>Dothis,X,Y,1,LClick,LShift,Hello Marcus

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

Re: Is there "best" way to create a wrapper for pr

Post by Marcus Tettmar » Tue Nov 04, 2008 7:33 pm

gdyvig wrote: All the commands in the subroutine work except these:
%DoThis_Var_4%
Press %DoThis_Var_5%
Version 11 will allow you to do that. Until then the Press... commands are commands in and of themselves. With v11 you can optionally make Press work as a function taking the key as a parameter.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Mouse commands too?

Post by gdyvig » Tue Nov 04, 2008 8:02 pm

Very good!

Are you planning to consolidate the mouse click commands into a function for a future release?

JRL's method of creating a macro on the fly works provided you are running the compiled macro on a machine with MS installed, similar to my "Evaluate Command" enhancement suggestion a few weeks ago.

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

Post by JRL » Tue Nov 04, 2008 9:22 pm

JRL's method of creating a macro on the fly works provided you are running the compiled macro on a machine with MS installed,
From my happy button post.
For anyone who's interested there's a couple of interesting tidbits in here... a workaround for a non-modal Macro> function. (Will work as a script or compiled.)
Here is the above rewritten to run as both a script and/or a compiled script. (I did not test this so I could have left something out but it "looks" right.) :)

EDIT:Fixed the posted script (below) and tested it to be sure it works.

Code: Select all

//Determine if the process is a script or an exe
//Set mProcessor variable accordingly
StringReplace>%COMMAND_LINE%,",,COMMAND_LINE
VBSTART
VBEND
VBEval>Lcase("%COMMAND_LINE%"),COMMAND_LINE
Position>.exe,%COMMAND_LINE%,1,exe_loc
Add>exe_loc,4
Midstr>%COMMAND_LINE%,1,%exe_loc%,COMMAND_LINE
Separate>%COMMAND_LINE%,\,prossvar
Let>value=prossvar_%prossvar_count%
Separate>value,.,value
If>%value_1%=msched
  Let>mProcessor=%COMMAND_LINE%%SPACE%
Else
  Let>mProcessor=%COMMAND_LINE% /Script=
EndIf

//If the variable "Script" has a value, then this executable has been
//invoked by itself as a script processing agent.  Run the script then exit.
Ass>Script,RunScript
If>RunScript=TRUE
  Macro>Script
  Goto>EOF
EndIF

SRT>DoThis
WriteLn>%temp_dir%dothis.scp,wres,TimeStamp>%DoThis_Var_1%,%DoThis_Var_2%,...etc
WriteLn>%temp_dir%dothis.scp,wres,MouseMove>%DoThis_Var_1%,%DoThis_Var_2%
WriteLn>%temp_dir%dothis.scp,wres,Wait>%DoThis_Var_3%
WriteLn>%temp_dir%dothis.scp,wres,%DoThis_Var_4%
WriteLn>%temp_dir%dothis.scp,wres,Press %DoThis_Var_5%
WriteLn>%temp_dir%dothis.scp,wres,Send Character/Text>%DoThis_Var_6%
WriteLn>%temp_dir%dothis.scp,wres,Release %DoThis_Var_5%

//Run msched.exe %temp_dir%dothis.scp or thisexe.exe %temp_dir%dothis.scp
Run>%mProcessor%%temp_dir%dothis.scp

Deletefile>%temp_dir%dothis.scp
End>DoThis

gosub>DoThis,200,200,1,LClick,LShift,Hello Marcus

Label>EOF

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