Solved

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

Posted on 2004-04-27
8
326 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
  • 6
  • 2
8 Comments
 
LVL 11

Author Comment

by:turn123
Comment Utility
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
Comment Utility

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
Comment Utility
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
 
LVL 11

Author Comment

by:turn123
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 11

Author Comment

by:turn123
Comment Utility
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
Comment Utility
I'm asking for this to be deleted as I never heard back from Dennis.

Turn123
0
 

Expert Comment

by:ctrondlp
Comment Utility
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
Comment Utility
> 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl - Mawk 2 69
unable to remove invisible characters with perl 2 66
syslog unix file 20 61
PERL - Find newest folder 12 101
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now