RE: Win32::OLE

2003-09-18 Thread Martin Bower
ok , last question(s)promise

1. how can I get the current window status? (e.g is it minimised?).  I found
a Win32 call IsWindowVisible(HWND hWnd) , but am unsure of how to call this.
2. where's a good place/book to pick up Win32::API programming ?

Martin



-Original Message-
From: Martin Bower [mailto:[EMAIL PROTECTED]
Sent: 18 September 2003 15:39
To: 'Groenwold, Harmen (ICT) (HK)';
[EMAIL PROTECTED]
Subject: RE: Win32::OLE


cool, thanks v much.

I just googled and added the following 2 lines to restore the window to its
previous position if it had been minimsed.

my $ShowWindow = new Win32::API('user32', 'ShowWindow', 'NN', 'N');
$ShowWindow->Call($outlook_window_handle,9);

thanks for your help, it's very much appreciated.

Martin



-Original Message-
From: Groenwold, Harmen (ICT) (HK) [mailto:[EMAIL PROTECTED]
Sent: 18 September 2003 14:42
To: 'Martin Bower'; [EMAIL PROTECTED]
Subject: RE: Win32::OLE


Hi,
This took me a while to figure out, but I think I got the solution to your
problem.

First, the Win32::Process, Win32::Process::Info or even Win32::OLE seem not
to help in any way to achieve what you want. I've gone through quite some
VBA documentation for Outlook and it seems that VBA doesn't have any way to
bring a window to the front.

Thankfully, deep in the Win32 API there are some functions to do this! If
you know a WHND (a windowhandle that has a LONG value), it's quite easy.
However, it's difficult get a WHND. If you know the string in a titlebar of
a window, it isn't that difficult. For example: start CALC.EXE, the string
in the titlebar is 'Calculator', use the FindWindow API call to get the WHND
from this window. But Outlook doen't have one simple string in the titlebar.
If you select the Tasks folder in Outlook, the titlebar changes to 'Tasks -
Microsoft Outlook'. If you select the Contacts folder, the titlebar changes
to 'Contacts - Microsoft Outlook'. See the problem?

One API call saves the day however: EnumWindows. Like the name says, it
enumerates through all windows and with a callback function (see the
Win32::API::Callback documentation) we can link titlebars and windowhandles!
Now, use some good old regex and... Voila! We know which handle to use.
After this, it's a walk in the park.

The following script works fine on my machine. Let me know if it works on
yours.
My machine: Windows XP Pro, Office XP Pro, ActivePerl build 806, latest
version of Win32::API by using PPM.

The script:

==
use warnings;
use strict;

use Win32::API;
use Win32::API::Callback;

# First, we need to get all the titlebar strings from all
# active windows. We need this to figure out what
# WINDOWHANDLE the Outlook window has.

# Set up a hash to store the WINDOWSHANDLEs as key
# and the titlebar strings as value
my %windowhandle_titlebar;
# We need a scalar in the $callback function. This
# needs to be declared before the function
my $title_bar;

# We need a callback function for the EnumWindows WinAPI function.
# This callback object includes a function that fills the hash.
my $callback = Win32::API::Callback->new(sub
  {my $handle=$_[0];$title_bar = subGetTitle($handle);
   $windowhandle_titlebar{$handle}= $title_bar; return 1;},
  'N', 'I');

# This is a sub that gets a WINDOWHANDLE (which is a just simply a LONG).
# The sub returns the titlebar of the window which WINDOWHANDLE is supplied
sub subGetTitle {
  my $win_handle = $_[0];
  my $title_bar_size = 50;
  my $title_bar = ' ' x $title_bar_size;
  my $get_window_text = new Win32::API('user32', 'GetWindowText', 'NPI',
'I');
  my $return_val2 = $get_window_text->Call($win_handle, $title_bar,
$title_bar_size);
  return $title_bar;
}

# define $enum_windows as a Win32::API object
my $enum_windows = new Win32::API('user32', 'EnumWindows', 'KN', 'I');
# some errorhandling... can be done better...
if(not defined $enum_windows) {
  die "Can't import API EnumWindows: $!\n";
}

# do I really need this parameter?
my $my_parameter_string = 1;

# watch this! here we start the EnumWindows API call
# now the hash %windowhandle_titlebar gets filled
my $return_val1 = $enum_windows->Call($callback, $my_parameter_string);

# Let's walk through the hash to get the handle of the
# window which has /\s-\sMicrosoft\sOutlook/ in the titlebar.
# check this regex first if this script doesn't work for you
# because I've tested this only on Office/Outlook XP.
# Other versions of Outlook might behave differently...
my $outlook_window_handle;
while ((my $hashkey, my $hashvalue) = each (%windowhandle_titlebar)) {
  if ($hashvalue =~ m/\s-\sMicrosoft\sOutlook/) {
$outlook_window_handle = $hashkey;
  }
}

# Now that we have a WINDOWHANDLE (which is by for the most
# difficult), we can use this to call the SetForegroundWindow API call.
# First, declare the function by using Win32::API
my $SetForegroundWindow = new Win32::API('user32', 'SetForegroundWindow',
'N', 'I');
# some e

Re: OT: Regex humor

2003-09-18 Thread Carl Jolley
On Thu, 18 Sep 2003, Ted Schuerzinger wrote:

> This, I suppose, is proof that computers are only as bright as the people
> who program them, and a good lesson on being careful what you look for in
> your regexes  :-)
>
> I've noticed that spammers sometimes try to get around people's spam
> filters by using commas or understrokes or somesuch between each letter of
> a word that might otherwise raise a warning flag, eg. s,e,x or m|o|n|e|y!
> So, I set the following line in my spam filter (Hamster) to get the more
> common ones I see:
>
> =kill() Subject: {f.r.e.e.} {v.i.a.g.r.a.}
>
> I haven't gotten many hits on this filter, but finally did this morning:
>

I find that using [^a-z]+ as a letter seperator is more effective,
especially when spammers use such text as V~ I~ A~ G~ R~ A

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Duplicate lines in text file.

2003-09-18 Thread Octavio Heredia
Title: Duplicate lines in text file.






Hello all,


I have an excel spreadsheet with over 20K lines in it and some

of these have the same "name" as one of the columns but the other

fields might be different. I have been tasked with identifying all records

that have the same "name". 


I can save the spreadsheet into a tab delimited file which gives me a

line that looks like this (tabs are in between since it is a tab delimited file).


1   8   122345  1235    P233    SWC NAME WOULD BE HERE  4   A   


Any other line matches the "NAME WOULD BE HERE", I need to write it to a

second file "duplicates.txt".


Thank you very much for any help you could provide.


Octavio Heredia





Re: newbie hlelp!

2003-09-18 Thread $Bill Luebkert
Lee Goddard wrote:

> Did/do you say braces or square brackets?
> Did you specify the style of parenthesis:
> looked to me like the significance was as
> implicit in your sentence as mine.
> 
> How about:
> 
>() - plain/round parenthesis/brackets
>[] - square parenthesis/brackets
>{} - curly parenthesis/brackets, set delimiters (maybe not)
><> - angle brackets; greater-/less-than
> 
> Really, though, bull aside, do you Yankees really
> think () are not brackets?  Or [] aren't?

Dictionary definitions are indented after each symbol pair:

() parentheses (parens for short)
1. Either or both of the upright curved lines, ( ), used to mark
off explanatory or qualifying remarks in writing or printing or
enclose a sum, product, or other expression considered or treated
as a collective entity in a mathematical operation.

{} braces
3.  Chiefly British. Suspenders.
14. Mathematics. Either of a pair of symbols, { }, used to indicate
aggregation or to clarify the grouping of quantities when
parentheses and square brackets have already been used.

Brackets:
[] brackets (or square brackets)
4. a. A square bracket.
<> angle brackets
4. b. An angle bracket.
5. Chiefly British. One of a pair of parentheses.

Apparently the Brits call all of these brackets, but that makes it
kinda hard to tell which you're talking about doesn't it.  :)

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Reg Expression missing last char?

