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 

Visual Basic Script support in AutoHotKey
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
AHKnow



Joined: 03 Jul 2004
Posts: 118

PostPosted: Sat Jul 03, 2004 2:39 pm    Post subject: Visual Basic Script support in AutoHotKey Reply with quote

From this post about a DLL version of AutoHotKey http://www.autohotkey.com/forum/viewtopic.php?t=96&highlight=visual+basic I gather you might not be too enthusiastic about just copying AutoIt. I suggest that some commands for greater support of VBScript be added. Other macro recorders like Macro Scheduler or Aldo's Macro Recorder have high levels of VBScript support. A program called macroangel 2 / macro angel 2 also has support for Visual Basic for Applications. There is also a freeware program, which in various ways is less advanced but in others more, called MediaBasic ( http://www.uolang.org/mediabasic/ ) that can directly compile .vbs files into .exe.

VBScript support would allow AutoHotKey executables to do more with less need for supporting files or other external scripts and give them greater functionality.

I just put down a little visual of what I mean, but of course however it would be done, it would be very useful.

VBS_START ("Inputbox", add whatever)
dim response
response = inputbox("Type anything in the box and click OK.", "Input box demo")
if response <> "" then
msgbox "You typed " & response & ".", 64, "Your Input"
end if
VBS_END

VBS_RUN ("Inputbox", "cscript")

VBS_START and VBS_END could kind of be like #include, but are inside of the script as oppose to calling another script externally.

VBS_RUN could be a modified version of a command like RunWait('cscript.exe "c:\long file\name\script.vbs"') But where RunWait was was getting the VBS script externally, VBS_RUN would use what is between VBS_START and VBS_END and could send that to cscript.exe or wscript.

Of course if some other way was found for AutoHotKey to compile VBS than that would be even better.

EDIT- installs VBScript help doc in .CHM format (might be useful at some future point)
http://simplythebest.net/software/dll/vbscriptdoc.exe

Visual Basic for Applications free tutor
http://www.users.bigpond.net.au/gradley/vbatutor/VBATUTOR_INDEX.htm#Part1


Last edited by AHKnow on Sun Jul 04, 2004 9:53 am; edited 4 times in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sat Jul 03, 2004 4:00 pm    Post subject: Reply with quote

