[已解决]请教如何转换这段字符串
本帖最后由 wangms 于 2014-4-18 00:46 编辑zhesnoW老师AU3Tool工具箱配置文件中有这样字符串:
%windir%\explorer.exe %app%\Extras\PCRE
zhesnoW老师的这个字符串不知如何调用,又特想使用这种格式的配置文件!!
假设AU3安装目录是:
$InstallDir_AU3 = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)
求转换为:@WindowsDir\explorer.exe $InstallDir_AU3\Extras\PCRE的代码!
这个字符串能用在ShellExecute()里,谢谢各位老师先!!! 自己顶一下,等待高手指点!!!!!!!! 回复 1# wangms
先设置系统的环境变量APP=AU3的安装目录。就可以直接用%app%\Extras\PCRE,格式了 本帖最后由 wangms 于 2014-4-12 23:19 编辑
回复 3# 121044246
谢谢指教!!我不想改变系统环境变量,只是想将%windir%\explorer.exe %app%\Extras\PCRE替换成:@WindowsDir\explorer.exe $InstallDir_AU3\Extras\PCRE 这样,
%app%是固定换成 $InstallDir_AU3\,容易!但@WindowsDir也可能其他的系统环境变量,想替换成au3对应的宏变量,麻烦!就是想求教这个脚本代码如何写? 不知zhesnoW老师AU3Tool是如何调用这种格式的配置文件?期待高手出现指教!! 回复 4# wangms
但@WindowsDir也可能其他的系统环境变量,想替换成au3对应的宏变量,麻烦!就是想求教这个脚本代码如何写?
没明白你这个的意思 本帖最后由 121044246 于 2014-4-12 23:50 编辑
@WindowsDir就是当前系统的windows目录,怎么可能是其他系统的变量,如果你担心@WindowsDir不是EXPLORER的目录完全可以不需要使用,办法很多$InstallDir_AU3 = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)
;-------------------例子一--------------------
ShellExecute("explorer.exe",$InstallDir_AU3)
;-------------------例子二--------------------
#include <Process.au3>
_RunDos($InstallDir_AU3)
;-------------------例子三--------------------
ShellExecute(@HomeDrive&"\windows\explorer.exe",$InstallDir_AU3) 回复 7# 121044246
谢谢老师不胜其烦!我说的不太清楚。
1=Au3Info [&I];%app%\Au3Info.exe
1=SPY++程序;%windir%\explorer.exe %app%\Extras\Spy++
1=Spy4Win ;%app%\Tools\Spy4Win\Spy4Win.exe
1=百度搜索一下 [&B];C:\Program Files\Internet Explorer\iexplore.exe http://www.baidu.com
1=程序所在目录 [&P];%windir%\explorer.exe %app%
1=检测官方更新 [&U];%app%\AutoIt3.exe %app%\Extras\AutoUpdateIt\AutoUpdateIt.au3
2=AU3函数巡捕 ;%app%\Tools\Au3ChmFunc.exe
2=彗星小助手 ;%app%\Tools\CometAssistant.exe
2=图标提取专家 ;%app%\Tools\icon.exe
2=XueTr ;%app%\Tools\XueTr.EXE
2=SQLite 数据库管理;%APP%\Extras\SQLite\SQLiteQuery.exe
2=OLE程序查看器;%app%\Extras\OLEview\oleview.exe
2=WMI ScriptoMatic;%app%\AutoIt3.exe %app%\Extras\OLEview\scriptomatic.exe
2=DLL查看器;%app%\Extras\OtherEXE\Depends.Exe
2=程序资源修改;%app%\Extras\OtherEXE\ResHacker.exe
2=软件皮肤DLL;%windir%\explorer.exe %app%\Extras\Otherfile
2=PCRE正则表达式测试工具;%windir%\explorer.exe %app%\Extras\PCRE
2=SQLite测试工具;%windir%\explorer.exe %app%\Extras\SQLite
3=ACN SCITE;%app%\scite\scite.exe
3=KODA 图形编辑器;%app%\SciTe\Koda\FD.exe
4=运行一个脚本 [&R];%app%\AutoIt3.exe
4=编译一个脚本 [&AU3];%app%\Aut2Exe\Aut2exe.exe
4=编译一个脚本 ;%app%\SciTe\ACNWrapper\ACNWrapper.exe
4=编译一个脚本 [&GUI];%app%\SciTe\ACNWrapper\ACNWrapper.exe /ShowGui
4=文件转到脚本 [&F];%ap4p%\Extras\File2script\file2script.exe
4=代码迷惑工具 [&O];%app%\SciTe\Obfuscator\Obfuscator.exe
4=代码整理工具 [&T];%app%\SciTe\Tidy\Tidy.exe
5=打开帮助文件 [&H];%app%\AutoIt3Help.exe
6=Autoit官方网站;%windir%\explorer.exe http://www.autoitscript.com/autoit3
6=Autoit官方论坛;%windir%\explorer.exe http://www.autoitscript.com/forum/index.php
这是zhesvnW老师AU3TOOL配置文件,我想直接用她,但她里面文件夹路径不是使用@宏来表示的,而是用系统环境变量% %这种格式,我就想在脚本里来转换她,以便调用。
再次谢谢老师的指点!! 本帖最后由 121044246 于 2014-4-13 01:16 编辑
$InstallDir_AU3 = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)
$peizhi = "1=程序所在目录 [&P];%windir%\explorer.exe %app%"
$1 = StringInStr($peizhi, "%app%")
$2 = StringInStr($peizhi, "%windir%")
If $1 <> 0 And $2 <> 0 Then
$3 = StringReplace($peizhi, '%app%', $InstallDir_AU3)
$4 = StringReplace($3, "%windir%", @WindowsDir)
MsgBox(0, "", $4)
ElseIf $1 <> 0 And $2 = 0 Then
$3 = StringReplace($peizhi, '%app%', $InstallDir_AU3)
MsgBox(0, "", $3)
ElseIf $1 = 0 And $2 <> 0 Then
$4 = StringReplace($3, "%windir%", @WindowsDir)
MsgBox(0, "", $4)
EndIf
回复 9# 121044246
再次谢谢老师的帮助!!现在我的问题想改为:用正则在"%windir%\explorer.exe %app%\Extras\PCRE"里找出%windir%和%app%来的正则表达式,请老师不吝赐教!! #include <WinAPI.au3>
Opt("MustDeclareVars", 1)
#include <Array.au3>
Local $InstallDir_AU3 = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)
Local $a = "%windir%\explorer.exe %app%\Extras\Otherfile"
Local $aa = StringReplace($a, "%app%", $InstallDir_AU3)
MsgBox (0,'$aa',$aa)
Local $bs = StringRegExp($aa,"%.*%",1);只知道一点点正则,就这么先用着。
For $b In $bs
Local $sysVar = $b
Next
_ArrayDisplay($bs, "$bs数组")
MsgBox (0,'$sysVar',$sysVar)
Local $au3Var = _WinAPI_ExpandEnvironmentStrings($sysVar)
MsgBox (0,'!!',$au3Var)
Local $aaa = StringReplace($aa, $sysVar, $au3Var)
MsgBox (0,'!!!',$aaa)
上面这段代码能单独执行的好好的,也用_ArrayDisplay($bs, "$bs数组")测试着变量$bs是数组,可将这段代码放进我的主脚本就提示如下错误:
请教各位老师这是什么原因?下面是我的主脚本的包含文件:
对于AU3本人是新手,可能问题挺多的,麻烦各位老师帮忙啦!!先谢谢大家!!! 本帖最后由 wangms 于 2014-4-13 07:29 编辑
不好意思!上面说的主脚本报错可能是主脚本里的条件判断不到位,由于在主脚本里$a是变化的,从而引起$bs确实不是数组而报错。
现在还是回到我请教各位老师的问题来,求教在"%windir%\explorer.exe %app%\Extras\Otherfile"里提取% %括起来的部分(包括百分号)的正则表达式。百分号%括起来部分可能是如%systemdrive%、%systemdrive%、%temp%、%ProgramFiles%等等。 %\w+?% 回复 13# afan
哎呀!!afan老师亲自指点,万分荣幸!谢谢afan老师!! 回复 14# wangms
比较老是对的… 师就不说了 :)
页:
[1]
2