Jump to content

call autoit commands via commandline


Recommended Posts

I am trying to get a exe that can run Autoit commands via commandline.


test.exe DllCall("user32.dll", "int", "MessageBox","hwnd", 0,"str", "Some text","str", "Some title","int", 0)

I can parse the command line and using variables to call the command.. 

but I get @error 2 = unknown "return type"

Is this possible?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <array.au3>
If $cmdline[0] = 0 Then
    ConsoleWrite('No command switches'& @CRLF)
$a = StringRegExp($cmdlineraw,'(.*?)(\(.*\))',1)
If @error Then
    ConsoleWrite('StringRegExp (.*?)(\(.*\)) Returned: ' & @error)
$func = $a[0]
$c = StringRegExpReplace($a[1],'(?!\B"[^"]*),(?![^"]*"\B)','|')
$c = StringRegExpReplace($c,'["'&"()]",'')
$c = StringSplit($c,'|')
DllCall("user32.dll", "int", "MessageBox","hwnd", 0,"str", "Some text","str", "Some title","int", 0)
ConsoleWrite('Dllcall error: ' & @error)
Link to comment
Share on other sites

It appears not to like the return type or function name, maybe it needs to be constant.



Tied it all kinds of ways now including struct and struct pointer and it will not work unless the return type and function name are literal constants.


Yet this works...

$rtn = "int"
$function = "MessageBox"

DllCall("user32.dll", $rtn, $function,"hwnd", 0,"str", "Some text","str", "Some title","int", 0)

Even tried opening/setting cmd to unicode, maybe I did it wrong, something must be happening through command line.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...