Quote:
There is also a freeware program, which in various ways is less advanced but in others more, called MediaBasic ( http://www.uolang.org/mediabasic/ ) that can directly compile .vbs files into .exe.

That's good. I'll see if this can be done for a future release, perhaps by learning from the source of MediaBasic or finding some info on MSDN about how to integrate VBS.

As always, development help is welcome from anyone, whether it be in the form of finding source code (as you did), contributing code, or finding technical articles that explain how to program specific things such as integrated VBS support.
Back to top
View user's profile Send private message Send e-mail
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Sat Jul 03, 2004 6:10 pm    Post subject: Reply with quote

I think that, rather than just vbs, if you used activescript instead, thus enabling the use of vbs, jscript, perlscript, rubyscript, or whatever. Unfortunately, my knowledge of how to set this up is limited to VB Sad.
Back to top
View user's profile Send private message AIM Address
Beastmaster



Joined: 15 Apr 2004
Posts: 181

PostPosted: Sat Jul 03, 2004 10:15 pm    Post subject: Reply with quote

As I know Macro Scheduler for a long time, the need to add additional commands was less important from that moment, as it was possible to use VBS with it. Here's a sample command how it uses VBS: VBStart
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Jul 04, 2004 3:18 am    Post subject: Reply with quote

savage wrote:
I think that, rather than just vbs, if you used activescript instead, thus enabling the use of vbs, jscript, perlscript, rubyscript, or whatever. Unfortunately, my knowledge of how to set this up is limited to VB Sad.


Related to that... I found these interesting...

http://msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28001169 (Microsoft Active scripting info.)

http://activescript.port5.com/index.html ( ActiveScript for Delphi )

http://www.geocities.co.jp/SiliconValley-PaloAlto/9251/ruby/main.html (ActiveScriptRuby)


Also... for MediaBasic ( http://www.uolang.org/mediabasic/ ) you have to copy the contents of a/your VBScript into their IDE and then compile it. MediaBasic understands the VBScript language syntax.
Back to top
AHKnow



Joined: 03 Jul 2004
Posts: 118

PostPosted: Sun Jul 04, 2004 11:37 am    Post subject: Reply with quote

Hmmm.... I was doing some studying on one of the ancestors of AutoHotkey and AutoIt.... Her name is Scriptit and it was a command line automation/install program made by Micro$oft and may have been "copied"/based on an early version of WinBatch. Well, it seems that it was Micro$oft's intention to have Scriptit able to "call" VBScript, JScript, etc...

info from http://www.microsoft.com/technet/prodtechnol/winntas/downloads/scriptit.mspx

MkFile

ScriptIt does not have many of the sophisticated features of traditional scripting languages such as Microsoft Visual Basic, Scripting Edition, Microsoft Jscript™ development software, or Perl. However, the mkfile line allows you to enhance and extend ScriptIt's capabilities with the features of these other scripting languages. The mkfile line capability allows ScriptIt to write a Visual Basic, Scripting Edition, Jscript, Perl script, and so forth, at run time. The external script can then be executed using a ScriptIt run or runwait line, or it can be executed from a title line using the left quotation mark (`) directive as described earlier. This will result in the standard output of the external script being redirected to the designated window title. Note that when you use any of the supported Windows Script Host languages from within the context of a title line, you should use CScript.exe, not WScript.exe, to launch them. ScriptIt expects that any command launched from a title line will send its output to standard output. WScript.exe does not use standard output.

Syntax

mkfile filename.ext=fileline

The parameters are as follows.

filename.ext

This parameter specifies the file name that is to be created or appended. Environment variables such as %Temp% can appear in the filename string.

fileline

This parameter specifies the line that is to be written or appended to filename. This line could be Visual Basic, Scripting Edition code, Jscript code, Perl code, and so forth. Or it could just be normal text that you want to save in a file.

If you want to create a multiple-line file, you need to include multiple mkfile lines in your script, each with the same filename.ext. The first instance of a given filename.ext opens a new file. All subsequent mkfile lines with the same filename.ext append lines to that file. Once you have finished building your new external script file, a ScriptIt run or runwait line can execute it. As indicated earlier, you can also redirect your external script's output to a specific window by using a ScriptIt title line with a keystroke segment that begins with the left quotation mark (`) followed by the command-line necessary to run the external script. For example, the following uses a run line to launch an instance of Notepad:

run=notepad.exe
mkfile %tmp%\t.vbs=set wshshell=wscript.createobject("wscript.shell")
mkfile %tmp%\t.vbs=set wshnetwork=wscript.createobject("wscript.network")
mkfile %tmp%\t.vbs=wscript.echo wshnetwork.username
Untitled - Notepad=`cscript //nologo %tmp%\t.vbs
run=`if exist %tmp%\t.vbs del %tmp%\t.vbs

It then uses mkfile lines to build a three-line Visual Basic, Scripting Edition file named %tmp%\t.vbs, and then uses a title line and a command line preceded by a left quotation mark (') to run t.vbs, redirecting the output to the Notepad window. Finally, the ScriptIt script cleans up after itself by using a run line with a left quotation mark to delete %tmp%\t.vbs.

You can download this old grandfather of AutoHotkey and Autoit at - http://www.csst-technologies.com/Automation%20CD/Utilities%20And%20Templates/Scriptit3%20Utility/

I really hope a way can be found to include this type of functionality.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sun Jul 04, 2004 11:56 am    Post subject: Reply with quote

Great links, thanks!

Also, I did know about ScriptIt, but not about it's extensions described above. Thanks also for that info.
Back to top
View user's profile Send private message Send e-mail
WHatler
Guest





PostPosted: Wed Sep 15, 2004 7:14 am    Post subject: Active-X Support Reply with quote

I use WinBatch a lot and recently started using AHK because it works better for capturing hotkeys. One thing they recently added that solves a lot of problems in one shot is the addition of basic Active-X support. You can use syntax similar to Visual Basic's CreateObject to open any active-x control. This very nicely solves a lot of problems.

For example, my most frequent use of this is to get Regular Expressions (something else on your wishlist). I just use VBScript's regular expressions and life is good. You can also use Active Scripting to fire up VBScript or JScript itself, although I very rarely do this.

If you could do something like they did with Active-X support, a lot or your wish-list items would go away immediately.
Back to top
BoBo
Guest





PostPosted: Wed Sep 15, 2004 7:40 am    Post subject: Reply with quote

Confirmed Very Happy
If you look at Macro Scheduler (Shareware) it follows the same route (as it allows to include/implement VBS within its native code) That would be of help for all of those who are familiar with such a "second" language.

On the other hand, AHK's benefit (like it was with AutoIt2) is its simplicity.

If it comes to complex tasks it's worth to think about to find the right hammer/tool for a specific nail/issue, as IMHO its legitimate to use an ATV instead of a Ferarri if you've to cross a muddy acre (if available Wink).

Quote:
my most frequent use of this is to get Regular Expressions (something else on your wishlist).

Man, you should definitely have a look at Perl(/Tk) or Tcl/Tc or ...

Last but not least (I guess Chris would recommand this too: AutoIt2/3 offers an Active X module (?), maybe it could be used with AHK as well (???))
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Sep 15, 2004 10:41 am    Post subject: Reply with quote

Quote:
You can use syntax similar to Visual Basic's CreateObject to open any active-x control. This very nicely solves a lot of problems.
Thanks for mentioning it and describing it so nicely. I'm definitely going to research this to find out how difficult it is to include.
Back to top
View user's profile Send private message Send e-mail
AHKnow



Joined: 03 Jul 2004
Posts: 118

PostPosted: Sat Sep 03, 2005 7:28 am    Post subject: Reply with quote

FileAppend is pretty close to the orginal wish for this feature, though its not so clear by name or example that it could be used for the purpose of executing other scripting languages in AutoHotkey.

AutoHotkey, by virtue of FileAppend has activex/com/ole (in a way) because it can simply FileAppend VBScript code to a text file and execute it.

You can even use this for .NET languages like cscript (C# script) and various .NET scripting programs.

Example using VBScript, fso, CreateObject, etc....

Code:


FileAppend,
(
Dim fso, f, ftext, r, stext, lstart, i, ls, fok
Set fso = CreateObject("Scripting.FileSystemObject")
 on error resume next
 ftext = inputbox("Enter the path of the file for processing.", "FILENAME")
    if ftext = "" then
        set fso = Nothing
        'WScript.Echo fco
        wscript.quit
    end if
       '--check whether the path is valid:
 If fso.fileexists(ftext) = false then
        fok = false
   do while fok = false
      r = msgbox("The path is wrong, there's no such file. Do you want to re-enter?", 36, "Woops!")
         if r = 7 then
            set fso = nothing
            wscript.quit
         else
            ftext = inputbox("Enter the filename for processing.", "FILENAME")
               if fso.fileexists(ftext) = true then
                   fok = true
                   exit do
              end if
         end if
    loop
end if
fs = inputbox("What is the string you're looking for? This will tell you the number of occurences.", "Enter string to find")
  if fs = "" then
     set fso = nothing
     wscript.quit
  end if
   '--open the file and read it into the variable stext:
set f = fso.opentextfile(ftext)
  stext = f.readall
  f.close
set f = nothing
set fso = nothing
'--more instances of the string.
   lstart = 1
      i = 0
      ls = 1
  do until ls = 0
           ls = instr(lstart, stext, fs, 1)
      If ls <> 0 then
          i = i + 1
          lstart = ls + 1
     end if
  loop
  msgbox i
), c:\testbox.vbs
Runwait,c:\testbox.vbs



I think this aspect of AutoHotkey should be emphasized. Why?

1. In many situations, this type of ability is the equal of AutoitX.dll or its built-in Activex/OLE/COM.

Programmers from other other languages can use their favorite code inside of AutoHotkey for various problems that they encounter.

2. AutoIt's AcitveX is a copy of VBScript. So why not use the real thing?

Even better, you can use more than just VBScript or Jscript.

3. Many AutoHotkey programmers don't have to wait for certain type of increased functionality in AutoHotkey, because while waiting they can use any scripting language that can use wscript or cscript, like Jscript , VBscript, or Perl. They can also use various .NET scripting languages that use VB.NET or C# script ( http://www.codeproject.com/csharp/cs-script_for_CP.asp ).

I was wondering if "FileAppend", "Run", and/or "RunWait" could be enhanced a bit more or a similar command created that specifically deals with handling other scripting languages and .NET??

A big enhancement would be to see if you could pass the commands to wscript or cscript without a temp file or .dll (like cmdret (great program)). I know its been talked about, but that would make this kind of feature even better.


Last edited by AHKnow on Sat Sep 03, 2005 10:40 am; edited 2 times in total
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sat Sep 03, 2005 9:55 am    Post subject: Reply with quote

AHKnow wrote:
...if you could pass the commands to wscript or cscript without a temp file of .dll (like cmdret (great program)).
I think the target language's interpreter would have to have built-in support for reading the commands from stdin. Does anyone know if VBScript or the others support this?

One problem with using FileAppend is that the script to be executed won't have access to any AutoHotkey variables, though I imagine you could pass parameters in via the command line. Another question is how to get data back out, which could be done via the exit code (for a single integer) or by having the external script write to stdout or a file.

I seem to remember that some macro languages allow seamless integration of VBScript so that both languages can see each other's data.

Thanks for the ideas.
Back to top
View user's profile Send private message Send e-mail
AHKnow



Joined: 03 Jul 2004
Posts: 118

PostPosted: Sat Sep 03, 2005 10:52 am    Post subject: Reply with quote

If this command was tweaked perhabs it could be like...

OtherScript, , (maybe some other commands),

(

Whatever the scripting language

), (maybe send to "Clipboard" and/or "tmp" file), cscript.exe (whatever .exe used to run other script).



Note: Perhaps you could have the contents of the clipboard piped to cscript, wscript, etc...

Code:
c:\testbox.vbs >  c:\windows\system32\cscript.exe


That works, so why not from the clipboard?


Anyway, these type of commands allow Autohotkey to do whatever else you need to do too. Even if that was ActiveX/COM/OLE, .NET, something in Perl, compiling a .NET DLL, etc.. it would not matter.

AutoHotkey advantage over the others will be its simplicity and/or automation abilities. Nevertheless, as AutoHotkey develops, there may be something people want from another scripting language. AutoHotkey could provide the "best of BOTH worlds", so that people can do whatever they need to


Last edited by AHKnow on Sat Sep 03, 2005 1:47 pm; edited 3 times in total
Back to top
View user's profile Send private message
Nemroth



Joined: 07 Sep 2004
Posts: 262
Location: France

PostPosted: Sat Sep 03, 2005 12:36 pm    Post subject: Reply with quote

Perfectly agree with the integration of VB Script in AHK.
May be this link about the "implementation of Active Script Site with ATL" may be of help ?
And may be this one too ?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sat Sep 03, 2005 7:34 pm    Post subject: Reply with quote

Thanks for the links and ideas. This will make my research easier when I start looking into COM, OLE, VBScript, and Active Scripting.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
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