List of commands that affect ErrorLevel Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

List of commands that affect ErrorLevel

02 Apr 2018, 16:59

Has anyone catalogued the built-in commands that affect ErrorLevel? I would find it useful.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: List of commands that affect ErrorLevel

09 Apr 2018, 12:18

I don't know if this is 100% accurate. I thought I'd give it a try though.

I opened the AutoHotkey docs, switched to the "Search" menu tab, and typed ErrorLevel.

The returned list of commands is listed below:

https://autohotkey.com/docs/commands/RegRead.htm - RegRead
https://autohotkey.com/docs/commands/RegDelete.htm - RegDelete
https://autohotkey.com/docs/commands/RegWrite.htm - RegWrite
https://autohotkey.com/docs/commands/Input.htm - Input
https://autohotkey.com/docs/commands/Process.htm - Process
https://autohotkey.com/docs/commands/ControlGet.htm - ControlGet
https://autohotkey.com/docs/commands/SoundSet.htm - SoundSet
https://autohotkey.com/docs/commands/PostMessage.htm - PostMessage / SendMessage
https://autohotkey.com/docs/commands/Run.htm - Run[Wait]
https://autohotkey.com/docs/commands/DllCall.htm - DllCall
https://autohotkey.com/docs/commands/FileCopy.htm - FileCopy
https://autohotkey.com/docs/commands/FileMove.htm - FileMove
https://autohotkey.com/docs/commands/FileRead.htm - FileRead
https://autohotkey.com/docs/commands/SoundGet.htm - SoundGet
https://autohotkey.com/docs/commands/Drive.htm - Drive
https://autohotkey.com/docs/commands/DriveGet.htm - DriveGet
https://autohotkey.com/docs/commands/Hotkey.htm - Hotkey
https://autohotkey.com/docs/commands/ImageSearch.htm - ImageSearch
https://autohotkey.com/docs/commands/StringReplace.htm - StringReplace / StrReplace()
https://autohotkey.com/docs/commands/WinWait.htm - WinWait
https://autohotkey.com/docs/commands/WinWaitActive.htm - WinWait[Not]Active
https://autohotkey.com/docs/commands/ClipWait.htm - ClipWait
https://autohotkey.com/docs/commands/FileReadLine.htm - FileReadLine
https://autohotkey.com/docs/commands/InputBox.htm - InputBox
https://autohotkey.com/docs/commands/KeyWait.htm - KeyWait
https://autohotkey.com/docs/commands/PixelSearch.htm - PixelSearch
https://autohotkey.com/docs/commands/StatusBarWait.htm - StatusBarWait
https://autohotkey.com/docs/commands/StringGetPos.htm - StringGetPos
https://autohotkey.com/docs/commands/WinWaitClose.htm - WinWaitClose
https://autohotkey.com/docs/commands/Control.htm - Control
https://autohotkey.com/docs/commands/Co ... tFocus.htm - ControlGetFocus
https://autohotkey.com/docs/commands/FileCopyDir.htm - FileCopyDir
https://autohotkey.com/docs/commands/FileDelete.htm - FileDelete
https://autohotkey.com/docs/commands/Fi ... ortcut.htm - FileGetShortcut
https://autohotkey.com/docs/commands/FileRemoveDir.htm - FileRemoveDir
https://autohotkey.com/docs/commands/FileSetTime.htm - FileSetTime
https://autohotkey.com/docs/commands/GuiControl.htm - GuiControl
https://autohotkey.com/docs/commands/GuiControlGet.htm - GuiControlGet
https://autohotkey.com/docs/commands/RegExMatch.htm - RegExMatch
https://autohotkey.com/docs/commands/RegExReplace.htm - RegExReplace
https://autohotkey.com/docs/commands/ControlClick.htm - ControlClick
https://autohotkey.com/docs/commands/ControlFocus.htm - ControlFocus
https://autohotkey.com/docs/commands/ControlGetText.htm - ControlGetText
https://autohotkey.com/docs/commands/ControlMove.htm - ControlMove
https://autohotkey.com/docs/commands/ControlSend.htm - ControlSend[Raw]
https://autohotkey.com/docs/commands/ControlSetText.htm - ControlSetText
https://autohotkey.com/docs/commands/EnvSet.htm - EnvSet
https://autohotkey.com/docs/commands/EnvUpdate.htm - EnvUpdate
https://autohotkey.com/docs/commands/FileAppend.htm - FileAppend
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: List of commands that affect ErrorLevel

09 Apr 2018, 14:07

Thank you! I went through the same steps but couldn't figure out how to save the results. I appreciate you doing that and, for my own education, am curious if there is a simple way to get the list you posted.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: List of commands that affect ErrorLevel

