Jump to content

call autoit commands via commandline


step887
 Share

Recommended Posts

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

Example:

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 ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <array.au3>
If $cmdline[0] = 0 Then
    ConsoleWrite('No command switches'& @CRLF)
    Exit
Endif
$a = StringRegExp($cmdlineraw,'(.*?)(\(.*\))',1)
If @error Then
    ConsoleWrite('StringRegExp (.*?)(\(.*\)) Returned: ' & @error)
    Exit
EndIf
$func = $a[0]
$c = StringRegExpReplace($a[1],'(?!\B"[^"]*),(?![^"]*"\B)','|')
$c = StringRegExpReplace($c,'["'&"()]",'')
$c = StringSplit($c,'|')
_arraydisplay($c,$func)
DllCall("user32.dll", "int", "MessageBox","hwnd", 0,"str", "Some text","str", "Some title","int", 0)
DllCall($c[1],$c[2],$c[3],$c[4],$c[5],$c[6],$c[7],$c[8],$c[9],$c[10],$c[11])
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.

DllCall($c[1],"int","MessageBox",$c[4],$c[5],$c[6],$c[7],$c[8],$c[9],$c[10],$c[11])

EDIT:

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.

EDIT2:

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
 Share

  • Recently Browsing   0 members

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