AutoHotkey Community

It is currently May 26th, 2012, 6:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: March 19th, 2005, 8:53 pm 
Offline

Joined: March 12th, 2005, 7:57 pm
Posts: 15
Code:

;Combining Perl with AHK in the same script using ActivePerl
;Notes:
;  wperl allows the script to run without opening an additional window
;  -x flag says to read from #!perl line to end of file
;------------------------------------------------------------------------------
^!r::
;---Set the input for the routine---
perl_input=42 File(s)      1,173,988 bytes

;---Set the function you want to run from your perl script---
perl_action=files_bytes
Gosub, PerlRun

;---Display the output---
MsgBox,%perl_output%
return

;==========Everything below this line is the Perl "library"====================
;---First, the AHK Perl interface---
PerlRun:
ClipBoard0=%ClipBoardAll%
ClipBoard=%perl_input%
RunWait, C:\Perl\bin\wperl -x %A_ScriptFullPath% %perl_action%
perl_action=
perl_output=%ClipBoard%
ClipBoard=%ClipBoard0%
return


;---Then, the Perl code itself---
/******************************************************************************
#!perl
# For giving Perl capability to ahk

use strict;
use Win32::Clipboard;
my $wc = Win32::Clipboard();
my $data = $wc->Get();
my $action = $ARGV[0];

if($action eq
#------------------------------------------------------------------------------
'no_whitespace'
#------------------------------------------------------------------------------
) {
  $data =~ s/\s//g;
} elsif($action eq
#------------------------------------------------------------------------------
'files_bytes'
#------------------------------------------------------------------------------
) {
  for($data) {
    $_ = join(';',split /[^\d,]+/, $data);
    s/,//g;
  }
} else {
#------------------------------------------------------------------------------
# Default action
#------------------------------------------------------------------------------
  $data =~ s/s/x/g;
}

$wc->Set($data);

__END__
*/



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2005, 9:14 pm 
Offline

Joined: February 25th, 2005, 5:05 pm
Posts: 11
Location: Germany
This is a really smart solution - great job tinypig !


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group