step887 Posted January 19, 2015 Posted January 19, 2015 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)
JohnOne Posted January 19, 2015 Posted January 19, 2015 I get that error in the console, but it still works. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
step887 Posted January 19, 2015 Author Posted January 19, 2015 comment out this DllCall("user32.dll", "int", "MessageBox","hwnd", 0,"str", "Some text","str", "Some title","int", 0) I just had there to make sure I was calling it right via the command line.
JohnOne Posted January 19, 2015 Posted January 19, 2015 (edited) 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 January 19, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
step887 Posted January 19, 2015 Author Posted January 19, 2015 (edited) Thanks John for your effort. That is kinda of wierd how the command under Edit2 works.. Edited January 19, 2015 by step887
JohnOne Posted January 19, 2015 Posted January 19, 2015 I've no doubt someone with better know how will chime in soon with an explanation. There are some proper code boffins here. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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