taduh Posted July 16, 2008 Share Posted July 16, 2008 I somehow found my way here because I'm looking for a substitute for the infamously unstable VBS Sendkeys command. I'm wondering if I can develop an alternative in Autoit that could be called from within my VBA script? Can someone tell me if this is possible (and fairly painless?) muttley Thanks - TaDuh Link to comment Share on other sites More sharing options...
Szhlopp Posted July 16, 2008 Share Posted July 16, 2008 I somehow found my way here because I'm looking for a substitute for the infamously unstable VBS Sendkeys command. I'm wondering if I can develop an alternative in Autoit that could be called from within my VBA script? Can someone tell me if this is possible (and fairly painless?) muttley Thanks - TaDuh So basically you want to be able to send keys from AutoIt using another app/script? Create an EXE from AutoIt with something like: WinWaitActive("Your Title") Send("This is a string of text") Tools>Compile (Ctrl-F7) Create an EXE. You should be able to call the EXE from anything else. RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
ResNullius Posted July 16, 2008 Share Posted July 16, 2008 I somehow found my way here because I'm looking for a substitute for the infamously unstable VBS Sendkeys command.I'm wondering if I can develop an alternative in Autoit that could be called from within my VBA script? Can someone tell me if this is possible (and fairly painless?) muttley Thanks - TaDuhI have succesfully used several compiled AutoIt scripts called from within VBA modules in Excel & Word.You can pass command line parameters to the AutoIt script on launch and can have AutoIt hand information back via Exit code or writing to ini files for your VBA to read. Link to comment Share on other sites More sharing options...
taduh Posted July 16, 2008 Author Share Posted July 16, 2008 I have succesfully used several compiled AutoIt scripts called from within VBA modules in Excel & Word.You can pass command line parameters to the AutoIt script on launch and can have AutoIt hand information back via Exit code or writing to ini files for your VBA to read.What is the VBA syntax for calling your AutoIt script? Link to comment Share on other sites More sharing options...
ResNullius Posted July 17, 2008 Share Posted July 17, 2008 What is the VBA syntax for calling your AutoIt script?In this example, my compiled AutoIt exe is called "MakePDF" and I am passing 3 command line parameters to it: sourceName: the source documentshortPdfName: the filename of the PDF document longPdfName: the full path & file name of the pdf file PDFMe = Shell("C:\makepdf\BIN\MakePDF.exe " & _ Chr(34) & sourceName & Chr(34) & _ " " & _ Chr(34) & longPdfName & Chr(34) & _ " " & _ Chr(34) & shortPdfName & Chr(34), 1) Link to comment Share on other sites More sharing options...
taduh Posted July 17, 2008 Author Share Posted July 17, 2008 In this example, my compiled AutoIt exe is called "MakePDF" and I am passing 3 command line parameters to it: sourceName: the source documentshortPdfName: the filename of the PDF document longPdfName: the full path & file name of the pdf file PDFMe = Shell("C:\makepdf\BIN\MakePDF.exe " & _ Chr(34) & sourceName & Chr(34) & _ " " & _ Chr(34) & longPdfName & Chr(34) & _ " " & _ Chr(34) & shortPdfName & Chr(34), 1) Thanks ResNullius - I appreciate it! What do the Chr(34) characters translate to? Also, what does the Link to comment Share on other sites More sharing options...
Kiti Posted July 17, 2008 Share Posted July 17, 2008 Thanks ResNullius - I appreciate it! What do the Chr(34) characters translate to? Also, what does the Chr(34) is the number 4 (four). You can check this in an ascii table, which can also be found in SciTe's help. " This is what it does. Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
ResNullius Posted July 17, 2008 Share Posted July 17, 2008 (edited) Thanks ResNullius - I appreciate it! What do the Chr(34) characters translate to? Also, what does the Chr(34) is the number 4 (four). You can check this in an ascii table, which can also be found in SciTe's help. " This is what it does.CHR(34) is not the number 4, it is a quotation mark: " (@Kiti: the number 4 has a hex value of 34, but an ascii value of 52 !) They are there to "wrap" the variables as they might have spaces in them (like in the long file name that includes the path) and the only way to pass a command line variable with spaces in windows (most of the time) is by enclosing it in quotes. Otherwise it gets broken up at each space: eg: C:\My Pdfs\Work\A long pdf name.pdf passed without quotes to the program would be seen not as one command line parameter but as 5: C:\MyPdfs\Work\Alongpdfname.pdfSo I make sure it gets sent as "C:\My Pdfs\Work\A long pdf name.pdf". There are other ways of having your program recieve command line parameters (i.e.: switches) such that you don't have to wrap with quotes, but that adds another layer of complexity to your AutoIt program. PS: Kiti is right about the tags, they are used when posting to offset the text into a "code" highlighted area. For instance [ code ]If that then do this EndIf [ /code ] becomes (if you take out the spaces around the words in the square brackets) If that then do this EndIf Eaiser to read and see where the code starts and stops! Edit: hit the "add reply button instead of "preview post" before I was done! Edited July 17, 2008 by ResNullius Link to comment Share on other sites More sharing options...
taduh Posted July 17, 2008 Author Share Posted July 17, 2008 CHR(34) is not the number 4, it is a quotation mark: " (@Kiti: the number 4 has a hex value of 34, but an ascii value of 52 !) They are there to "wrap" the variables as they might have spaces in them (like in the long file name that includes the path) and the only way to pass a command line variable with spaces in windows (most of the time) is by enclosing it in quotes. Otherwise it gets broken up at each space: eg: C:\My Pdfs\Work\A long pdf name.pdf passed without quotes to the program would be seen not as one command line parameter but as 5: C:\MyPdfs\Work\Alongpdfname.pdfSo I make sure it gets sent as "C:\My Pdfs\Work\A long pdf name.pdf". There are other ways of having your program recieve command line parameters (i.e.: switches) such that you don't have to wrap with quotes, but that adds another layer of complexity to your AutoIt program. PS: Kiti is right about the tags, they are used when posting to offset the text into a "code" highlighted area. For instance [ code ]If that then do this EndIf [ /code ] becomes (if you take out the spaces around the words in the square brackets) If that then do this EndIf Eaiser to read and see where the code starts and stops! Edit: hit the "add reply button instead of "preview post" before I was done! Thanks, Resnullius - taDuh Link to comment Share on other sites More sharing options...
ResNullius Posted July 18, 2008 Share Posted July 18, 2008 Thanks, Resnullius - taDuhYou're welcome taDuh. And welcome to the forums by the way: Happy Coding! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now