正文

AutoIt脚本的反编译和代码格式化问题分析(lua脚本反编译工具手机版)新鲜出炉

文章摘要

这篇文章介绍了名为`au3formatter`的Python脚本,其主要目的是对AU3格式的文本文件进行处理和调整。脚本通过定义`au3formatter`函数和`main`函数,实现对输入文件中不同语句的缩进调整。具体来说,脚本根据输入行的开始关键词(如`;end;`、`;until;`、`;next;`、`;wend;`、`;if;`、`;for;`、`;select;`、`;switch;`、`;while;`、`;do;`、`;else;`、`;case;`等)自动调整缩进级别,从而生成符合特定格式的输出文件。该脚本能够处理多种AU3文件格式,并将其转换为指定的输出格式。

 #!/usr/bin/env python2.7 #-*- coding: utf-8 -*- _AU3=’;https://www.jb51.net/article/sample.au3′; _AU3_OUT=’;https://www.jb51.net/article/format.au3′; _INDENT=’; ‘; * 4 def au3formater(line, indent): line=line.strip().lower() next_indent=indent if (line.startswith(‘;end’;) or line.startswith(‘;until’;) or line in (‘;next’;, ‘;wend’;)): indent -=1 next_indent -=1 elif line.startswith(‘;if’;) and line.endswith(‘;then’;): next_indent +=1 elif (line.startswith(‘;func’;) or line.startswith(‘;for’;) or line.startswith(‘;select’;) or line.startswith(‘;switch’;) or line.startswith(‘;while’;) or line==’;do’;): next_indent +=1 elif line.startswith(‘;else’;) or line.startswith(‘;case’;): indent -=1 new_line=_INDENT * indent + line return new_line, next_indent def main(): with open(_AU3, ‘;r’;) as fp: with open(_AU3_OUT, ‘;w’;) as fpw: indent=0 line=fp.readline() while line: new_line, indent=au3formater(line, indent) fpw.write(‘;%s\n’; % new_line) line=fp.readline() if __name__==’;__main__’;: main()