Werty Posted August 12, 2011 Share Posted August 12, 2011 (edited) So I have a line that looks like this... $msgs = $img.Convert($5,$8,$7,$1,$2&$c1,$1,$2&$c2,$1,$2&$c3,$1,$2&$c4,$1,$2&$c5,$1,$2&$c6,$1,$2&$c7,$1,$2&$c8,$1,$2&$c9,$6) ..how do I put all that into a single string ? This doesnt work $string = "$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$1,$2&$c3,$1,$2&$c4,$1,$2&$c5,$1,$2&$c6,$1,$2&$c7,$1,$2&$c8,$1,$2&$c9,$6" $msgs = $img.Convert($string) All the variables are strings, like.. Global $1 = "-draw", $2 = "line", etc, etc, etc Notice the &'s in the string. Edited August 12, 2011 by Werty Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Exit Posted August 12, 2011 Share Posted August 12, 2011 (edited) Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand $msgs = $img.Convert("$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$1,$2&$c3,$1,$2&$c4,$1,$2&$c5,$1,$2&$c6,$1,$2&$c7,$1,$2&$c8,$1,$2&$c9,$6") Edited August 12, 2011 by forumer100 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Werty Posted August 12, 2011 Author Share Posted August 12, 2011 (edited) Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand $msgs = $img.Convert("$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$1,$2&$c3,$1,$2&$c4,$1,$2&$c5,$1,$2&$c6,$1,$2&$c7,$1,$2&$c8,$1,$2&$c9,$6") I cant get that working, I tried... Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand $string = "$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$1,$2&$c3,$1,$2&$c4,$1,$2&$c5,$1,$2&$c6,$1,$2&$c7,$1,$2&$c8,$1,$2&$c9,$6" $msgs = $img.Convert($string) The line works as I wrote it in the OP, I just need it something like the above, like $img.Convert($string) Edited August 12, 2011 by Werty Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Werty Posted August 12, 2011 Author Share Posted August 12, 2011 (edited) Here's a fully working example (requires ImageMagickObject.dll)... #include <GDIPlus.au3> #include <ClipBoard.au3> $img = ObjCreate("ImageMagickObject.MagickImage.1") Global $1="-draw",$2="line ",$5="-size",$6="clipboard:",$7="xc:white",$8="640x480" Global $c1="100,100 100,200",$c2="100,200 200,200" $gui = GUICreate("example", 640, 480) GUISetState() _GDIPlus_Startup() $img.Convert($5,$8,$7,$1,$2&$c1,$1,$2&$c2,$6) $pic1 = makegraphic() $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImage($hgraphic, $pic1, 0, 0) Sleep(3000) _GDIPLUS_Shutdown() Func makegraphic() _ClipBoard_Open(WinGetHandle(AutoItWinGetTitle())) $image = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() $hbitmap = _GDIPlus_BitmapCreateFromHBITMAP($image) $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) Return $hbitmap EndFunc ...which I need to be something like this (which doesnt work)... #include <GDIPlus.au3> #include <ClipBoard.au3> $img = ObjCreate("ImageMagickObject.MagickImage.1") Global $1="-draw",$2="line ",$5="-size",$6="clipboard:",$7="xc:white",$8="640x480" Global $c1="100,100 100,200",$c2="100,200 200,200" $gui = GUICreate("Example", 640, 480) GUISetState() _GDIPlus_Startup() $string = "$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$6" $img.Convert($string) $pic1 = makegraphic() $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImage($hgraphic, $pic1, 0, 0) Sleep(3000) _GDIPLUS_Shutdown() Func makegraphic() _ClipBoard_Open(WinGetHandle(AutoItWinGetTitle())) $image = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() $hbitmap = _GDIPlus_BitmapCreateFromHBITMAP($image) $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) Return $hbitmap EndFunc So I would like this line... $img.Convert($5,$8,$7,$1,$2&$c1,$1,$2&$c2,$6) ...to be something like... $string = "$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$6" $img.Convert($string) ? Edited August 12, 2011 by Werty Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Malkey Posted August 12, 2011 Share Posted August 12, 2011 (edited) Try this. expandcollapse popup#include <GDIPlus.au3> #include <ClipBoard.au3> Global $img = ObjCreate("ImageMagickObject.MagickImage.1") Global $1 = "-draw", $2 = "line ", $5 = "-size", $6 = "clipboard:", $7 = "xc:white", $8 = "640x480" Global $c1 = "100,100 100,200", $c2 = "100,200 200,200" Global $str = "$img.Convert(" Global $gui = GUICreate("example", 640, 480) GUISetState() _GDIPlus_Startup() Global $string = "$5,$8,$7,$1,$2&$c1,$1,$2&$c2,$6" #cs Local $arr = StringSplit($string, ",", 2) For $i = 0 To UBound($arr) - 1 $str &= '"' & Execute($arr[$i]) & '",' Next $str = StringTrimRight($str, 1) & ")" #ce ; or ;$str = "$img.Convert(" & StringReplace(Execute('"' & StringRegExpReplace($string, '([^,]+)', '#" & \1 & "#') & '"'), "#", '"') & ")" ;or simply ;$str = "$img.Convert($5,$8,$7,$1,$2&$c1,$1,$2&$c2,$6)" $str = "$img.Convert(" & $string & ")" ;ConsoleWrite($str & @LF) Execute($str) ;Execute('$img.Convert("-size","640x480","xc:white","-draw","line 100,100 100,200","-draw","line 100,200 200,200","clipboard:")') $pic1 = makegraphic() $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImage($hgraphic, $pic1, 0, 0) Sleep(3000) _GDIPlus_Shutdown() Func makegraphic() _ClipBoard_Open(WinGetHandle(AutoItWinGetTitle())) $image = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() $hbitmap = _GDIPlus_BitmapCreateFromHBITMAP($image) $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) Return $hbitmap EndFunc ;==>makegraphic Edit: Added ;or simply method Edited August 12, 2011 by Malkey Link to comment Share on other sites More sharing options...
Werty Posted August 12, 2011 Author Share Posted August 12, 2011 Edit: Added ;or simply methodRead about Execute() a while ago and was like "hmmm, this could come in handy", guess I was right I went with the ;or simply method, thanks Some guy's script + some other guy's script = my script! 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