AlmarM Posted April 12, 2009 Share Posted April 12, 2009 (edited) Hi,I'm tired so i'll keep it short.Some stuff you might want to know.// Comment msgbox,title,text sleep,time (in ms) send,text sendkey,key (ex: {enter}) controlsend,title,text controlsendkey,title,key beep,hz,time (in ms) movemouse,x,y,speed (0 - 100) clickmouse,x,y,speed dbclickmouse,x,y,speed run,path writefile,path,line exitexpandcollapse popupGlobal $qPath = @ScriptDir & "\EasyMacro.txt" Global $aPath = @ScriptDir & "\EasyMacro.au3" Global $_FileOpen If FileExists($qPath) Then FileDelete($qPath) If FileExists($aPath) Then FileDelete($aPath) $GUI = GUICreate("Easy Macro", 500, 450) $cEdit = GUICtrlCreateEdit("msgbox,My First Script,Hello World!", 10, 10, 480, 400) $cRun = GUICtrlCreateButton("Run", 190, 417, 100, 25) GUISetState() GUICtrlSetFont($cEdit, "", "", "", "System") While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 FileClose($_FileOpen) Exit Case $nMsg = $cRun $RaS = _ReadAndSave(GUICtrlRead($cEdit), $qPath) $Tran = _Translate($RaS) _Execute($Tran) EndSelect WEnd Func _ReadAndSave($Control, $Path) FileWrite($Path, $Control) Return $Path EndFunc Func _Translate($File) $_FileOpen = FileOpen($File, 0) $TotalLines = StringSplit(FileRead($_FileOpen), Chr(10)) For $i = 1 To $TotalLines[0] $_Read = FileReadLine($_FileOpen, $i) If StringLeft($_Read, 2) == "//" Then $_x = FileReadLine($_FileOpen, $i) FileWrite($aPath, ";" & $_x & @CRLF) ElseIf StringLeft($_Read, 6) == "msgbox" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "MsgBox(0, '" & $Split[2] & "', '" & $Split[3] & "')" & @CRLF) ElseIf StringLeft($_Read, 5) == "sleep" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "Sleep(" & $Split[2] & ")" & @CRLF) ElseIf StringLeft($_Read, 4) == "send" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "Send('" & $Split[2] & "')" & @CRLF) ElseIf StringLeft($_Read, 7) == "sendkey" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "Send('" & $Split[2] & "')" & @CRLF) ElseIf StringLeft($_Read, 11) == "controlsend" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "ControlSend('" & $Split[2] & "', '', '', '" & $Split[3] & "')" & @CRLF) ElseIf StringLeft($_Read, 14) == "controlsendkey" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "ControlSend('" & $Split[2] & "', '', '', '" & $Split[3] & "')" & @CRLF) ElseIf StringLeft($_Read, 4) == "beep" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "Beep(" & $Split[2] & ", " & $Split[3] & ")" & @CRLF) ElseIf StringLeft($_Read, 9) == "movemouse" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "MouseMove(" & $Split[2] & ", " & $Split[3] & ", " & $Split[4] & ")" & @CRLF) ElseIf StringLeft($_Read, 10) == "clickmouse" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "MouseClick('left', " & $Split[2] & ", " & $Split[3] & ", 1, " & $Split[4] & ")" & @CRLF) ElseIf StringLeft($_Read, 12) == "dbclickmouse" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "MouseClick('left', " & $Split[2] & ", " & $Split[3] & ", 2, " & $Split[4] & ")" & @CRLF) ElseIf StringLeft($_Read, 3) == "run" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "Run('" & $Split[2] & "')" & @CRLF) ElseIf StringLeft($_Read, 9) == "writefile" Then $_x = FileReadLine($_FileOpen, $i) $Split = StringSplit($_x, ",") FileWrite($aPath, "FileWrite('" & $Split[2] & "', '" & $Split[3] & "')" & @CRLF) ElseIf StringLeft($_Read, 4) == "exit" Then FileWrite($aPath, "Exit" & @CRLF) EndIf Next Return $aPath EndFunc Func _Execute($Script) Run('"C:\Program Files\AutoIt3\AutoIt3.exe" "' & $Script & '"') Sleep(100) FileClose($_FileOpen) If FileExists($aPath) Then FileDelete($aPath) If FileExists($qPath) Then FileDelete($qPath) EndFunc Func OnAutoItExit() FileClose($_FileOpen) If FileExists($qPath) Then FileDelete($qPath) If FileExists($aPath) Then FileDelete($aPath) EndFuncStill need help in the begin at _Translate (read the comment).Done. AlmarM Edited April 13, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Cynagen Posted April 13, 2009 Share Posted April 13, 2009 (edited) Hi, I'm tired so i'll keep it short. Some stuff you might want to know. // Comment msgbox,title,text sleep,time (in ms) send,text sendkey,key (ex: {enter}) controlsend,title,text controlsendkey,title,key beep,hz,time (in ms) movemouse,x,y,speed (0 - 100) clickmouse,x,y,speed dbclickmouse,x,y,speed run,path (Lot of AutoIt script that there's no need repeating.) Still need help in the begin at _Translate (read the comment). AlmarM For the _Translate, you could use your open handle, read the entire file into a variable, and then split it to get your count. There's 1 common line concatenation between all operating systems now, chr(10) (aka Line Feed). Carriage Return (char 13) would only work under windows. Assuming we might take input written on other systems, we need to go with the one common denominator, and that's Line Feed (char 10). So we can use the following: $_FileLines = StringSplit(FileRead($_FileOpen),chr(10)) For $i = 1 to $_FileLines[0] Edited April 13, 2009 by Cynagen Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums. Link to comment Share on other sites More sharing options...
AlmarM Posted April 13, 2009 Author Share Posted April 13, 2009 (edited) Nice! It worked. Thx mate AlmarM EDIT: Updated! View first post. Edited April 13, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
AlmarM Posted April 13, 2009 Author Share Posted April 13, 2009 I made a little example: msgbox,Start,Script Start! sleep,1000 run,notepad.exe sleep,1000 controlsend,Naamloos - Kladblok,Test! controlsendkey,Naamloos - Kladblok,{enter} sleep,1000 movemouse,100,100,50 sleep,1000 clickmouse,500,500,40 sleep,1000 dbclickmouse,350,400,30 sleep,1000 beep,1000,1000 sleep,1000 writefile,C:\testfile.txt,It worked! msgbox,Done,Script Finished! exit msgbox,...,I wont be executed! AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Xand3r Posted April 13, 2009 Share Posted April 13, 2009 (edited) nice one alarm some suggestions : 1.make it run inside the script expandcollapse popupGlobal $qPath = @ScriptDir & "\EasyMacro.txt" Global $aPath = @ScriptDir & "\EasyMacro.au3" Global $_FileOpen If FileExists($qPath) Then FileDelete($qPath) If FileExists($aPath) Then FileDelete($aPath) $GUI = GUICreate("Easy Macro", 500, 450) $cEdit = GUICtrlCreateEdit("msgbox,My First Script,Hello World!", 10, 10, 480, 400) $cRun = GUICtrlCreateButton("Run", 190, 417, 100, 25) GUISetState() GUICtrlSetFont($cEdit, "", "", "", "System") While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 FileClose($_FileOpen) Exit Case $nMsg = $cRun $RaS = _ReadAndSave(GUICtrlRead($cEdit), $qPath) $Tran = _Translate($RaS) OnAutoItExit() EndSelect WEnd Func _ReadAndSave($Control, $Path) FileWrite($Path, $Control) Return $Path EndFunc Func _Translate($File) $_FileOpen = FileOpen($File, 0) $TotalLines = StringSplit(FileRead($_FileOpen), Chr(10)) For $i = 1 To $TotalLines[0] $_Read = FileReadLine($_FileOpen, $i) If StringLeft($_Read, 2) == "//" Then $_x = FileReadLine($_FileOpen, $i) ElseIf StringLeft($_Read, 6) == "msgbox" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") MsgBox(0, $Split[2], $Split[3]) ElseIf StringLeft($_Read, 5) == "sleep" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") Sleep($Split[2]) ElseIf StringLeft($_Read, 4) == "send" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") Send($Split[2]) ElseIf StringLeft($_Read, 7) == "sendkey" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") Send($Split[2]) ElseIf StringLeft($_Read, 11) == "controlsend" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") ControlSend($Split[2], '', '', $Split[3]) ElseIf StringLeft($_Read, 14) == "controlsendkey" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") ControlSend($Split[2], '', '', $Split[3]) ElseIf StringLeft($_Read, 4) == "beep" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") Beep($Split[2], $Split[3]) ElseIf StringLeft($_Read, 9) == "movemouse" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") MouseMove($Split[2],$Split[3],$Split[4]) ElseIf StringLeft($_Read, 10) == "clickmouse" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") MouseClick('left', $Split[2] , $Split[3] , 1, $Split[4]) ElseIf StringLeft($_Read, 12) == "dbclickmouse" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") MouseClick('left', $Split[2] , $Split[3] , 2, $Split[4]) ElseIf StringLeft($_Read, 3) == "run" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") Run($Split[2]) ElseIf StringLeft($_Read, 9) == "writefile" Then $_x = FileReadLine($_FileOpen, $i) $_x=vars($_x) $Split = StringSplit($_x, ",") FileWrite($Split[2], $Split[3]) ElseIf StringLeft($_Read, 4) == "exit" Then Exit ElseIf StringRegExp($_Read,"\$.*=.*") Then $_x = FileReadLine($_FileOpen,$i) Assign(StringTrimLeft(StringLeft($_x,StringInStr($_x,"=")-1),1),Execute(StringTrimLeft($_x,StringInStr($_x,"="))),2) EndIf Next Return $aPath EndFunc Func OnAutoItExit() FileClose($_FileOpen) If FileExists($qPath) Then FileDelete($qPath) If FileExists($aPath) Then FileDelete($aPath) EndFunc Func vars($text) $reg=StringRegExp($text,"\$.*?\$",3) For $result In $reg $text=StringReplace($text,$result,Eval(StringTrimLeft(StringTrimRight($result,1),1))) Next Return $text EndFunc like that why? because it could act like some kind of plugin... 2. try to make it accept "," in the input something like regexp \, would be ignored that's about it 3. add vars $myvar=value and in functions ex: msgobx,10,$myvar$ hehe nice job Edited April 13, 2009 by TheMadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
jvanegmond Posted April 13, 2009 Share Posted April 13, 2009 (edited) Looks like AutoIt v2. Are you planning on adding backwards functionality? It's a little late for now. Edited April 13, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Xand3r Posted April 13, 2009 Share Posted April 13, 2009 Looks like AutoIt v2. Are you planning on adding backwards functionality?It's a little late for now.actually with a few modifications you can make small plugins for autoit v3.... Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
AlmarM Posted April 13, 2009 Author Share Posted April 13, 2009 Hmm I was thinking about doing the vars, but I still have no clue how to start it. And about the "," in the input. I can change the StringSplit to ... "|" ? And keep up the ideas! AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Xand3r Posted April 13, 2009 Share Posted April 13, 2009 Hmm I was thinking about doing the vars, but I still have no clue how to start it. And about the "," in the input. I can change the StringSplit to ... "|" ?And keep up the ideas!AlmarMlook at my reply i made the vars part Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
AlmarM Posted April 14, 2009 Author Share Posted April 14, 2009 (edited) look at my reply i made the vars part Im getting an error, must be an object. AlmarM EDIT: The Func vars($text) $reg=StringRegExp($text,"\$.*?\$",3) For $result In $reg $text=StringReplace($text,$result,Eval(StringTrimLeft(StringTrimRight($result,1),1))) Next Return $text EndFunc Edited April 14, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Authenticity Posted April 14, 2009 Share Posted April 14, 2009 Dim $MyVar = 'Hello', $my = 'World' Dim $sText = 'koekdeodd ed $MyVar$ -2 lsss 2-s 2 $my$' Dim $sRet = vars($sText) ConsoleWrite($sRet & @LF) Func vars($text) $reg = StringRegExp($text,"\$(.*?)\$",3) For $result In $reg $text=StringReplace($text, '$' & $result & '$', Eval($result)) Next Return $text EndFunc Hmm.. and what if it's an array? Link to comment Share on other sites More sharing options...
Xand3r Posted April 14, 2009 Share Posted April 14, 2009 (edited) Im getting an error, must be an object. AlmarM EDIT: The Func vars($text) $reg=StringRegExp($text,"\$.*?\$",3) For $result In $reg $text=StringReplace($text,$result,Eval(StringTrimLeft(StringTrimRight($result,1),1))) Next Return $text EndFuncFunc vars($text) $reg=StringRegExp($text,"\$.*?\$",3) If Not IsArray($reg) return $text For $result In $reg $text=StringReplace($text,$result,Eval(StringTrimLeft(StringTrimRight($result,1),1))) Next Return $text EndFunc @Authenticity: it's not possible with arrays Edited April 14, 2009 by TheMadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
Authenticity Posted April 14, 2009 Share Posted April 14, 2009 (edited) Sure it's, the question is what you'll do to skip strings such as "My variable is called $lol$" ? you need to be more specific.Dim $avArray[2] = ['!!!!', '++++'] Dim $iValue = 99 Dim $sSource = 'blah $avArray[0]$ blah l... .l $iValue$ o0l 0 0 oO $avArray[1]$ owosk $avArray[10]$' Dim $sRet = Vars($sSource) ConsoleWrite($sRet & @LF) Func Vars($sText) Local $aMatches = StringRegExp($sText, '\$(.*?)\$', 3) If IsArray($aMatches) Then For $Match In $aMatches If StringInStr($Match, '[') Then Local $aArrVar = StringRegExp($Match, '(\w+)\[(\d+)\]', 1) $sText = StringReplace($sText, '$' & $Match & '$', _Eval(Eval($aArrVar[0]), $aArrVar[1])) Else $sText = StringReplace($sText, '$' & $Match & '$', Eval($Match)) EndIf Next EndIf Return $sText EndFunc Func _Eval($avArr, $iElement) If Not IsArray($avArr) Then Return '' If $iElement > (UBound($avArr)-1) Then Return '' Return $avArr[$iElement] EndFuncoÝ÷ Ù±ßÛ5ìm²×©Ëhzö¥¹«^²Úâ%G´ß¦¯ºÚ˴ߦ(ºwvÚç$¶hÂ+a¶½©_ºw-è®Ø^JÚâ^Li-¦ºi¹r²¶§X¤y«¢+ØÅÕ½Ðì ÀäÈíܬ¤ üèÀäÈíl ÀäÈí¬¤ÀäÈít¤¬ÅÕ½Ðì(í¹Ñ¡¸Í½µÑ¡¥¹±¥è((ÀÌØíÍ ±°ôÅÕ½Ðí}Ù°¡Ù° ÀÌØíÉÉYÉlÁt¤ÅÕ½Ðì()½ÈÀÌØí¤ôÄQ¼U ½Õ¹ ÀÌØíÉÉYȤ´Ä(ÀÌØíÍ ±°µÀìôÅÕ½Ðì°ÅÕ½ÐìµÀìÀÌØíÉÉYÉlÀÌØí¥t)9áÐ((ÀÌØíÍ ±°µÀìôÅÕ½Ðì¤ÅÕ½Ðì(ÀÌØíÍQáÐôMÑÉ¥¹IÁ± ÀÌØíÍQáаÌäìÀÌØìÌäìµÀìÀÌØí5Ñ µÀìÌäìÀÌØìÌäì±áÕÑ ÀÌØíÍ ±°¤¤((츸¸Edit2: ... Edited April 14, 2009 by Authenticity 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