2003-09-18 Thread $Bill Luebkert
Adam Ingerman wrote:

> when debugging, I tend to be more direct in variable checking, this might be 
> evern better for you (add another \n if it's liable to be a long line, and 
> change the ' to another character if need be)
> 
> print "\$1\t'$1'\n\$2\t'$2'\n\$3\t'$3'\n";
> 
> sure, it doesn't look much there, but it does help when you use it, eg:
> 
> 
> $1variable
> $2name
> $3is

This is easier and picks up up to 9 (or more if you like):

for (1..9) { eval "print \"$_: \", \$$_, \"\n\" if defined \$$_"; }

and you can wrap it in an if $debug for testing.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: newbie hlelp!

2003-09-18 Thread Arms, Mike
Lee Goddard ([EMAIL PROTECTED]) wrote:
> How about:
> 
>() - plain/round parenthesis/brackets
>[] - square parenthesis/brackets
>{} - curly parenthesis/brackets, set delimiters (maybe not)
><> - angle brackets; greater-/less-than
> 
> Really, though, bull aside, do you Yankees really
> think () are not brackets?  Or [] aren't?

Well, I'm taking a chance in replying to this thread that
Lee isn't just trolling or having a good laugh. To answer
your question, No, I do not think () are brackets. Here goes
from a Yankee's perpective:

  () - parentheses (or shortened as parens)
  [] - brackets (or referred to as square brackets if the other person
doesn't understand)
  {} - braces (or referred to as curly braces if the other person doesn't
understand)
  <> - angle brackets (or referred to as less-than greater-than if the other
person doesn't understand)

While we're at it, some more computer geek lingo:

  !  - bang; as in "!!" is "bang-bang" to repeat the last command in many
Unix shells
  #  - pound
  *  - star
  /  - slash
  \  - backslash
  |  - pipe

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


OT: Regex humor

2003-09-18 Thread Ted Schuerzinger
This, I suppose, is proof that computers are only as bright as the people 
who program them, and a good lesson on being careful what you look for in 
your regexes  :-)

I've noticed that spammers sometimes try to get around people's spam 
filters by using commas or understrokes or somesuch between each letter of 
a word that might otherwise raise a warning flag, eg. s,e,x or m|o|n|e|y!  
So, I set the following line in my spam filter (Hamster) to get the more 
common ones I see:

=kill() Subject: {f.r.e.e.} {v.i.a.g.r.a.}

I haven't gotten many hits on this filter, but finally did this morning:



[Hamster]

A mail-message on pop.bestweb.net (fedya) was deleted due to mail-filters.
-> =kill() Subject: {f.r.e.e.} {v.i.a.g.r.a.}
Size of mail: 2,388 bytes

-- Headers and first 20 lines of message follow: --

[...]

From: "Pa Pell" <[EMAIL PROTECTED]>
To: "Bayete Leriche" <[EMAIL PROTECTED]>
Subject: Cool university degree deal for everybody!


Well, it *does* match the regex, after all!  :-)

--
Ted Schuerzinger, [EMAIL PROTECTED]
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::OLE

2003-09-18 Thread Martin Bower
cool, thanks v much.

I just googled and added the following 2 lines to restore the window to its
previous position if it had been minimsed.

my $ShowWindow = new Win32::API('user32', 'ShowWindow', 'NN', 'N');
$ShowWindow->Call($outlook_window_handle,9);

thanks for your help, it's very much appreciated.

Martin



-Original Message-
From: Groenwold, Harmen (ICT) (HK) [mailto:[EMAIL PROTECTED]
Sent: 18 September 2003 14:42
To: 'Martin Bower'; [EMAIL PROTECTED]
Subject: RE: Win32::OLE


Hi,
This took me a while to figure out, but I think I got the solution to your
problem.

First, the Win32::Process, Win32::Process::Info or even Win32::OLE seem not
to help in any way to achieve what you want. I've gone through quite some
VBA documentation for Outlook and it seems that VBA doesn't have any way to
bring a window to the front.

Thankfully, deep in the Win32 API there are some functions to do this! If
you know a WHND (a windowhandle that has a LONG value), it's quite easy.
However, it's difficult get a WHND. If you know the string in a titlebar of
a window, it isn't that difficult. For example: start CALC.EXE, the string
in the titlebar is 'Calculator', use the FindWindow API call to get the WHND
from this window. But Outlook doen't have one simple string in the titlebar.
If you select the Tasks folder in Outlook, the titlebar changes to 'Tasks -
Microsoft Outlook'. If you select the Contacts folder, the titlebar changes
to 'Contacts - Microsoft Outlook'. See the problem?

One API call saves the day however: EnumWindows. Like the name says, it
enumerates through all windows and with a callback function (see the
Win32::API::Callback documentation) we can link titlebars and windowhandles!
Now, use some good old regex and... Voila! We know which handle to use.
After this, it's a walk in the park.

The following script works fine on my machine. Let me know if it works on
yours.
My machine: Windows XP Pro, Office XP Pro, ActivePerl build 806, latest
version of Win32::API by using PPM.

The script:

==
use warnings;
use strict;

use Win32::API;
use Win32::API::Callback;

# First, we need to get all the titlebar strings from all
# active windows. We need this to figure out what
# WINDOWHANDLE the Outlook window has.

# Set up a hash to store the WINDOWSHANDLEs as key
# and the titlebar strings as value
my %windowhandle_titlebar;
# We need a scalar in the $callback function. This
# needs to be declared before the function
my $title_bar;

# We need a callback function for the EnumWindows WinAPI function.
# This callback object includes a function that fills the hash.
my $callback = Win32::API::Callback->new(sub
  {my $handle=$_[0];$title_bar = subGetTitle($handle);
   $windowhandle_titlebar{$handle}= $title_bar; return 1;},
  'N', 'I');

# This is a sub that gets a WINDOWHANDLE (which is a just simply a LONG).
# The sub returns the titlebar of the window which WINDOWHANDLE is supplied
sub subGetTitle {
  my $win_handle = $_[0];
  my $title_bar_size = 50;
  my $title_bar = ' ' x $title_bar_size;
  my $get_window_text = new Win32::API('user32', 'GetWindowText', 'NPI',
'I');
  my $return_val2 = $get_window_text->Call($win_handle, $title_bar,
$title_bar_size);
  return $title_bar;
}

# define $enum_windows as a Win32::API object
my $enum_windows = new Win32::API('user32', 'EnumWindows', 'KN', 'I');
# some errorhandling... can be done better...
if(not defined $enum_windows) {
  die "Can't import API EnumWindows: $!\n";
}

# do I really need this parameter?
my $my_parameter_string = 1;

# watch this! here we start the EnumWindows API call
# now the hash %windowhandle_titlebar gets filled
my $return_val1 = $enum_windows->Call($callback, $my_parameter_string);

# Let's walk through the hash to get the handle of the
# window which has /\s-\sMicrosoft\sOutlook/ in the titlebar.
# check this regex first if this script doesn't work for you
# because I've tested this only on Office/Outlook XP.
# Other versions of Outlook might behave differently...
my $outlook_window_handle;
while ((my $hashkey, my $hashvalue) = each (%windowhandle_titlebar)) {
  if ($hashvalue =~ m/\s-\sMicrosoft\sOutlook/) {
$outlook_window_handle = $hashkey;
  }
}

# Now that we have a WINDOWHANDLE (which is by for the most
# difficult), we can use this to call the SetForegroundWindow API call.
# First, declare the function by using Win32::API
my $SetForegroundWindow = new Win32::API('user32', 'SetForegroundWindow',
'N', 'I');
# some errorhandling... needs more...
if (not defined $SetForegroundWindow) {
  die "Can't import API SetForegroundWindow: $!\n";
}
# And finally, this is the call that does what you wanted.
# It brings to the foreground the wanted window
my $return_val = $SetForegroundWindow->Call($outlook_window_handle);


=
End script

Start Outlook, set another window on top (i.e.

Re: newbie hlelp!

2003-09-18 Thread Lee Goddard
At 19:18 17/09/2003, you wrote:
Lee Goddard wrote:

> Brackets, parenthesis, the terms change over the Atlantic:
> that's just pedantry, Bill :)
That's just bull, Lee. :)  If you can't have common terminology,
how can you have a reasonable discussion about programming which
requires explicit terminolgy ?
Did/do you say braces or square brackets?
Did you specify the style of parenthesis:
looked to me like the significance was as
implicit in your sentence as mine.
How about:

  () - plain/round parenthesis/brackets
  [] - square parenthesis/brackets
  {} - curly parenthesis/brackets, set delimiters (maybe not)
  <> - angle brackets; greater-/less-than
Really, though, bull aside, do you Yankees really
think () are not brackets?  Or [] aren't?
>> $file[9], why doesn't @{ stat($file) }[9] work?
>
> I don't mean to argue, I really am curious.
I'm guessing that is forcing a scalar context for 'stat($file)' when you
need a list context.
Could be. I really ought to invest in looking at the
source for this thing...
Cheers!
Lee

Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How to launch Internet Explorer from perl script ?

2003-09-18 Thread Lee Goddard
Maybe not exactly what you want, but it's fun to play with:
forgive the untrimmed code.
# Copyright (C) 2003, Little Bits Ltd:
# All rights reserved.
#
# use LBL;
#
use Win32::OLE; #  qw( EVENTS in with valof );
use Win32::OLE::Variant;
use LWP::UserAgent;
use strict;
use Win32::Process;
use Win32;
our $VERSION = 0.2;
my ($res,$req);
my $url = new URI ("http://localhost/photoserver";);
Win32::OLE->Option( Warn => 0 );

my $args = {
 application_name} => "x",
 width => 626,
 height => 397,
 try_time => 20,
};
my $IE = Win32::OLE->GetActiveObject( 'WebBrowser.Application' );
if( ! defined $IE ){
$IE = Win32::OLE->new( 'InternetExplorer.Application', "Quit" )
|| die "Cannot find Internet Explorer to start $args->{application_name}";
}
$IE->{Visible} = 0;
$IE->Navigate( 'splash.html' );
$IE->{RegisterAsBrowser} = 1;
$IE->{AddressBar} = 0;
$IE->{MenuBar} = 0;
$IE->{Offline} = 0;
$IE->{StatusBar} = 0;
$IE->{ToolBar} = 0;
$IE->{FullScreen} = 1;
$IE->{Left}  = ($IE->{Width}  - $args->{width})/2;
$IE->{Top}   = ($IE->{Height} - $args->{height})/2;
$IE->{Width}  = $args->{width};
$IE->{Height} = $args->{height};
$IE->{ScrollBars} = 0;
$IE->{Visible} = 1;
foreach (qw/ top bottom left right/){
$IE->{Document}->{body}->{$_."Margin"} = 0;
}
while( $IE->{Busy} ){
while( $IE->SpinMessageLoop() ){}
}
$IE->{Visible} = 1;

my $ua = LWP::UserAgent->new(timeout => 5,);
$req = new HTTP::Request('GET', $url);
$res = $ua->request($req);

Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: newbie hlelp!

2003-09-18 Thread Lee Goddard

I'm guessing that the @{ } syntax implies not only scalar content but that
what is enclosed in the braces is an array reference, not a list.
Ah, probably: I didn't think beyond scalar

Thanks.
Lee

Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::OLE

2003-09-18 Thread Groenwold, Harmen (ICT) (HK)
Hi,
This took me a while to figure out, but I think I got the solution to your
problem.

First, the Win32::Process, Win32::Process::Info or even Win32::OLE seem not
to help in any way to achieve what you want. I've gone through quite some
VBA documentation for Outlook and it seems that VBA doesn't have any way to
bring a window to the front.

Thankfully, deep in the Win32 API there are some functions to do this! If
you know a WHND (a windowhandle that has a LONG value), it's quite easy.
However, it's difficult get a WHND. If you know the string in a titlebar of
a window, it isn't that difficult. For example: start CALC.EXE, the string
in the titlebar is 'Calculator', use the FindWindow API call to get the WHND
from this window. But Outlook doen't have one simple string in the titlebar.
If you select the Tasks folder in Outlook, the titlebar changes to 'Tasks -
Microsoft Outlook'. If you select the Contacts folder, the titlebar changes
to 'Contacts - Microsoft Outlook'. See the problem?

One API call saves the day however: EnumWindows. Like the name says, it
enumerates through all windows and with a callback function (see the
Win32::API::Callback documentation) we can link titlebars and windowhandles!
Now, use some good old regex and... Voila! We know which handle to use.
After this, it's a walk in the park.

The following script works fine on my machine. Let me know if it works on
yours.
My machine: Windows XP Pro, Office XP Pro, ActivePerl build 806, latest
version of Win32::API by using PPM.

The script:

==
use warnings;
use strict;

use Win32::API;
use Win32::API::Callback;

# First, we need to get all the titlebar strings from all
# active windows. We need this to figure out what
# WINDOWHANDLE the Outlook window has.

# Set up a hash to store the WINDOWSHANDLEs as key
# and the titlebar strings as value
my %windowhandle_titlebar;
# We need a scalar in the $callback function. This
# needs to be declared before the function
my $title_bar;

# We need a callback function for the EnumWindows WinAPI function.
# This callback object includes a function that fills the hash.
my $callback = Win32::API::Callback->new(sub
  {my $handle=$_[0];$title_bar = subGetTitle($handle);
   $windowhandle_titlebar{$handle}= $title_bar; return 1;},
  'N', 'I');

# This is a sub that gets a WINDOWHANDLE (which is a just simply a LONG).
# The sub returns the titlebar of the window which WINDOWHANDLE is supplied
sub subGetTitle {
  my $win_handle = $_[0];
  my $title_bar_size = 50;
  my $title_bar = ' ' x $title_bar_size;
  my $get_window_text = new Win32::API('user32', 'GetWindowText', 'NPI',
'I');
  my $return_val2 = $get_window_text->Call($win_handle, $title_bar,
$title_bar_size);
  return $title_bar;
}

# define $enum_windows as a Win32::API object
my $enum_windows = new Win32::API('user32', 'EnumWindows', 'KN', 'I');
# some errorhandling... can be done better...
if(not defined $enum_windows) {
  die "Can't import API EnumWindows: $!\n";
}

# do I really need this parameter?
my $my_parameter_string = 1;

# watch this! here we start the EnumWindows API call
# now the hash %windowhandle_titlebar gets filled
my $return_val1 = $enum_windows->Call($callback, $my_parameter_string);

# Let's walk through the hash to get the handle of the
# window which has /\s-\sMicrosoft\sOutlook/ in the titlebar.
# check this regex first if this script doesn't work for you
# because I've tested this only on Office/Outlook XP.
# Other versions of Outlook might behave differently...
my $outlook_window_handle;
while ((my $hashkey, my $hashvalue) = each (%windowhandle_titlebar)) {
  if ($hashvalue =~ m/\s-\sMicrosoft\sOutlook/) {
$outlook_window_handle = $hashkey;
  }
}

# Now that we have a WINDOWHANDLE (which is by for the most
# difficult), we can use this to call the SetForegroundWindow API call.
# First, declare the function by using Win32::API
my $SetForegroundWindow = new Win32::API('user32', 'SetForegroundWindow',
'N', 'I');
# some errorhandling... needs more...
if (not defined $SetForegroundWindow) {
  die "Can't import API SetForegroundWindow: $!\n";
}
# And finally, this is the call that does what you wanted.
# It brings to the foreground the wanted window
my $return_val = $SetForegroundWindow->Call($outlook_window_handle);


=
End script

Start Outlook, set another window on top (i.e. a Command Prompt box), run
the script and Outlook will be put on the foreground. Good luck! Let me know
if you have any questions.

Harmen


-Original Message-
From: Martin Bower [mailto:[EMAIL PROTECTED] 
Sent: woensdag 17 september 2003 3:30
To: [EMAIL PROTECTED]
Subject: Win32::OLE


I've got lots of windows running,  and I'd like to activate Outlook when I
run this script. I'll assign this to a hotkey, so when I press the hotkey,
outlook will appear (if its running).

I'm running O

RE: Read a text file and parse values

2003-09-18 Thread Tobias Hoellrich
File "a" contains the list of hostnames:

C:\>type a
one
two
three

Just print the commands we would execute:

C:\>perl -ne "chomp;print qq{exec $_  -u abc -p xxx abc.bat\n}" a
exec \\one  -u abc -p xxx abc.bat
exec \\two  -u abc -p xxx abc.bat
exec \\three  -u abc -p xxx abc.bat

And this time, execute them:

C:\>perl -ne "chomp;print qx{exec $_  -u abc -p xxx abc.bat\n}" a

HTH
  Tobias

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Noushad Dawood
> Sent: Thursday, September 18, 2003 2:39 AM
> To: Hanson, Rob; 'Gary Nielson'; [EMAIL PROTECTED]
> Subject: Read a text file and parse values
> 
> 
> Friends,
> 
> I got a text file that contains a list of computer names. I
> need to write a program that will read this file and execute 
> following command for each computer name:
> 
>   exec \\ -u abc -p xxx abc.bat
> 
> where  is picked up from the text file.
> 
> Can some one help me on this?
> 
> Many thanks in advance.
> 
> ND
> 
> 
> 
> 
> **
> The contents of this mail are personal opinions of the Author.
> ADIA disclaims all responsibility and accepts no liability, 
> whatsoever.
> **
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Read a text file and parse values

2003-09-18 Thread Beckett Richard-qswi266
> Friends,
> 
> I got a text file that contains a list of computer names. I 
> need to write a
> program that will read this file and execute following 
> command for each
> computer name:
> 
>   exec \\ -u abc -p xxx abc.bat
> 
> where  is picked up from the text file.
> 
> Can some one help me on this?

You realise that exec terminates the current program, executes an external
command AND NEVER RETURNS!!!?

Maybe you mean system?

use strict;
use warnings;

open (FILE, "input.txt");
my @puters = ;
close (FILE);

foreach (@puters) {
system ("$_ -u abc blah, blah...");

}

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Open2/3, Handle, 5.6.1-633/635, 5.8.0-806 issues

2003-09-18 Thread Andre Warnier
Dear Sir,

I will accept to be slapped in the face for good reasons, but otherwise I
will send you my witnesses.

Did you actually run the example (which uses "to be autovivified" variables
rather than the \*HANDLE form) ?
In my case, I tried the various forms, but no matter what form I use, the
results are the same.

It also doesn't seem to explain why in the sample program - which does the
same call over and over in a loop - only the first loop
fails under 5.8.0, and the other loops work fine.

But by the way, I didn't know what you mention about the eval block acting
as a quoted string,
but it sounds interesting.  Are you sure ?  Can I find some documentation
about that ?


--
André Warnier
[EMAIL PROTECTED]



Message text written by Carl Jolley

In an eval block \*FMCHILD is not a reference to a glob but rather
simply equivalent to '*FMCHILD'. Either take out the eval block
or double the back slashes. all the single backslash did is escape
the * character. The sound that you hear is either me slapping you
or you slapping your open palm to your forehead.


> 
On Tue, 16 Sep 2003, Andre Warnier wrote:

> This issue was posted before under the subject "ASPerl5.6.1, Win2K,
open2()" in various lists in desperation.
> Apologies for that. I have done some more homework since.
>
> If I'm right, this seems more like a bug report that should be posted
somewhere else, but I can't find a place
> so here it goes...
> Ideally, if the problem is real, it would be really nice for me if a
patch was feasible for 5.6.1-635, because
> my production programs run under that version and because of Unicode
concerns it is difficult for me to upgrade
> right now to 5.8.0.  But hey, this being free software, I'll take what I
get ;-).
> In fact, it would be rather nice if I made a stupid mistake, because then
I could rectify it and
> my program would run. So go ahead, slap me if I deserve it, as long as
you indicate a solution.
>
> Summary :
>
> The following instructions gives different - and apparently incorrect -
results under WinNT 4.0 and Win2K, with
> ActivePerl 5.6.1-633, ActivePerl 5.6.1-635, and ActivePerl 5.8.0-806, for
a Perl program running either as a console
> application or as a Win32 Service.
>
> Sample instructions :
>
>   eval { $pid = open2(\*FMCHILD,\*TOCHILD,$ExtExe); };
>   eval { $pid = open3($TOCHILD,$FMCHILD,$FMCHILD,$ExtExe); };
>
> where :
>   - FMCHILD etc... are either 'Glob references' (\*X) or declared but
undefined variables ($X) intended
>   for auto-vivification.
>   - $ExtExe is, for example, "c:\winnt\systems32\nslookup.exe"
>
> The various results can be seen by running the attached sample program
under the various conditions indicated
> above.
>
> The most obvious error appears when running the program as a Service
under Win2K & 5.6.1-635, leading to a message
> "open3: Can't call method "close" on an undefined value at
c:/Perl/lib/IPC/Open3.pm line 327"
> but the real origin of the problem in Open3.pm is the line
>   $fd->{tmp_copy} = IO::Handle->new_from_fd($fd->{handle},
$fd->{mode});
> in the 1st foreach of the spawn_with_handles() sub, which returns undef.
>
> The apparent cause (as far as I can tell) seems to be that the value
contained in $fd->{handle} is
> not properly understood (or handled) by the fdopen() sub in Handle.pm,
itself called by IO::Handle::new_from_fd().
>
> Details :
>
> The problem originally appears in a program which can run on the console
(for debugging) or as an NT Service
> (in production) under Windows NT 4.0 and/or Win2k.  This program must
also run under Unixes, hence the open2/3
> method usage.
> The original program uses the Open2() call to start an external
> process and read/write to it's STDIN/STDOUT. The program runs fine on the
console, but has a problem when
> it is started as a Service using Roth's Win32::Daemon extension.
> The problem in that case shows itself by an error at the open2() call, as
follows :
> open2: Can't call method "close" on an undefined value at
c:/Perl/lib/IPC/Open3.pm line 327
> but in fact the problem happens earlier in the Open3 module, as shown by
a modified Open3.pm (tracing added).
>
> The original program being about 3,000 lines long, I have created a
simplified test case which shows the same symptoms,
> using open3() directly.
> The test case is a mere 270 lines, so I took the liberty of appending the
source code below.
> Part of the setup required is a bit tedious (installing it as a Service),
so I hope someone will have the patience.
> I've tried to make it as easy to run as possible.
>
>
> I have run this test case under ActivePerl 5.6.1 build 633, ActivePerl
5.6.1 build 635, and ActivePerl 5.8.0 build 806.
> The results are slightly different in the various cases, but as an
example here are some traces :
>
> 1) Under 5.8.0-806, running on the Win2k console, logged in as a local
Admin, log file in Appendix 2 below
>
> 2) Under 5.8.0-806, running as a Win2K Service, as 'LocalSystem', log
file in

