AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

You got your Perl in my AHK!

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
tinypig



Joined: 12 Mar 2005
Posts: 14

PostPosted: Sat Mar 19, 2005 8:53 pm    Post subject: You got your Perl in my AHK! Reply with quote

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__
*/

Back to top
View user's profile Send private message
hs2



Joined: 25 Feb 2005
Posts: 11
Location: Germany

PostPosted: Sat Mar 19, 2005 9:14 pm    Post subject: Reply with quote

This is a really smart solution - great job tinypig !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group