自动化前处理 Win32-GuiTest-1.56

来源:互联网 发布:虚假交友app源码 编辑:程序博客网 时间:2024/04/30 07:50

前提条件:

·         安装 ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi

·         安装Win32-GuiTest-1.56.tar.gz,具体方法见README文件
·         显示器:1280*1024,或者修改 Autotrans.pl 中 MouseMoveAbsPix( 120, 674 ); 和 MouseMoveAbsPix( 120, 419 ); 的坐标值。

具体过程:

运行 update.bat 脚本,内容如下

@echo off
set LSCMD=C:/Program Files/LocStudio/LSCMD.exe

rem Note LanguageList has LanguageName;LCID, for example DEDE;0x0407
rem edit LanguageList.txt to your needs.
set Token1=LanguageList.txt
Set Token2=SourceFileList.txt

rem This sets the default view for Locstudio.
C:/Automation_Axapta/Autotool_Scripts/AX50_LS_View.reg

echo Please enter in root folder (path above Master):
set /p rootlocation=

rem set /p LANG=   ARAR, ZHCN, JAJP, FRCH
rem |- Master
rem    -- source
rem |- <LANG>
rem    -- target
rem    --- RCM_<LANG>.edb

echo.

 dir /b/s/on "%rootlocation%/Master/axRCM*.ald">SourceFileList.txt
 for /F "usebackq delims=; tokens=1,2" %%a in (%TOKEN1%) do (
  
  echo -----------------------------
  rem echo Creating edb for %%a_RCM.edb
  rem "%LSCMD%" "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" /CREATE /TL %%b /SL 0x0409 /s -p "../Master/source" /t -p "./target"
  
  for /F "usebackq delims=; tokens=1*" %%x in (%TOKEN2%) do (
   echo Adding source file %%~nxx to %%a_RCM.edb...
   "%LSCMD%" "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" /Add "%%x"
  )
  
  rem echo.
     rem echo load LS48_Settings.lss...
     rem Note C:/Program Files/LocStudio/LS48_Settings.lss is hard coded here.
     rem "%LSCMD%" "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" /LOADS "C:/Program Files/LocStudio/LS48_Settings.lss"

  echo.
  echo Updating...
  "%LSCMD%" /U "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb"
 
  echo.
  echo Import Master Instructions/Usr src Lock/Custom4
  "%LSCMD%" "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" /IMP -IN "%rootlocation%/MASTER/UPD/RCM/MASTER_RCM.edb" -LS -C4 -I
  
  echo.
  echo Locver...
  "%LSCMD%" "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" /X "Verify Localization Rules" -OUT "%%a_LOCVER_Report.txt"
  
  echo.
  echo leverage...
  
  
Autotrans.pl "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" "%rootlocation%/%%a/UPD/RCM/%%a_AXAPTA500.EDB"
  rem  ../%%a_RCM.edb" 是要翻译的 EDB /%%a_AXAPTA500.EDB 是用作 glossary EDB
  echo.
  echo Statistics...
  "%LSCMD%" "%rootlocation%/%%a/UPD/RCM/%%a_RCM.edb" /X "Statistics"
 )

)
del /q SourceFileList.txt
echo -----------------------------
echo Process completed.
echo.
pause


 

其中 Autotrans.pl 用于自动翻译。内容如下

#!C:/Perl/bin/perl.exe -w
####################################
# for MBS AX UI pre process
#
judy.su@lionbridge.com
# version 1.0 open edb, add glossary, autotrans all
# 2009-1-21
# This script used to:
# open EDB --> add a glossary --> autotranslate --> remove 3 glossaries at most.
####################################

use Win32::GuiTest qw( :ALL);
    use strict;
    #or ($ARGV[0] ne "D://temp//TRTR_RCM.edb")
    if (not @ARGV or (not $ARGV[1])) {
    #if ($ARGV[1] eq 0) {
    die "Usage: $0 <EdbName>.edb <GlossaryFullPath>.edb/n"
} # end if

##############################################################################
#----------------------to Open EDB sub-------------------

sub openEDB {
    system("start msloc");
    sleep 3;

    my @whnds = FindWindowLike( undef, "^Microsoft Localization Studio" );
    if(
!@whnds ){
        die "Cannot find window with title/caption Microsoft Localization Studio/n";
    }else{
        printf( "Window handle of Microsoft Localization Studio application is %x/n", $whnds[ 0 ] );
    }

SetForegroundWindow( $whnds[ 0 ] );
    #SendKeys("%{V}{u}"); #full screen
    SendKeys( "%{SPACE}{x}",50 );# max window
    SendKeys( "%{0}",50 );# max window
    sleep 2;
    SendKeys("%{F}");
    SendKeys("{DOWN}");
    SendKeys( "~",25 );
    SendKeys("%{N}",100);
    SendKeys("$ARGV[0]",25);# open input EDB
    SendKeys( "~" );
   
    } #end of openEDB
   
sub rmgls {
    SendMouse( "{LEFTCLICK}",50 ); #click ref glossary, mouse at (120, 415)
    SendKeys( "{DOWN}",50 );
    SendKeys( "%{F}{r}" ); #reomve glossary
    }
########################################################################
   
 system("C://Automation_Axapta//Autotool_Scripts//AX50_LS_View.reg");
 SendKeys( "~",100 );
 SendKeys( "~",100 );
   
    openEDB;
   
    MouseMoveAbsPix( 120, 674 ); #Mouse move to Glossary view-------------------------------------
    #MouseMoveAbsPix( x, y);
    SendMouse( "{LEFTCLICK}" ); # right click on Glossary View tab
    sleep 1;
    MouseMoveAbsPix( 120, 419 ); # select Ref GLossary
    #MouseMoveAbsPix( x, y);
   
    SendKeys( "{DOWN}",50 ); 
    SendKeys( "{RIGHT}",50 );
    SendMouse( "{RIGHTCLICK}" ,50); # open right mouse menu
    SendKeys( "{DOWN}" ); #add a Glossary
    SendKeys( "~" );
    SendKeys("$ARGV[1]",50); # $ARGV[1] the glossary full path
    SendKeys( "~" );
    SendKeys( "{F4}",50 );
    SendKeys( "%{R}{t}",50 ); #autotranslate
    
    sleep 50; #waite for translation finish
 SendKeys( "~",100 );
 
    rmgls;
    rmgls;
    rmgls;
    SendKeys( "%{F4}",50 );
# go back to cmd

参考链接:

http://search.cpan.org/~karasik/Win32-GuiTest-1.56/lib/Win32/GuiTest.pm

http://www.piotrkaluski.com/files/winguitest/docs/winguitest.html