Re: Reg Expression missing last char?

2003-09-18 Thread Adam Ingerman
On Thu, 18 Sep 2003 06:43, Capacio, Paula J wrote:
> Thanks Bill, Rob and David!  I didn't pickup on $1 getting too much of
> the match.  I guess the lesson there is when printing the results, I
> should have delimited them with either words or characters, (like you
> did) then I would've noticed it.
> print "Expression matched and retained: $1 and $2\n";
> Instead of:
> print "Expression matched and retained: $1 $2\n";
> Thanks again.
> Paula
>

when debugging, I tend to be more direct in variable checking, this might be 
evern better for you (add another \n if it's liable to be a long line, and 
change the ' to another character if need be)

print "\$1\t'$1'\n\$2\t'$2'\n\$3\t'$3'\n";

sure, it doesn't look much there, but it does help when you use it, eg:


$1  variable
$2  name
$3  is


of course, if it's something you're going to leave in as output in the running 
version (as opposed to testing) then you want more detail in the output. but 
this works well and quickly for checking one part or another

hope this helps

adam
-- 
Quidquid latine dictum sit, altum viditur.

(Whatever is said in Latin sounds profound.)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Read a text file and parse values

2003-09-18 Thread Noushad Dawood
Friends,

I got a text file that contains a list of computer names. I need to write a
program that will read this file and execute following command for each
computer name:

  exec \\ -u abc -p xxx abc.bat

where  is picked up from the text file.

Can some one help me on this?

Many thanks in advance.

ND




**
The contents of this mail are personal opinions of the Author. 
ADIA disclaims all responsibility and accepts no liability, whatsoever.
**

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Reg Expression missing last char?

2003-09-18 Thread Carl Jolley
On Wed, 17 Sep 2003, Capacio, Paula J wrote:

> I am using $1 and $2 to retain data from a matched regular expression.
> I expect $1 to contain the KEY ID and $2 to contain USER NAME, but $2 is
> missing the last character.  See the code and results below.
> (watch out for text line wrapping)
> Thanks in advance
> Paula
> CODE
> use strict;
> #simulate the output from a back-tick command : @system_out =
> `$command`;
> my @system_out;
> push @system_out, " Alg  Type Size  Flags   Key ID User
> Name\n\n";
> push @system_out, "*DSS  pair 1024/1024 [VI---] 0x2BEAF881 American
> Family Insurance\n\n";
> push @system_out, " DSS  pub  2048/1024 [-] 0x8E5DAD1A operator2
> <[EMAIL PROTECTED]>\n\n";
> push @system_out, " DSS  pub  3072/1024 [-] 0xBE71303F
> another/americanfamily <[EMAIL PROTECTED]>\n\n";
> push @system_out, " DSS  pub  1024/1024 [-] 0xB04F7DAA
> swisscow\n\n";
> push @system_out, " DSS  pub  2048/1024 [-] 0xAA2F4ABA SLM
> <[EMAIL PROTECTED]>\n\n";
> push @system_out, " 5 found.\n\n";
> foreach my $line (@system_out) {
> next if ($line !~ /DSS  p/);   #eliminate heading/footer lines
> chomp $line;
> print "$line";
> if ($line =~ /DSS  p.+\].{1}(.+).{1}(.*)/) {
> print "Expression matched and retained: $1 $2\n\n";
> }else{
> print "Start Over, expression did not match\n";
> }
> }
> RESULTS
> *DSS  pair 1024/1024 [VI---] 0x2BEAF881 American Family Insurance
> Expression matched and retained: 0x2BEAF881 American Family Insuranc
>
>  DSS  pub  2048/1024 [-] 0x8E5DAD1A operator2
> <[EMAIL PROTECTED]>
> Expression matched and retained: 0x8E5DAD1A operator2
> <[EMAIL PROTECTED]
>
>  DSS  pub  3072/1024 [-] 0xBE71303F another/americanfamily
> <[EMAIL PROTECTED]>
> Expression matched and retained: 0xBE71303F another/americanfamily
> <[EMAIL PROTECTED]
>
>  DSS  pub  1024/1024 [-] 0xB04F7DAA swisscow
> Expression matched and retained: 0xB04F7DAA swissco
>
>  DSS  pub  2048/1024 [-] 0xAA2F4ABA SLM <[EMAIL PROTECTED]>
> Expression matched and retained: 0xAA2F4ABA SLM <[EMAIL PROTECTED]
>

