Benny-D wrote:
I think it's not that hard.
I might've been too self-confident in saying that. On one hand, I kind of came up with
a script discerning the command lines (I don't know if this way is the best way, though) :
Code:
code =
(
Msgbox, about to start
x = 1
Msgbox, Here is x: %x%
)
CommandList=
(Join
AutoTrim,BlockInput,ClipWait,Control,ControlClick,ControlFocus,
ControlGet,ControlGetFocus,ControlGetPos,ControlGetText,
ControlMove,ControlSend,ControlSendRaw,ControlSetText,CoordMode,
DetectHiddenText,DetectHiddenWindows,Drive,DriveGet,
DriveSpaceFree,Edit,EnvAdd,EnvDiv,EnvMult,EnvSet,EnvSub,EnvUpdate,
ExitApp,FileAppend,FileCopy,FileCopyDir,FileCreateDir,
FileCreateShortcut,FileDelete,FileGetAttrib,FileGetShortcut,
FileGetSize,FileGetTime,FileGetVersion,FileMove,FileMoveDir,
FileRead,FileReadLine,FileRecycle,FileRecycleEmpty,FileRemoveDir,
FileSelectFile,FileSelectFolder,FileSetAttrib,FileSetTime,
GetKeyState,GroupActivate,GroupAdd,GroupClose,GroupDeactivate,Gui,
GuiControl,GuiControlGet,Hotkey,IfEqual,IfNotEqual,IfExist,
IfNotExist,IfGreater,IfGreaterOrEqual,IfInString,IfNotInString,
IfLess,IfLessOrEqual,IfMsgBox,IfWinActive,IfWinNotActive,IfWinExist,
IfWinNotExist,ImageSearch,IniDelete,IniRead,IniWrite,Input,InputBox,
KeyHistory,KeyWait,ListHotkeys,ListLines,ListVars,Menu,MouseClick,
MouseClickDrag,MouseGetPos,MouseMove,MsgBox,OnExit,OutputDebug,
Pause,PixelGetColor,PixelSearch,PostMessage,Process,Progress,Random,
RegDelete,RegRead,RegWrite,Reload,Run,RunAs,RunWait,Send,SendRaw,
SendMessage,SetBatchLines,SetCapslockState,SetControlDelay,
SetDefaultMouseSpeed,SetFormat,SetKeyDelay,SetMouseDelay,
SetNumlockState,SetScrollLockState,SetStoreCapslockMode,SetTimer,
SetTitleMatchMode,SetWinDelay,SetWorkingDir,Shutdown,Sleep,Sort,
SoundBeep,SoundGet,SoundGetWaveVolume,SoundPlay,SoundSet,
SoundSetWaveVolume,SplashImage,SplashTextOn,SplashTextOff,SplitPath,
StatusBarGetText,StatusBarWait,StringCaseSense,StringGetPos,
StringLeft,StringLen,StringLower,StringMid,StringReplace,StringRight,
StringSplit,StringTrimLeft,StringTrimRight,StringUpper,Suspend,
SysGet,Thread,ToolTip,Transform,TrayTip,URLDownloadToFile,
WinActivate,WinActivateBottom,WinClose,WinGetActiveStats,
WinGetActiveTitle,WinGetClass,WinGet,WinGetPos,WinGetText,
WinGetTitle,WinHide,WinKill,WinMaximize,WinMenuSelectItem,
WinMinimize,WinMinimizeAll,WinMinimizeAllUndo,WinMove,WinRestore,
WinSet,WinSetTitle,WinShow,WinWait,WinWaitActive,WinWaitClose,
WinWaitNotActive
)
loop, parse, code, `n
{
result := "is not"
CodeLine= %A_LoopField%
loop, parse, CommandList, `,
{
FoundPos := InStr(CodeLine, A_LoopField)
If FoundPos = 1
{
result := "is"
break
}
}
msgbox, The code line # %A_Index% %result% a command line
}
But, on the other hand, when I was trying to incorporate it with that function, I realized
that I don't know how to turn the non-command lines in to "Run mode", i.e. if the
parsing loop sees that "X=1" line is not a command line, how can it let the script simply
run that line (assign value "1" to the variable "X")?