09 Apr 2018, 14:28

iPhilip wrote:Thank you! I went through the same steps but couldn't figure out how to save the results. I appreciate you doing that and, for my own education, am curious if there is a simple way to get the list you posted.
I'm happy to share the methods I used! You can probably adapt this for use in your web browser of choice.

1) Open Mozilla Firefox
2) Navigate to https://autohotkey.com/docs/commands/index.htm
3) Click the 'Search' tab in upper-left corner
4) Enter "ErrorLevel" in the search field
5) Press F12 key to open 'Developer Tools'
6) Click the 'Inspector' tab from the Developer Tools panel/window.
7) Expand the Source HTML until you find div.list

Code: Select all

html
	body
		div#body
			div#main
				div#left
					div.search
						div.list
8) When you find <div class="list">, right-click it and choose "Copy" > "Inner HTML"
9) Paste clipboard contents into Notepad++
10) Use Find/Replace (and more) until the list is formatted to your liking.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: List of commands that affect ErrorLevel

09 Apr 2018, 14:30

Decompile the chm using 7-Zip to give multiple files, and try NirSoft SearchMyFiles, searching for ErrorLevel, and get a list of htm files.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: List of commands that affect ErrorLevel

09 Apr 2018, 15:13

Here's a script, to get the name/title/relevant lines of text, for htm files that contain a string.

Code: Select all

q:: ;get htm files that contain needle
vNeedle := "ErrorLevel"
vDir1 := A_Desktop "\AutoHotkey_1.1.28.02\AutoHotkey\docs\commands"
VarSetCapacity(vOutput, 1000000*2)
Loop, Files, % vDir1 "\*.htm", F
{
	vPath := A_LoopFileFullPath
	SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
	FileRead, vHtml, % vPath
	if !InStr(vHtml, vNeedle)
		continue
	vOutput .= "[TITLE] " JEE_HtmlGetTitle(vHtml) "`r`n"
	vHtml := RegExReplace(vHtml, "<.*?>")
	vOutput .= "[NAME] " vName "`r`n"
	Loop, Parse, vHtml, `n, `r
		if InStr(A_LoopField, vNeedle)
			vOutput .= A_LoopField "`r`n"
}
Clipboard := vOutput
MsgBox, % "done"
return

;==================================================

JEE_HtmlGetTitle(ByRef vHtml)
{
	if (vHtml = "")
		return
	vPos1 := InStr(vHtml, "<title>")
	if !vPos1
		vPos1 := InStr(vHtml, "<title")
	vPos2 := InStr(vHtml, "</title>", 0, vPos1) + 7
	if vPos1 && !(vPos2 = 7)
		vHtml2 := SubStr(vHtml, vPos1, vPos2-vPos1+1)
	else
		return

	oHTML := ComObjCreate("HTMLFile")
	oHTML.Write(vHtml2)
	try vText := oHTML.getElementsByTagName("title")[0].innerText
	oHTML := ""

	vText := StrReplace(vText, "`r", " ")
	vText := StrReplace(vText, "`n", " ")
	vText := StrReplace(vText, "`t", " ")
	vText := Trim(vText, " ")
	vText := RegExReplace(vText, " {2,}", " ")
	return vText
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: List of commands that affect ErrorLevel

17 Apr 2018, 20:26

TheDewd wrote:I'm happy to share the methods I used! You can probably adapt this for use in your web browser of choice.

1) Open Mozilla Firefox
2) Navigate to https://autohotkey.com/docs/commands/index.htm
3) Click the 'Search' tab in upper-left corner
4) Enter "ErrorLevel" in the search field
5) Press F12 key to open 'Developer Tools'
6) Click the 'Inspector' tab from the Developer Tools panel/window.
7) Expand the Source HTML until you find div.list

Code: Select all

html
	body
		div#body
			div#main
				div#left
					div.search
						div.list
8) When you find <div class="list">, right-click it and choose "Copy" > "Inner HTML"
9) Paste clipboard contents into Notepad++
10) Use Find/Replace (and more) until the list is formatted to your liking.
Hi TheDewd,

Thank you! That was very helpful. I used the results of that approach to post a suggestion for documentation improvements here.
jeeswg wrote:Here's a script, to get the name/title/relevant lines of text, for htm files that contain a string.

Code: Select all

q:: ;get htm files that contain needle
vNeedle := "ErrorLevel"
vDir1 := A_Desktop "\AutoHotkey_1.1.28.02\AutoHotkey\docs\commands"
VarSetCapacity(vOutput, 1000000*2)
Loop, Files, % vDir1 "\*.htm", F
{
	vPath := A_LoopFileFullPath
	SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
	FileRead, vHtml, % vPath
	if !InStr(vHtml, vNeedle)
		continue
	vOutput .= "[TITLE] " JEE_HtmlGetTitle(vHtml) "`r`n"
	vHtml := RegExReplace(vHtml, "<.*?>")
	vOutput .= "[NAME] " vName "`r`n"
	Loop, Parse, vHtml, `n, `r
		if InStr(A_LoopField, vNeedle)
			vOutput .= A_LoopField "`r`n"
}
Clipboard := vOutput
MsgBox, % "done"
return

;==================================================

JEE_HtmlGetTitle(ByRef vHtml)
{
	if (vHtml = "")
		return
	vPos1 := InStr(vHtml, "<title>")
	if !vPos1
		vPos1 := InStr(vHtml, "<title")
	vPos2 := InStr(vHtml, "</title>", 0, vPos1) + 7
	if vPos1 && !(vPos2 = 7)
		vHtml2 := SubStr(vHtml, vPos1, vPos2-vPos1+1)
	else
		return

	oHTML := ComObjCreate("HTMLFile")
	oHTML.Write(vHtml2)
	try vText := oHTML.getElementsByTagName("title")[0].innerText
	oHTML := ""

	vText := StrReplace(vText, "`r", " ")
	vText := StrReplace(vText, "`n", " ")
	vText := StrReplace(vText, "`t", " ")
	vText := Trim(vText, " ")
	vText := RegExReplace(vText, " {2,}", " ")
	return vText
}
Hi jeeswg,

Thank you, too. That's a very powerful script. There was a lot of material to sort through in the results (519 lines!). I appreciate you sharing the script, especially your function.

Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: List of commands that affect ErrorLevel  Topic is solved

18 Apr 2018, 17:49

- I used my script above to produce a list. I retrieved the text, replaced ErrorLevel with ERRORLEVEL to make occurrences more obvious, and read through the whole thing manually. Hopefully the list is correct, but it's so hard to get these things perfect.
- AFAICT all of the items in both TheDewd's and iPhilip's lists are correct, however, there may be around 30 items missing. Btw this list includes commands *and* functions. I see no reason to exclude functions.
- The two lists:
List of commands that affect ErrorLevel - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 00#p211500
Suggestions on documentation improvements - Page 20 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 25#p213325
- To assume that if a command's page contains 'ErrorLevel' means that the command uses it, would give you false positives. However, if the page contains 'ErrorLevel is set to' this is usually a good indicator.
- Some command/function pages mention ErrorLevel explicitly to say that it is *not* set by the command/function: Hotstring, IniRead, RunAs, WinClose, WinKill.
- It might be worth adding additional info to the list below, e.g. commands that only set ErrorLevel if UseErrorLevel is used etc.
- I've added a link to this page to my list of commands/functions etc.
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 42#p131642
- My list. Note: the text comes directly from the webpage titles.

Code: Select all

;AHK v1 commands/functions that set ErrorLevel
ClipWait
Control
ControlClick
ControlFocus
ControlGet
ControlGetFocus
ControlGetText
ControlMove
ControlSend[Raw]
ControlSetText
DllCall
Drive
DriveGet
EnvSet
EnvUpdate
FileAppend
FileCopy
FileCopyDir
FileCreateDir
FileCreateShortcut
FileDelete
FileGetAttrib
FileGetShortcut
FileGetSize
FileGetTime
FileGetVersion
FileInstall
FileMove
FileMoveDir
FileRead
FileReadLine
FileRecycle
FileRecycleEmpty
FileRemoveDir
FileSelectFile
FileSelectFolder
FileSetAttrib
FileSetTime
GroupActivate
GUI
GuiControl
GuiControlGet
Hotkey
ImageSearch
IniDelete
IniWrite
Input
InputBox
KeyWait
Menu
PixelGetColor
PixelSearch
PostMessage / SendMessage
Process
RegDelete
RegExMatch
RegExReplace
RegRead
RegWrite
Run[Wait]
SetWorkingDir
Sort
SoundGet
SoundGetWaveVolume
SoundPlay
SoundSet
SoundSetWaveVolume
StatusbarGetText
StatusBarWait
StringGetPos
StringReplace / StrReplace() [note: StringReplace can affect ErrorLevel, but not StrReplace]
UrlDownloadToFile
WinGetText
WinMenuSelectItem
WinSet
WinWait
WinWait[Not]Active
WinWaitClose
Taken out: Loop (registry). [RegRead/RegWrite can affect ErrorLevel, but not Loop]

[EDIT:] A full list has been added here:
ErrorLevel
https://autohotkey.com/docs/misc/ErrorLevel.htm
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Decar, doodles333, mikeyww and 231 guests