Solved

Win32::GuiTest sends | instead of \ for a random amount charecters.

Posted on 2004-04-27
8
335 Views
Last Modified: 2010-05-18
I'm not sure what is wrong but the output of the code below will be anything from \\server\d\Jonathan\invoice.pdf to ||SERVER|D|jONAthan\\invoice.pdf

What is the problem and how do I fix it?

Thank you,
Turn123

##      Open and print PDF
SendKeys("{LWIN}r");
SendKeys("\\\\server\\d\\Jonathan\\invoice.pdf~");
sleep 2;
SendKeys("^p~");
sleep 5;
0
Comment
Question by:turn123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 11

Author Comment

by:turn123
ID: 11059339
Full code:

###      Extracts the shipping and notification information from quickbooks

use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow SendKeys);
      $Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode
use Win32::GUI;
use strict;

##      Check to see if our import file exists.
if (-e 'import.txt') {
      #      If it doesn't we create a new one.
      open CREATE, "> \\\\shipping\\data import\\import.txt";
      close CREATE;
} else {
      #      If it does we do nothing. (under development)
      open CREATE, "> \\\\shipping\\data import\\import.txt";
      close CREATE;
};

##      We delete all the html and pdf files left over from the last run
while (my $line = <*>) {
      unlink $1 if $line =~ /(.*\.html)/i;
      unlink $1 if $line =~ /(.*\.pdf)/i;
};

##      Defining the varibales
my $line="";
my $a=0;
my $b=1;
my @invoice=();
my @baddress=();
my @saddress=();
my @PO=();
my @carrier=();
my @partnumber=();
my @quantity=();
my @priceeach=();
my @price=();
my @description=();
my @email=();

##      Give QuickBooks Focus
my @windows = FindWindowLike(0, "^Osborne Wood Products, Inc - QuickBooks");
for (@windows) {
      Win32::GUI::Maximize($_);
      SetForegroundWindow($_);
      SendKeys("%ffi");                              ##       We batch print the invoice form
      sleep 6;                                    #      Wait for the invoices to load
      SendKeys("~");                                    #      Hit enter
      sleep 5;                                    #      Wait for the print screen
      SendKeys("p%c");                              #      Change the printer to the pdf printer and go to the number of copies
      SendKeys("1");                                    #      And set it to 1
      sleep 2;                                    #      Wait for it to take the change
      SendKeys("~");                                    #      And print
      ##      Giving script focus
      @windows = FindWindowLike(0, "Invoice Importer");
      for (@windows) {
            print "$_>\t'", GetWindowText($_), "'\n";
            SetForegroundWindow($_);
      };
      system 'pause';                                    #      Manual breakpoint for user to continue when all documents are printed
};

sleep 1;
##      Open the PDF Editor and converts the pdf file to html documets
SendKeys ("{LWIN}rC:\\pdf995\\res\\utilities\\pdfEdit995\.exe~");
sleep 4;
SendKeys ("^{TAB 9}{TAB 4}~{TAB}~invoice.pdf~{TAB 3}~invoice.html~");

##      Clean up after ourselves
while (1) {
      my $flag = "";
      @windows = FindWindowLike(0, "^Intuit");
      for (@windows) {
            $flag = 1;
      };
      last if $flag == 1;
      sleep 2;
};
SendKeys ("%{F4}%{F4}%{F4}");                        #      Closes html index and PDF editor
sleep 1;

##      Open and print PDF
SendKeys("{LWIN}r");
SendKeys("\\\\server\\d\\Jonathan\\invoice.pdf~");
sleep 2;
SendKeys("^p~");
sleep 5;
0
 

Accepted Solution

by:
ctrondlp earned 500 total points
ID: 11124885

Hello,

Based on what you are seeing "||SERVER|D|jONAthan\\invoice.pdf vs. \\server\d\Jonathan\invoice.pdf", it looks like some sort of problem "surrounding" the shift key.  

A couple of thoughts:
1) Make sure the shift key is working correctly (i.e. isn't stuck).
2) Try typing the key sequence (\\server\....) manually and see if the same problem (||SERVER|D|....) persists.  
3) You could even beef-up the script by replacing many of the SendKeys() statements with better Win32::GuiTest commands (i.e., WMSetText, MenuSelect, WaitWindow, etc.; which are available in Win32-GuiTest-ad v1.50.1 (http://sourceforge.net/projects/winguitest))
4) And lastly, an initial script recorder for Win32::GuiTest can be found at http://dkp.itgo.com...  It is still in development, but it might help in certain cases.


Regards,
Dennis K. Paulsen
0
 
LVL 11

Author Comment

by:turn123
ID: 11125615
ctrondlp,

>1) Make sure the shift key is working correctly (i.e. isn't stuck).
First think I tried.

>2) Try typing the key sequence (\\server\....) manually and see if the same problem (||SERVER|D|....) persists.  
It doesn't happen if you type it in manually.

>3) You could even beef-up the script by replacing many of the SendKeys() statements with better Win32::GuiTest commands (i.e., WMSetText, MenuSelect, WaitWindow, etc.; which are available in Win32-GuiTest-ad v1.50.1 (http://sourceforge.net/projects/winguitest))
>4) And lastly, an initial script recorder for Win32::GuiTest can be found at http://dkp.itgo.com...  It is still in development, but it might help in certain cases.
These look interesting.  I'll look into them as soon as I get a chance and let you know what I come up with.

Thanks for taking the time to look at this.

Turn123
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Author Comment

by:turn123
ID: 11127440
Dennis,

When trying to install I'm getting Error: no suitable installation target found for package Win32-GuiTest.

ppm> install C:\Downloads\Win32-GuiTest-1.50.1-ad\win32-guitest.ppd
Error: no suitable installation target found for package Win32-GuiTest.

What should I do differently?

Turn123
0
 
LVL 11

Author Comment

by:turn123
ID: 11197255
Dennis,

Any suggestions on how I can install the package to see if it solves my problem?

Turn123
0
 
LVL 11

Author Comment

by:turn123
ID: 11284279
I'm asking for this to be deleted as I never heard back from Dennis.

Turn123
0
 

Expert Comment

by:ctrondlp
ID: 11284509
You could try using v5.6.1 of Perl that supports Win32-GuiTest-1.50.1-ad or you could use v5.8.x of Perl and use Win32-GuiTest-1.50.2-ad...  Or you could use the build instructions included in the README to manually install it.  Easy as pie. :-)


Once you get things going and for some odd/out-of-the-ordinary reason it still appears to use the shift modifier on characters (\ becomes |), try adding the following line several places within your script: SendRawKey(VK_LSHIFT, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP);


-D
0
 
LVL 11

Author Comment

by:turn123
ID: 11284843
> Easy as pie. :-)
Yeah right :-(.

I actualy got it to do what I wanted using the Win32::Clipboard module which seems like a better solution.

Turn123
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question