You are push'ing the header lines not unshifting them. They will be
placed at the end of system_out. Also I believe you probably should
do the unshifts in reverse order. But that is beside the point. I suspect
that $2 matched the empty string at the end of your line, after all
you did capture it with (.*). The last "real" character was matched
by the preceeding .{1} field. It had to be otherwise the match would
have failed. The empty string following the last real character then
allowed the (.*) to also match.

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: win32::ODBC insert error

2003-09-18 Thread Carl Jolley
On Tue, 16 Sep 2003, Mark Elliott wrote:

> I get this error:
>
> "[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored
> procedure 'insert into hosts (HOST,lastchk)
>
> When I attempt to insert a bunch of rows into a MSSQL table.  It gets data
> from a text file.
>
> Here is the code:
>
> use Win32::ODBC;
> $prox = new Win32::ODBC("DSN=wilma");
> @_ = <>;
> foreach $_(@_){
>   /(.*)\t(.*)\t(.*)/;
>   $strsql = '"insert into hosts (HOST,lastchk) VALUES
> (\''.$1.'\',\''.$3.'\');"';
>   print $strsql;
>
>   if ($prox->sql($strsql)){$prox->DumpError}
>   $prox->sql($strsql);
>   $foo = <>;}
>
> $prox->Close();
>

All your '\' strings need to be changed to '\\'.

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: newbie hlelp!

2003-09-18 Thread Carl Jolley
On Tue, 16 Sep 2003, alex p wrote:

> Might it be the way i have it set on my computer to read the time?
> I have copied and pasted $Bill's code onto mine and I still get the same
> output!
> 
> foreach $f (@allfiles)
>   {
> unless ( ($f eq ".") || ($f eq "..") )
>   {
> print "$f\n";
> my ($dom, $mon, $year) = (localtime ((stat $f)[9]))[3,4,5];
> printf "$f: %04d%02d%02d\n", $year+1900, $mon+1, $dom;
> #(undef,undef,undef,$dom,$mon,$year)=localtime((stat($dir/$f))[9]);
> #$mon++;
> #$year += 1900;
> #$dateval = printf("%04d%02d%02d\n",$year,$mon,$dom);}
> 
> 
> 8000839F.LOG: 19691231
> 800083BC.LOG: 19691231
> 800083D8.LOG: 19691231
> 80008401.LOG: 19691231
> 80008441.LOG: 19691231
> 800084AB.LOG: 19691231
> 80008509.LOG: 19691231
> 80008560.LOG: 19691231
> 8000863E.LOG: 19691231
> 
>
>
>
> >From: "$Bill Luebkert" <[EMAIL PROTECTED]>
> >To: alex p <[EMAIL PROTECTED]>
> >CC: [EMAIL PROTECTED]
> >Subject: Re: newbie hlelp!
> >Date: Tue, 16 Sep 2003 11:05:22 -0700
> >
> >alex p wrote:
> >
> > > Thank you all for replying, I am using the code below and I am still
> >unable
> > > to get the correct date
> > > 
> > > opendir (DIR, "$server\\c\$\\sys\\data\\LOG\\updates");
> > >   @allfiles = readdir(DIR);
> > >   #print("," readdir(DIR));
> > >   #closedir(DIR);
> > >   foreach $f (@allfiles)
> > >   {
> > > unless ( ($f eq ".") || ($f eq "..") )
> > >   {
> > > print "$f\n";
> > > (undef,undef,undef,$dom,$mon,$year)=localtime((stat($f))[9]);
> > > $mon++;
> > > $year += 1900;
> > > $dateval = printf("%04d%02d%02d\n",$year,$mon,$dom);
> > >}
> > > 
> > > the output of printf is: 19691231  for every file?
> > > what am I doing wrong?
> > > the date should be yesterdays date 20030915
> >
> >The following works fine for me (modified the dir for testing):
> >
> >use strict;
> >
> >#opendir DIR, "$server\\c\$\\sys\\data\\LOG\\updates" or die "opendir:
> >$!";
> >opendir DIR, "." or die "opendir: $!";
> >my @allfiles = readdir DIR;
> >closedir DIR;
> >
> >foreach my $f (@allfiles) {
> > next if $f =~ /^\.{1,2}$/;
> > my ($dom, $mon, $year) = (localtime ((stat $f)[9]))[3,4,5];
> > printf "$f: %04d%02d%02d\n", $year+1900, $mon+1, $dom;
> >}
> >
> >__END__
> >
> >Your version also worked with minimal additions for scoping, etc.
> >Maybe there's a problem using the share - try a local filesystem and
> >see if it makes a difference.
> >

If that is your code then it's clear why it doesn't work.

You need to do: stat("$dir/$f"). The value of $dir divided by $f
also won't work (the part that you commented out). I suggest that
you put the following line immediatedly after your
print "$f\n";

print "file test", -f "$dir/$f","\n";

Note also that you are checking all files AND dirctories in the current
directory. If you just want to check files and not directories then
you might change the initialization of @allfiles to:

@allfiles=grep{ -f } readdir DIR;

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs