Commands As Functions (Titan's/polyethene's Functions.ahk update)

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Commands As Functions (Titan's/polyethene's Functions.ahk update)

14 Jan 2017, 20:54

[EDIT:][see this link for the successor to this library]
commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=29689

First attempt at updating and completing Titan's/polyethene's Functions.ahk.
Warning: many functions are untested.

Code: Select all

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

;CF.ahk
;Commands As Functions
;AutoHotkey commands as functions
;original Functions.ahk functions by Titan/polyethene
;modifications and additional functions by jeeswg
;[updated: 2017-01-15]

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

;;;ORIGINAL FUNCTIONS

CF_IfBetween(ByRef Var, LowerBound, UpperBound) {
	if Var between %LowerBound% and %UpperBound%
	Return, 1
	else
	Return, 0
}
CF_IfNotBetween(ByRef Var, LowerBound, UpperBound) {
	if Var not between %LowerBound% and %UpperBound%
	Return, 1
	else
	Return, 0
}
CF_IfIn(ByRef Var, MatchList) {
	if Var in %MatchList%
	Return, 1
	else
	Return, 0
}
CF_IfNotIn(ByRef Var, MatchList) {
	if Var not in %MatchList%
	Return, 1
	else
	Return, 0
}
CF_IfContains(ByRef Var, MatchList) {
	if Var contains %MatchList%
	Return, 1
	else
	Return, 0
}
CF_IfNotContains(ByRef Var, MatchList) {
	if Var not contains %MatchList%
	Return, 1
	else
	Return, 0
}
CF_IfIs(ByRef Var, Type) {
	if Var is %Type%
	Return, 1
	else
	Return, 0
}
CF_IfIsNot(ByRef Var, Type) {
	if Var is not %Type%
	Return, 1
	else
	Return, 0
}
CF_ControlGet(Cmd, Value = "", Control = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	ControlGet, v, %Cmd%, %Value%, %Control%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_ControlGetFocus(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	ControlGetFocus, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_ControlGetText(Control = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	ControlGetText, v, %Control%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_DriveGet(Cmd, Value = "") {
	DriveGet, v, %Cmd%, %Value%
	Return, v
}
CF_DriveSpaceFree(Path) {
	DriveSpaceFree, v, %Path%
	Return, v
}
CF_EnvGet(EnvVarName) {
	EnvGet, v, %EnvVarName%
	Return, v
}
CF_FileGetAttrib(Filename = "") {
	FileGetAttrib, v, %Filename%
	Return, v
}
CF_FileGetShortcut(LinkFile, ByRef OutTarget = "", ByRef OutDir = "", ByRef OutArgs = "", ByRef OutDescription = "", ByRef OutIcon = "", ByRef OutIconNum = "", ByRef OutRunState = "") {
	FileGetShortcut, %LinkFile%, OutTarget, OutDir, OutArgs, OutDescription, OutIcon, OutIconNum, OutRunState
}
CF_FileGetSize(Filename = "", Units = "") {
	FileGetSize, v, %Filename%, %Units%
	Return, v
}
CF_FileGetTime(Filename = "", WhichTime = "") {
	FileGetTime, v, %Filename%, %WhichTime%
	Return, v
}
CF_FileGetVersion(Filename = "") {
	FileGetVersion, v, %Filename%
	Return, v
}
CF_FileRead(Filename) {
	FileRead, v, %Filename%
	Return, v
}
CF_FileReadLine(Filename, LineNum) {
	FileReadLine, v, %Filename%, %LineNum%
	Return, v
}
CF_FileSelectFile(Options = "", RootDir = "", Prompt = "", Filter = "") {
	FileSelectFile, v, %Options%, %RootDir%, %Prompt%, %Filter%
	Return, v
}
CF_FileSelectFolder(StartingFolder = "", Options = "", Prompt = "") {
	FileSelectFolder, v, %StartingFolder%, %Options%, %Prompt%
	Return, v
}
CF_FormatTime(YYYYMMDDHH24MISS = "", Format = "") {
	FormatTime, v, %YYYYMMDDHH24MISS%, %Format%
	Return, v
}
CF_GetKeyState(KeyName, Mode = "") {
	GetKeyState, v, %KeyName%, %Mode%
	Return, v
}
CF_GuiControlGet(Subcommand = "", ControlID = "", Param4 = "") {
	GuiControlGet, v, %Subcommand%, %ControlID%, %Param4%
	Return, v
}
CF_ImageSearch(ByRef OutputVarX, ByRef OutputVarY, X1, Y1, X2, Y2, ImageFile) {
	ImageSearch, OutputVarX, OutputVarY, %X1%, %Y1%, %X2%, %Y2%, %ImageFile%
}
CF_IniRead(Filename, Section, Key, Default = "") {
	IniRead, v, %Filename%, %Section%, %Key%, %Default%
	Return, v
}
CF_Input(Options = "", EndKeys = "", MatchList = "") {
	Input, v, %Options%, %EndKeys%, %MatchList%
	Return, v
}
CF_InputBox(Title = "", Prompt = "", HIDE = "", Width = "", Height = "", X = "", Y = "", Font = "", Timeout = "", Default = "") {
	InputBox, v, %Title%, %Prompt%, %HIDE%, %Width%, %Height%, %X%, %Y%, , %Timeout%, %Default%
	Return, v
}
CF_MouseGetPos(ByRef OutputVarX = "", ByRef OutputVarY = "", ByRef OutputVarWin = "", ByRef OutputVarControl = "", Param5 = "") {
	MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, %Param5%
}
CF_PixelGetColor(X, Y, Param3 = "") {
	PixelGetColor, v, %X%, %Y%, %Param3%
	Return, v
}
CF_PixelSearch(ByRef OutputVarX, ByRef OutputVarY, X1, Y1, X2, Y2, ColorID, Variation = "", Param9 = "") {
	PixelSearch, OutputVarX, OutputVarY, %X1%, %Y1%, %X2%, %Y2%, %ColorID%, %Variation%, %Param9%
}
CF_Random(Min = "", Max = "") {
	Random, v, %Min%, %Max%
	Return, v
}
CF_RegRead(RootKey, SubKey, ValueName = "") {
	RegRead, v, %RootKey%, %SubKey%, %ValueName%
	Return, v
}
CF_Run(Target, WorkingDir = "", Mode = "") {
	Run, %Target%, %WorkingDir%, %Mode%, v
	Return, v
}
CF_SoundGet(ComponentType = "", ControlType = "", DeviceNumber = "") {
	SoundGet, v, %ComponentType%, %ControlType%, %DeviceNumber%
	Return, v
}
CF_SoundGetWaveVolume(DeviceNumber = "") {
	SoundGetWaveVolume, v, %DeviceNumber%
	Return, v
}
CF_StatusBarGetText(Part = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	StatusBarGetText, v, %Part%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_SplitPath(ByRef InputVar, ByRef OutFileName = "", ByRef OutDir = "", ByRef OutExtension = "", ByRef OutNameNoExt = "", ByRef OutDrive = "") {
	SplitPath, InputVar, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
}
CF_StringGetPos(ByRef InputVar, SearchText, Param4 = "", Offset = "") {
	StringGetPos, v, InputVar, %SearchText%, %Param4%, %Offset%
	Return, v
}
CF_StringLeft(ByRef InputVar, Count) {
	StringLeft, v, InputVar, %Count%
	Return, v
}
CF_StringLen(ByRef InputVar) {
	StringLen, v, InputVar
	Return, v
}
CF_StringLower(ByRef InputVar, T = "") {
	StringLower, v, InputVar, %T%
	Return, v
}
CF_StringMid(ByRef InputVar, StartChar, Count , L = "") {
	StringMid, v, InputVar, %StartChar%, %Count%, %L%
	Return, v
}
CF_StringReplace(ByRef InputVar, SearchText, ReplaceText = "", ReplaceAll = "") {
	StringReplace, v, InputVar, %SearchText%, %ReplaceText%, %ReplaceAll%
	Return, v
}
CF_StringRight(ByRef InputVar, Count) {
	StringRight, v, InputVar, %Count%
	Return, v
}
CF_StringTrimLeft(ByRef InputVar, Count) {
	StringTrimLeft, v, InputVar, %Count%
	Return, v
}
CF_StringTrimRight(ByRef InputVar, Count) {
	StringTrimRight, v, InputVar, %Count%
	Return, v
}
CF_StringUpper(ByRef InputVar, T = "") {
	StringUpper, v, InputVar, %T%
	Return, v
}
CF_SysGet(Subcommand, Param3 = "") {
	SysGet, v, %Subcommand%, %Param3%
	Return, v
}
CF_Transform(Cmd, Value1, Value2 = "") {
	Transform, v, %Cmd%, %Value1%, %Value2%
	Return, v
}
CF_WinGet(Cmd = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	WinGet, v, %Cmd%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_WinGetActiveTitle() {
	WinGetActiveTitle, v
	Return, v
}
CF_WinGetClass(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	WinGetClass, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_WinGetText(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	WinGetText, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}
CF_WinGetTitle(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
	WinGetTitle, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
	Return, v
}

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

;;;ORIGINAL FUNCTIONS (ALTERNATIVE NAMES)

CF_Between(ByRef Var, LowerBound, UpperBound) {
	if Var between %LowerBound% and %UpperBound%
	Return, 1
	else
	Return, 0
}
CF_NotBetween(ByRef Var, LowerBound, UpperBound) {
	if Var not between %LowerBound% and %UpperBound%
	Return, 1
	else
	Return, 0
}
CF_In(ByRef Var, MatchList) {
	if Var in %MatchList%
	Return, 1
	else
	Return, 0
}
CF_NotIn(ByRef Var, MatchList) {
	if Var not in %MatchList%
	Return, 1
	else
	Return, 0
}
CF_Contains(ByRef Var, MatchList) {
	if Var contains %MatchList%
	Return, 1
	else
	Return, 0
}
CF_NotContains(ByRef Var, MatchList) {
	if Var not contains %MatchList%
	Return, 1
	else
	Return, 0
}
CF_Is(ByRef Var, Type) {
	if Var is %Type%
	Return, 1
	else
	Return, 0
}
CF_IsNot(ByRef Var, Type) {
	if Var is not %Type%
	Return, 1
	else
	Return, 0
}

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

;;;ORIGINAL FUNCTIONS (ALTERNATIVE NAMES+)

CF_IsType(ByRef Var, Type) {
	if Var is %Type%
	Return, 1
	else
	Return, 0
}
CF_IsNotType(ByRef Var, Type) {
	if Var is not %Type%
	Return, 1
	else
	Return, 0
}

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

;;;FUNCTIONS NOT ADDED

;CF_Break
;CF_Continue
;CF_Else
;CF_If
;CF_Loop
;CF_While

;'Source' parameter must be literal text
;CF_FileInstall(Source, Dest, Flag="") {
;	FileInstall, % Source, % Dest, % Flag
;	Return
;}

;Gui command causes scripts to become Persistent
;CF_Gui(Subcommand, Param2="", Param3="", Param4="") {
;	Gui, % Subcommand, % Param2, % Param3, % Param4
;	Return
;}

;defunct command
;CF_Repeat() {
;	Repeat
;	Return
;}

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

;;;SPECIAL FUNCTIONS

CF_MsgBox(Options="Press OK to continue.", Title="", Text="", Timeout="") {
	if (Title = "") && (Text = "") && (Timeout = "")
	Text := Options, Options := ""
	MsgBox, % Options, % Title, % Text, % Timeout

	ButtonNames = Yes,No,OK,Cancel,Abort,Ignore,Retry,Continue,TryAgain,Timeout
	Loop, Parse, ButtonNames, `,
	IfMsgBox, %A_LoopField%
	Return, A_LoopField
	Return
}

CF_Return() {
	Exit
	Return
}

;e.g.
;vText := "a,b,c"
;CF_StringSplit("vOutput", vText, ", ")
;MsgBox % vOutput " " vOutput0 " " vOutput1 " " vOutput2 " " vOutput3

CF_Sort(VarName, Options="") {
	Sort, VarName, % Options
	Return, VarName
}

CF_StringSplit(OutputArray, ByRef InputVar, Delimiters="", OmitChars="") {
	global
	StringSplit, % OutputArray, InputVar, % Delimiters, % OmitChars
	Return
}

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

;;;FUNCTIONS WITH BYREF INPUT/OUTPUT VARIABLES

CF_ControlGetPos(ByRef X="", ByRef Y="", ByRef Width="", ByRef Height="", Control="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	ControlGetPos, X, Y, Width, Height, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_EnvAdd(ByRef Var, Value, TimeUnits="") {
	EnvAdd, %Var%, %Value%, %TimeUnits%
	Return
}
CF_EnvDiv(ByRef Var, Value) {
	EnvDiv, %Var%, %Value%
	Return
}
CF_EnvMult(ByRef Var, Value) {
	EnvMult, %Var%, %Value%
	Return
}
CF_EnvSub(ByRef Var, Value, TimeUnits="") {
	EnvSub, %Var%, %Value%, %TimeUnits%
	Return
}
CF_RunWait(Target, WorkingDir="", Param3="", ByRef OutputVarPID="") {
	RunWait, % Target, % WorkingDir, % Param3, OutputVarPID
	Return
}
CF_SetEnv(ByRef Var, Value) {
	SetEnv, Var, % Value
	Return
}
CF_WinGetActiveStats(ByRef Title, ByRef Width, ByRef Height, ByRef X, ByRef Y) {
	WinGetActiveStats, Title, Width, Height, X, Y
	Return
}
CF_WinGetPos(ByRef X="", ByRef Y="", ByRef Width="", ByRef Height="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinGetPos, X, Y, Width, Height, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}

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

;;;FUNCTIONS WITH NO PARAMETERS

CF_Click() {
	Click
	Return
}
CF_Edit() {
	Edit
	Return
}
CF_EnvUpdate() {
	EnvUpdate
	Return
}
CF_KeyHistory() {
	KeyHistory
	Return
}
CF_ListHotkeys() {
	ListHotkeys
	Return
}
CF_ListVars() {
	ListVars
	Return
}
CF_Reload() {
	Reload
	Return
}
CF_SplashTextOff() {
	SplashTextOff
	Return
}
CF_WinMinimizeAll() {
	WinMinimizeAll
	Return
}
CF_WinMinimizeAllUndo() {
	WinMinimizeAllUndo
	Return
}

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

;;;IF FUNCTIONS

CF_IfEqual(ByRef Var, Value) {
	IfEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_IfExist(FilePattern) {
	IfExist, % FilePattern
	Return, 1
	else
	Return, 0
}
CF_IfGreater(ByRef Var, Value) {
	IfGreater, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_IfGreaterOrEqual(ByRef Var, Value) {
	IfGreaterOrEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_IfInString(ByRef Var, SearchString) {
	IfInString, Var, % SearchString
	Return, 1
	else
	Return, 0
}
CF_IfLess(ByRef Var, Value) {
	IfLess, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_IfLessOrEqual(ByRef Var, Value) {
	IfLessOrEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_IfNotEqual(ByRef Var, Value) {
	IfNotEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_IfNotExist(FilePattern) {
	IfNotExist, % FilePattern
	Return, 1
	else
	Return, 0
}
CF_IfNotInString(ByRef Var, SearchString) {
	IfNotInString, Var, % SearchString
	Return, 1
	else
	Return, 0
}
CF_IfWinActive(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinActive, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}
CF_IfWinExist(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinExist, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}
CF_IfWinNotActive(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinNotActive, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}
CF_IfWinNotExist(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinNotExist, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}

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

;;;IF FUNCTIONS (ALTERNATIVE NAMES)

CF_Equal(ByRef Var, Value) {
	IfEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_Exist(FilePattern) {
	IfExist, % FilePattern
	Return, 1
	else
	Return, 0
}
CF_Greater(ByRef Var, Value) {
	IfGreater, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_GreaterOrEqual(ByRef Var, Value) {
	IfGreaterOrEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_InString(ByRef Var, SearchString) {
	IfInString, Var, % SearchString
	Return, 1
	else
	Return, 0
}
CF_Less(ByRef Var, Value) {
	IfLess, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_LessOrEqual(ByRef Var, Value) {
	IfLessOrEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_NotEqual(ByRef Var, Value) {
	IfNotEqual, Var, % Value
	Return, 1
	else
	Return, 0
}
CF_NotExist(FilePattern) {
	IfNotExist, % FilePattern
	Return, 1
	else
	Return, 0
}
CF_NotInString(ByRef Var, SearchString) {
	IfNotInString, Var, % SearchString
	Return, 1
	else
	Return, 0
}
CF_WinActive(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinActive, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}
CF_WinExist(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinExist, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}
CF_WinNotActive(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinNotActive, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}
CF_WinNotExist(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	IfWinNotExist, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return, 1
	else
	Return, 0
}

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

;;;IF FUNCTIONS+

CF_IfMsgBox(ButtonName) {
	IfMsgBox, %ButtonName%
	Return, 1
	else
	Return, 0
}

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

;;;FUNCTIONS WITH ONE OR MORE PARAMETERS

CF_AutoTrim(Param1) {
	AutoTrim, % Param1
	Return
}
CF_BlockInput(Mode) {
	BlockInput, % Mode
	Return
}
CF_ClipWait(SecondsToWait="", Param2="") {
	ClipWait, % SecondsToWait, % Param2
	Return
}
CF_Control(Cmd, Value="", Control="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	Control, % Cmd, % Value, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_ControlClick(ControlOrPos="", WinTitle="", WinText="", WhichButton="", ClickCount="", Options="", ExcludeTitle="", ExcludeText="") {
	ControlClick, % ControlOrPos, % WinTitle, % WinText, % WhichButton, % ClickCount, % Options, % ExcludeTitle, % ExcludeText
	Return
}
CF_ControlFocus(Control="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	ControlFocus, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_ControlMove(Control, X, Y, Width, Height, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	ControlMove, % Control, % X, % Y, % Width, % Height, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_ControlSend(Control="", Keys="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	ControlSend, % Control, % Keys, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_ControlSendRaw(Control="", Keys="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	ControlSendRaw, % Control, % Keys, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_ControlSetText(Control="", NewText="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	ControlSetText, % Control, % NewText, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_CoordMode(Param1, Param2="") {
	CoordMode, % Param1, % Param2
	Return
}
CF_Critical(Param1) {
	Critical, % Param1
	Return
}
CF_DetectHiddenText(Param1) {
	DetectHiddenText, % Param1
	Return
}
CF_DetectHiddenWindows(Param1) {
	DetectHiddenWindows, % Param1
	Return
}
CF_Drive(Subcommand, Drive="", Value="") {
	Drive, % Subcommand, % Drive, % Value
	Return
}
CF_EnvSet(EnvVar, Value) {
	EnvSet, % EnvVar, % Value
	Return
}
CF_Exit(ExitCode="") {
	Exit, % ExitCode
	Return
}
CF_ExitApp(ExitCode="") {
	ExitApp, % ExitCode
	Return
}
CF_FileAppend(Text="", Filename="", Encoding="") {
	FileAppend, % Text, % Filename, % Encoding
	Return
}
CF_FileCopy(SourcePattern, DestPattern, Flag="") {
	FileCopy, % SourcePattern, % DestPattern, % Flag
	Return
}
CF_FileCopyDir(Source, Dest, Flag="") {
	FileCopyDir, % Source, % Dest, % Flag
	Return
}
CF_FileCreateDir(DirName) {
	FileCreateDir, % DirName
	Return
}
CF_FileCreateShortcut(Target, LinkFile, WorkingDir="", Args="", Description="", IconFile="", ShortcutKey="", IconNumber="", RunState="") {
	FileCreateShortcut, % Target, % LinkFile, % WorkingDir, % Args, % Description, % IconFile, % ShortcutKey, % IconNumber, % RunState
	Return
}
CF_FileDelete(FilePattern) {
	FileDelete, % FilePattern
	Return
}
CF_FileMove(SourcePattern, DestPattern, Flag="") {
	FileMove, % SourcePattern, % DestPattern, % Flag
	Return
}
CF_FileMoveDir(Source, Dest, Flag="") {
	FileMoveDir, % Source, % Dest, % Flag
	Return
}
CF_FileRecycle(FilePattern) {
	FileRecycle, % FilePattern
	Return
}
CF_FileRecycleEmpty(DriveLetter="") {
	FileRecycleEmpty, % DriveLetter
	Return
}
CF_FileRemoveDir(DirName, Recurse="") {
	FileRemoveDir, % DirName, % Recurse
	Return
}
CF_FileSetAttrib(Attributes, FilePattern="", OperateOnFolders="", Recurse="") {
	FileSetAttrib, % Attributes, % FilePattern, % OperateOnFolders, % Recurse
	Return
}
CF_FileSetTime(YYYYMMDDHH24MISS="", FilePattern="", WhichTime="", OperateOnFolders="", Recurse="") {
	FileSetTime, % YYYYMMDDHH24MISS, % FilePattern, % WhichTime, % OperateOnFolders, % Recurse
	Return
}
CF_Gosub(Label) {
	Gosub, % Label
	Return
}
CF_Goto(Label) {
	Goto, % Label
	Return
}
CF_GroupActivate(GroupName, R="") {
	GroupActivate, % GroupName, % R
	Return
}
CF_GroupAdd(GroupName, WinTitle="", WinText="", Label="", ExcludeTitle="", ExcludeText="") {
	GroupAdd, % GroupName, % WinTitle, % WinText, % Label, % ExcludeTitle, % ExcludeText
	Return
}
CF_GroupClose(GroupName, Param2="") {
	GroupClose, % GroupName, % Param2
	Return
}
CF_GroupDeactivate(GroupName, R="") {
	GroupDeactivate, % GroupName, % R
	Return
}
CF_GuiControl(Subcommand, ControlID, Param3="") {
	GuiControl, % Subcommand, % ControlID, % Param3
	Return
}
CF_Hotkey(KeyName, Label="", Options="") {
	Hotkey, % KeyName, % Label, % Options
	Return
}
CF_IniDelete(Filename, Section, Key="") {
	IniDelete, % Filename, % Section, % Key
	Return
}
CF_IniWrite(Value, Filename, Section, Key) {
	IniWrite, % Value, % Filename, % Section, % Key
	Return
}
CF_KeyWait(KeyName, Options="") {
	KeyWait, % KeyName, % Options
	Return
}
CF_ListLines(Param1="") {
	ListLines, % Param1
	Return
}
CF_Menu(MenuName, Cmd, P3="", P4="", P5="") {
	Menu, % MenuName, % Cmd, % P3, % P4, % P5
	Return
}
CF_MouseClick(WhichButton="L", X="", Y="", ClickCount="", Speed="", Param6="", R="") {
	MouseClick, % WhichButton, % X, % Y, % ClickCount, % Speed, % Param6, % R
	Return
}
CF_MouseClickDrag(WhichButton, X1, Y1, X2, Y2, Speed="", R="") {
	MouseClickDrag, % WhichButton, % X1, % Y1, % X2, % Y2, % Speed, % R
	Return
}
CF_MouseMove(X, Y, Speed="", R="") {
	MouseMove, % X, % Y, % Speed, % R
	Return
}
CF_OnExit(Label="") {
	OnExit, % Label
	Return
}
CF_OutputDebug(Text) {
	OutputDebug, % Text
	Return
}
CF_Pause(Param1="", OperateOnUnderlyingThread="") {
	Pause, % Param1, % OperateOnUnderlyingThread
	Return
}
CF_PostMessage(Msg, wParam="", lParam="", Control="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	PostMessage, % Msg, % wParam, % lParam, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_Process(Cmd, PIDOrName="", Param3="") {
	Process, % Cmd, % PIDOrName, % Param3
	Return
}
CF_Progress(Param1, SubText="", MainText="", WinTitle="", FontName="") {
	Progress, % Param1, % SubText, % MainText, % WinTitle, % FontName
	Return
}
CF_RegDelete(RootKey, SubKey, ValueName="") {
	RegDelete, % RootKey, % SubKey, % ValueName
	Return
}
CF_RegWrite(ValueType, RootKey, SubKey, ValueName="", Value="") {
	RegWrite, % ValueType, % RootKey, % SubKey, % ValueName, % Value
	Return
}
CF_RunAs(User="", Password="", Domain="") {
	RunAs, % User, % Password, % Domain
	Return
}
CF_Send(Keys) {
	Send, % Keys
	Return
}
CF_SendEvent(Keys) {
	SendEvent, % Keys
	Return
}
CF_SendInput(Keys) {
	SendInput, % Keys
	Return
}
CF_SendMessage(Msg, wParam="", lParam="", Control="", WinTitle="", WinText="", ExcludeTitle="", ExcludeText="", Timeout="") {
	SendMessage, % Msg, % wParam, % lParam, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText, % Timeout
	Return
}
CF_SendMode(Param1) {
	SendMode, % Param1
	Return
}
CF_SendPlay(Keys) {
	SendPlay, % Keys
	Return
}
CF_SendRaw(Keys) {
	SendRaw, % Keys
	Return
}
CF_SetBatchLines(Param1) {
	SetBatchLines, % Param1
	Return
}
CF_SetCapsLockState(State) {
	SetCapsLockState, % State
	Return
}
CF_SetControlDelay(Delay) {
	SetControlDelay, % Delay
	Return
}
CF_SetDefaultMouseSpeed(Speed) {
	SetDefaultMouseSpeed, % Speed
	Return
}
CF_SetFormat(NumberType, Format) {
	SetFormat, % NumberType, % Format
	Return
}
CF_SetKeyDelay(Delay="", PressDuration="", Play="") {
	SetKeyDelay, % Delay, % PressDuration, % Play
	Return
}
CF_SetMouseDelay(Delay, Play="") {
	SetMouseDelay, % Delay, % Play
	Return
}
CF_SetNumLockState(State) {
	SetNumLockState, % State
	Return
}
CF_SetScrollLockState(State) {
	SetScrollLockState, % State
	Return
}
CF_SetStoreCapslockMode(Param1) {
	SetStoreCapslockMode, % Param1
	Return
}
CF_SetTimer(Label, Param2="", Priority="") {
	SetTimer, % Label, % Param2, % Priority
	Return
}
CF_SetTitleMatchMode(MatchMode) {
	SetTitleMatchMode, % MatchMode
	Return
}
CF_SetWinDelay(Delay) {
	SetWinDelay, % Delay
	Return
}
CF_SetWorkingDir(DirName) {
	SetWorkingDir, % DirName
	Return
}
CF_Shutdown(Code) {
	Shutdown, % Code
	Return
}
CF_Sleep(DelayInMilliseconds) {
	Sleep, % DelayInMilliseconds
	Return
}
CF_SoundBeep(Frequency="", Duration="") {
	SoundBeep, % Frequency, % Duration
	Return
}
CF_SoundPlay(Filename, Wait="") {
	SoundPlay, % Filename, % Wait
	Return
}
CF_SoundSet(NewSetting, ComponentType="", ControlType="", DeviceNumber="") {
	SoundSet, % NewSetting, % ComponentType, % ControlType, % DeviceNumber
	Return
}
CF_SoundSetWaveVolume(Percent, DeviceNumber="") {
	SoundSetWaveVolume, % Percent, % DeviceNumber
	Return
}
CF_SplashImage(ImageFile="", Options="", SubText="", MainText="", WinTitle="", FontName="") {
	SplashImage, % ImageFile, % Options, % SubText, % MainText, % WinTitle, % FontName
	Return
}
CF_SplashTextOn(Width="", Height="", Title="", Text="") {
	SplashTextOn, % Width, % Height, % Title, % Text
	Return
}
CF_StatusBarWait(BarText="", Seconds="", Part="", WinTitle="", WinText="", Interval="", ExcludeTitle="", ExcludeText="") {
	StatusBarWait, % BarText, % Seconds, % Part, % WinTitle, % WinText, % Interval, % ExcludeTitle, % ExcludeText
	Return
}
CF_StringCaseSense(Param1) {
	StringCaseSense, % Param1
	Return
}
CF_Suspend(Mode="") {
	Suspend, % Mode
	Return
}
CF_Thread(Setting, Param2, Param3="") {
	Thread, % Setting, % Param2, % Param3
	Return
}
CF_ToolTip(Text="", X="", Y="", WhichToolTip="") {
	ToolTip, % Text, % X, % Y, % WhichToolTip
	Return
}
CF_TrayTip(Title="", Text="", Seconds="", Options="") {
	TrayTip, % Title, % Text, % Seconds, % Options
	Return
}
CF_URLDownloadToFile(URL, Filename) {
	URLDownloadToFile, % URL, % Filename
	Return
}
CF_WinActivate(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinActivate, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinActivateBottom(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinActivateBottom, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinClose(WinTitle="", WinText="", SecondsToWait="", ExcludeTitle="", ExcludeText="") {
	WinClose, % WinTitle, % WinText, % SecondsToWait, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinHide(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinHide, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinKill(WinTitle="", WinText="", SecondsToWait="", ExcludeTitle="", ExcludeText="") {
	WinKill, % WinTitle, % WinText, % SecondsToWait, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinMaximize(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinMaximize, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinMenuSelectItem(WinTitle, WinText, Menu, SubMenu1="", SubMenu2="", SubMenu3="", SubMenu4="", SubMenu5="", SubMenu6="", ExcludeTitle="", ExcludeText="") {
	WinMenuSelectItem, % WinTitle, % WinText, % Menu, % SubMenu1, % SubMenu2, % SubMenu3, % SubMenu4, % SubMenu5, % SubMenu6, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinMinimize(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinMinimize, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinMove(WinTitle, WinText, X, Y, Width="", Height="", ExcludeTitle="", ExcludeText="") {
	WinMove, % WinTitle, % WinText, % X, % Y, % Width, % Height, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinRestore(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinRestore, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinSet(Attribute, Value, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinSet, % Attribute, % Value, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinSetTitle(WinTitle, WinText, NewTitle, ExcludeTitle="", ExcludeText="") {
	WinSetTitle, % WinTitle, % WinText, % NewTitle, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinShow(WinTitle="", WinText="", ExcludeTitle="", ExcludeText="") {
	WinShow, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinWait(WinTitle="", WinText="", Seconds="", ExcludeTitle="", ExcludeText="") {
	WinWait, % WinTitle, % WinText, % Seconds, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinWaitActive(WinTitle="", WinText="", Seconds="", ExcludeTitle="", ExcludeText="") {
	WinWaitActive, % WinTitle, % WinText, % Seconds, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinWaitClose(WinTitle="", WinText="", Seconds="", ExcludeTitle="", ExcludeText="") {
	WinWaitClose, % WinTitle, % WinText, % Seconds, % ExcludeTitle, % ExcludeText
	Return
}
CF_WinWaitNotActive(WinTitle="", WinText="", Seconds="", ExcludeTitle="", ExcludeText="") {
	WinWaitNotActive, % WinTitle, % WinText, % Seconds, % ExcludeTitle, % ExcludeText
	Return
}

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

;;;FUNCTIONS FOR NEW COMMANDS ADDED SINCE AUTOHOTKEY BASIC v1.0.48.05
;[up-to-date as of v1.1.24.04]

CF_FileEncoding(Encoding="") {
	FileEncoding, % Encoding
	Return
}
CF_SendLevel(Level) {
	SendLevel, % Level
	Return
}
CF_SetRegView(RegView) {
	SetRegView, % RegView
	Return
}

;new parameters:
;Break: LoopLabel
;Continue: LoopLabel
;FileAppend: Encoding
;SendMessage: Timeout
;SetKeyDelay: Play
;SetMouseDelay: Play
;SetTimer: Priority

;optional parameters (that were previously compulsory):
;ControlSetText: Control, NewText
;GroupAdd: WinTitle
;MouseClick: WhichButton
;Process: PIDOrName
;WinWait: WinTitle, WinText, Seconds
;WinWaitClose: WinTitle, WinText, Seconds

;==================================================
I would be interested in any comments on the following functions:
(or on any aspect of Commands As Functions:)
(Is 'CF.ahk' an acceptable name, has it already been used for something?)
(I thought of 'Func.ahk' but 'Func_' is too long in function names, and it might look
like the notation for defining functions generally.)

Code: Select all

;==================================================
;;;SPECIAL FUNCTIONS

CF_MsgBox(Options="Press OK to continue.", Title="", Text="", Timeout="") {
	if (Title = "") && (Text = "") && (Timeout = "")
	Text := Options, Options := ""
	MsgBox, % Options, % Title, % Text, % Timeout

	ButtonNames = Yes,No,OK,Cancel,Abort,Ignore,Retry,Continue,TryAgain,Timeout
	Loop, Parse, ButtonNames, `,
	IfMsgBox, %A_LoopField%
	Return, A_LoopField
	Return
}

CF_Return() {
	Exit
	Return
}

;e.g.
;vText := "a,b,c"
;CF_StringSplit("vOutput", vText, ", ")
;MsgBox % vOutput " " vOutput0 " " vOutput1 " " vOutput2 " " vOutput3

CF_Sort(VarName, Options="") {
	Sort, VarName, % Options
	Return, VarName
}

CF_StringSplit(OutputArray, ByRef InputVar, Delimiters="", OmitChars="") {
	global
	StringSplit, % OutputArray, InputVar, % Delimiters, % OmitChars
	Return
}

;==================================================
Last edited by jeeswg on 26 Mar 2017, 18:31, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
TAC109
Posts: 345
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

14 Jan 2017, 23:05

I note that many of these functions are not '#warn' friendly.

(My personal preference is to use #warn in my code to help me find programming errors.)
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

15 Jan 2017, 00:38

Thanks for the information.
What would be required to make a function, '#Warn friendly'?
If you wouldn't mind providing or linking an example function before and after.
Can all of them be made '#Warn friendly'?

I looked through:
#Warn
https://autohotkey.com/docs/commands/_Warn.htm
Its script-checking capabilities seem a bit limited,
do you find it particularly helpful?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
TAC109
Posts: 345
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

15 Jan 2017, 03:33

If you declare any local variables as 'local', that should do it, i.e. Local v
The other naughty thing some coders do is to declare a variable with the same name as a parameter.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

15 Jan 2017, 03:56

Interesting! And subtle.

My penchant is to
set all the parameters in DllCall to Int or UInt, in the hope that the numbers won't ever be that big, and that the system will be 32-bit.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 6488
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 02:02

I think "commands as functions" lose most of their appeal if you add a generic prefix to every name.

For the "If" variants, I think it is more appropriate to omit "If". The function does not behave like an IF statement, and would often be used (seemingly redundantly) within one, as in If CF_IfContains(...). It's more natural to just write If Contains(...).

Regarding CF_Return: It is impossible to write a user-defined function which performs the same as a Return statement. Exit is entirely not the same thing. On another note, it is redundant to write Return after Exit. The thread has already exited; it cannot/will not return.
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 03:55

lexikos wrote:I think "commands as functions" lose most of their appeal if you add a generic prefix to every name.
I agree, and people can strip them if they want.
I wanted to be able to identify any such function I had used in my script,
for possible later replacement.
lexikos wrote:For the "If" variants, I think it is more appropriate to omit "If"
I agree with this.
I did each one in two variants, to maintain Poly's original function names,
for backwards compatibility,
and to have each command (as function) with its literal name be available,
whereas I preferred to strip the 'ifs' because:
if CF_IfContains is confusing
whereas
if CF_Contains makes more sense.
Do you know what ... I think I might dispense with them and keep the forms without ifs, it's for the best.
But leave comments including the ifs to make them easier to find.
lexikos wrote:It is impossible to write a user-defined function which performs the same as a Return
Although I am not sure if it is possible to use 'Return' when defining a function,
as far as I can tell I have a working CF_Return() function in the main body of my main script,
it appears 3420 times, at the end of each subroutine,
and it appears to do what Return does. I use a variant of CF_Return() which records each hotkey press.
For example I do things like:
if vUrl not contains youtube.com/,youtu.be/
oWB := "", CF_Return()
lexikos wrote:it is redundant to write Return after Exit
In my definition of CF_Return(),
I thought that 'Exit' would be sufficient without 'Return', but my experience
had suggested that Exit was insufficient and that Return was also necessary
afterwards, but I may be wrong.

Thanks very much for your comments, greatly appreciated.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 6488
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 04:25

CF_Goto will simply never work. Goto cannot jump out of a function, or into any block which does not enclose the goto. Actually, it seems there's a bug - instead of showing an error message in this case, goto actually just returns from the CF_Goto function and sets A_ThisLabel:

Code: Select all

CF_Goto("foo")
MsgBox % A_ThisLabel
ExitApp

foo:
MsgBox At the real foo label.  ; Never happens.
ExitApp

CF_Goto(Label) {
	Goto, % Label
	Return
}
[Edit: Apparently the "jumping out of a function" check was never implemented for dynamic jumps - i.e. where Label is a variable. By contrast, using Goto, foo directly inside the function will cause a load-time error message.]

The "IfNot" functions are quite redundant, especially if you remove the prefix. There's little difference between writing If NotBetween(Var, Low, High) and writing If Not Between(Var, Low, High).

I don't think there's much sense in wrapping the basic If-commands like IfEqual and IfGreater, which already have their own dedicated operators in expressions. I suppose that someone might prefer the longer names over symbols, although I can't imagine the order being intuitive (function name followed by both inputs).

Some of the If-commands already have function equivalents: IfExist - FileExist, IfInString - InStr, IfWinExist - WinExist, etc.

Whenever there is an "InputVar" parameter, there is really no reason to use ByRef. However, it usually does no harm.

The script would be somewhat shorter if you removed the redundant Return (where there is no return value) at the end of each function.
for backwards compatibility,
But anyone wanting that would have to modify your script anyway, to remove the prefix.
as far as I can tell I have a working CF_Return() function in the main body of my main script,
it appears 3420 times, at the end of each subroutine,
and it appears to do what Return does.
I stand by what I said. How could you ever think that using Exit inside a function is equivalent to Return in the function which called it?

Return exits only the function which contains the statement, not the function or sub which called it.

Exit exits the entire thread.
but I may be wrong.
There's no "may be" about it. The thread exiting is the opposite of the thread continuing. It can't exit and then continue to execute commands.

The only way for a command immediately below Exit to execute is if the Exit itself did not. For example:

Code: Select all

if (false)
Exit ; Not executed.
Return ; Executed.
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 04:45

All fair points, I know there are a few fairly redundant functions
present that are only there for completeness. 'By design' as Microsoft would say.

LOL about CF_Goto, some of the functions were auto-generated,
and though I did check through everything, that must have escaped
my attention partly because I never use it. This will be dealt with.

Thanks, I'll have to look into the ByRef issue. Issues regarding ByRef had been a concern at the time of writing.
lexikos wrote:I stand by what I said. How could you ever think that using Exit inside a function is equivalent to Return in the function which called it?
My Return function does what I want it to do,
but perhaps it isn't strictly a 'Return' function, and I'll consider
renaming it.
Basically this is what it does, following an if condition,
variables are set, and the subroutine is exited, in one line,
as a one-liner. I use it where I would have used 'Return',
so ... is it simply an Exit function in effect?

I suppose if you arrived at the subroutine via Gosub,
it would not go back, so there is a problem there,
however I almost never use Gosub so I didn't really think of it.

Code: Select all

;before
if ErrorLevel
{
oWB := ""
Return
}

;after
if ErrorLevel
oWB := "", CF_Return()

;what I'll probably do in future to take care of potential Gosubs
;since I learned about the '(1, ...)' 'hack', the need for a Return function has become far less pressing
if ErrorLevel
if (1, oWB := "")
Return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 2555
Joined: 09 Oct 2013, 10:31

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 08:14

why not just use AHK v2 and then you have all commands as functions BY DEFAULT?

User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 13:16

I'll seriously look into this, it might affect my function name choices, to make them consistent with AHK v2.
I think that I will remove various 'Not' versions of (commands as) functions as well.
Has AHK v2 done *all* the commands, or are there any missing?
Furthermore are there any differences between the AHK v2 commands as functions and the AHK v1 commands.
I have been thinking that I will add some AHK v2 functions for AHK v1 like DateAdd, DateDiff and DirExist for example,
and also at the bottom put some of my own core functions that I think should have been in AHK from day 1
like StrRept, StrCountOcc and Dec2Hex.

function: commands
FileExist: FileGetAttrib, IfExist/IfNotExist
GetKeyState: GetKeyState
InStr: IfInString, StringGetPos
SubStr: StringLeft/StringRight, StringMid, StringTrimLeft/StringTrimRight
StrLen: StringLen
StrReplace: StringReplace
StrSplit: StringSplit
WinActive: IfWinActive/IfWinNotActive
WinExist: IfWinExist/IfWinNotExist
While: While

==================================================

WARNINGS REGARDING AUTOHOTKEY V2

I believe that the primary reason behind AutoHotkey v2 is to tighten up the syntax.
But there is no reason why some of the new functionality, especially
relatively simple functions can't be added into AutoHotkey v1.
It will also help enormously with transition.

You could even add 'AutoHotkey v2' global variables to AutoHotkey v1, to do
the opposite of my wish list proposals:
An 'AutoHotkey v1' negative offset global variable which can turn the following off:
- A negative StartingPos for InStr, SubStr, RegExMatch and RegExReplace is interpreted as a position from the end, starting at 1. Position -1 is the right-most character (in v1 this was position 0), and position 0 is invalid.
An 'AutoHotkey v1' multi-statement global variable which can turn the following off:
- The result of a multi-statement expression such as x(), y() is the last (right-most) sub-expression instead of the first (left-most) sub-expression.
In fact I think these global variables/directives are ESSENTIAL.
(Note: I think the new AutoHotkey v2 behaviour is preferable to the AutoHotkey v1 behaviour.)

I must state that:
SOME OF THE CHANGES BEING PROPOSED IN AUTOHOTKEY V2
ARE DANGEROUS AND COULD DESTROY THE AUTOHOTKEY COMMUNITY.

It's so serious that I'll say it again.
SOME OF THE CHANGES BEING PROPOSED IN AUTOHOTKEY V2
ARE DANGEROUS AND COULD DESTROY THE AUTOHOTKEY COMMUNITY.

And again.
SOME OF THE CHANGES BEING PROPOSED IN AUTOHOTKEY V2
ARE DANGEROUS AND COULD DESTROY THE AUTOHOTKEY COMMUNITY.

I am actually in so much agreement about the bulk of, even all of the AutoHotkey v2 proposals,
but I think it's ESSENTIAL that updates occur to AutoHotkey v1
that smooth the transition.

Btw it is without question ESSENTIAL that we be able to do something like this in AutoHotkey v2:
vPath := vDir "\" vName
vPath := StrCmdStyle("%A_Desktop%\%vName%")

It is also without question ESSENTIAL that we be able to
create a continuation section where every character is WYSIWYG:
vList := ;continuation section
(Join`r`n verbatim
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
)

Thanks for reading.

SOME OF THE CHANGES BEING PROPOSED IN AUTOHOTKEY V2
ARE DANGEROUS AND COULD DESTROY THE AUTOHOTKEY COMMUNITY.
(I say this because I support AutoHotkey and AutoHotkey v2.)
(Note: my upcoming tutorials and putting style guides on each command page in the AutoHotkey v1 documentation,
will do more to make syntax use consistent, and do it in a kinder way
than forcing people to change via AutoHotkey v2, where many people will avoid it altogether,
and stick with AutoHotkey v1.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 2555
Joined: 09 Oct 2013, 10:31

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

16 Jan 2017, 22:50

lol you've been part of the "ahk community" for a month and you're already making claims about AHK v2 being "dangerous" and "destroying the community", yet you've cited no examples of why or how this my be the case.

and you missed the point of my last post: i think you shouldn't waste your time trying to optimize this library and make it compatible, i think its pointless and unnecessary since all of the wrapper functions are completely trivial. of course i'm biased, but your time would probably be better spent contributing to the v1 -> v2 script converter

AHK v1 needs to remain backward compatible

AHK v2 is intended for changes that BREAK compatibility

if you want AHK v1 to incorporate the same changes as AHK v2, then why even have a v2? why not just continue on with AHK v1.2 or whatever? and use your suggestion for global switches to change language features? your 'global switches' idea isn't a bad one, but i'm not sure how feasible it is. i MUCH prefer the suggestion to use global switches in v2 to make v2 backward compatible with v1, than vice versa that you have suggested here. but your proposal only includes 2 examples of functionality that you want global switches for. there are TONS of other changes in AHK v2 you haven't accounted for.

further, you aren't even aware of what AHK v2 is capable of. your StrCmdStyle() is redundant. AHK v2 already allows %derefs% inside of quoted strings.

you're just speaking off the cuff without any real knowledge of the situation

User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

17 Jan 2017, 02:12

guest3456 wrote:lol you've been part of the "ahk community" for a month
In a sense I've been part of the "ahk community" for much longer than that.
In a way better, I sorted all my problems out by myself and never asked any questions,
however of course I benefited immensely from other people's questions.
I joined the old forum but it shut down before I'd asked a question.
I've also written an immense amount of libraries, functions and scripts,
I'm trying to get them out as fast as possible.

The dangers of doing the transition badly, have given me my first negative feelings about AutoHotkey. That and the need for: GUI specify class name, GUI specify no icon, A_ThisHwnd, InputBox take HFONT, ToolTip take HFONT (there is a function for that but it crashes a lot).

Also I don't know where people want AutoHotkey to go, my concerns in my wish list addendum are:
- manipulate windows/controls (i.e. more control types) (e.g. Acc.ahk, UI Automation)
- manipulate webpages directly and/or support common go-between utilities (e.g. IE/Firefox/Chrome/Edge)
- manipulate Windows desktop/folder windows (e.g. XP/Vista/7/8/10)
guest3456 wrote:you're already making claims about AHK v2 being "dangerous" and "destroying the community", yet you've cited no examples of why or how this my be the case.
Do you need examples?
Don't you remember AutoIt/AHK, AHKB/AHKL, and the forum problems?

I've said that I fully support AutoHotkey v2 and its intent.
There could be things that it leads to in the future that I can't even imagine.
In short, if the compatibility bridge between v1 and v2 is too great,
both will die, because it will be too time-consuming to migrate scripts.
The more realistic it is that someone can reasonably convert *all* their scripts,
the more likely it is that AutoHotkey v1 and AutoHotkey v2 will thrive.

Btw arduous as it is I don't mind converting from command style to expression style, and I thought about proceeding without the 2 global variables I suggested,
but it doesn't bear thinking about. For now it's more sensible to think that AutoHotkey v2 doesn't exist, and accept that it's taking all the enthusiasm, time and resources away from AutoHotkey v1.
guest3456 wrote:and you missed the point of my last post: i think you shouldn't waste your time trying to optimize this library and make it compatible
They will be useful as I do a top-to-toe rewrite of all my scripts.
Writing them took less time than I thought. WHY didn't someone do it before I did.
guest3456 wrote:there are TONS of other changes in AHK v2 you haven't accounted for.
Can you name me which ones you think are the problems. So far I think that with the 2 proposals (global variables) I mentioned, I could feasibly convert all my scripts from AHK v1 to AHK v2. What changes are concerning you?

If I use expression style and functions for everything in AHK v1, will my scripts be mostly ready? I'm coincidentally rewriting all my scripts at the moment.

I don't mind not having Progress windows for example, however,
using GUI commands is not realistic because this makes scripts Persistent,
this is actually a massive issue for me, for various reasons, and has made my GUI functions project ESSENTIAL to me.
guest3456 wrote: further, you aren't even aware of what AHK v2 is capable of. your StrCmdStyle() is redundant. AHK v2 already allows %derefs% inside of quoted strings.
Did you mean this, it's not especially clear.
Deref
https://lexikos.github.io/v2/docs/commands/Deref.htm

I've read through a lot of the pages of the documentation, and very carefully,
in order to establish the extent of my transition woes.
The single quotes notation for example, solves a lot of my problems,
especially for scripts relating to html.
guest3456 wrote: you're just speaking off the cuff without any real knowledge of the situation
Hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha.

That's just the kind of language that is dangerous and could divide the community! (jk obvs)

Frankly I'm worried about all the things I'm going to have to ask Lexikos for, that's what it boils down to, so far 2 things. I HATE to make feature requests but I think they'll be for the good of AutoHotkey and AutoHotkey v2 which I absolutely want to see thrive. Is anybody else actually writing the source code for AHK v1/v2?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 2555
Joined: 09 Oct 2013, 10:31

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

17 Jan 2017, 10:58

jeeswg wrote: In short, if the compatibility bridge between v1 and v2 is too great,
both will die, because it will be too time-consuming to migrate scripts.
jeeswg wrote: They will be useful as I do a top-to-toe rewrite of all my scripts.
Writing them took less time than I thought. WHY didn't someone do it before I did.
jeeswg wrote:I'm coincidentally rewriting all my scripts at the moment.
you already had multiple users on stackoverflow tell you you were wrong about things, and instead you just blame their community. now you're doing the same here. there is one constant however: you.

you remain insistent, and then you completely contradict yourself

you are ALREADY REWRITING your scripts RIGHT NOW. so therefore there is NO COMPATIBILITY BRIDGE that you speak of.

if you are rewriting scripts, then you might as well just rewrite them for v2

this is the problem with your new v1 'global switch' suggestion. all of the existing scripts will NOT have used those switches. so all of those scripts will not benefit from them. so those won't be compatible either. unless, just like yourself they are REWRITTEN.

since you're using that time rewriting the scripts, you might as well do it the right way and just rewrite them so they are forward compatible with AHK v1 and v2, like i did with the Gdip.ahk library. why don't you do that for your beloved Acc library? that would be way more beneficial to the community than any of this other nonsense

jeeswg wrote: If I use expression style and functions for everything in AHK v1, will my scripts be mostly ready?
AHK v2 still allows command syntax. functions aren't required.

jeeswg wrote:
guest3456 wrote: you're just speaking off the cuff without any real knowledge of the situation
Hahahahahahahahahahahahahahahah (trimmed)
orly?

proof:
jeeswg wrote:
guest3456 wrote: further, you aren't even aware of what AHK v2 is capable of. your StrCmdStyle() is redundant. AHK v2 already allows %derefs% inside of quoted strings.
Did you mean this, it's not especially clear.
Deref
https://lexikos.github.io/v2/docs/commands/Deref.htm
no.

Code: Select all

vName := "hi"
MsgBox, % "%A_Desktop%\%vName%"
MsgBox("%A_Desktop%\%vName%")
you would do well to be less certain about things

User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

17 Jan 2017, 12:50

guest3456 wrote:you already had multiple users on stackoverflow tell you you were wrong about things
The main problem I get at Stack Overflow is that they in effect don't like how AutoHotkey does things.
I don't have the code to implement their suggestions.
They don't like if you use SendMessage, or any method that is no longer officially sanctioned.
And they said that you're 'lucky' if SendMessage ever works with any program.
Would you mind rewriting AutoHotkey without SendMessage?
For example what is a sanctioned way to send ctrl+shift+left to a window,
is it doable via the Acc library?
One user keeps telling me to use UI Automation, have we finished the UI Automation library yet?
Let's just assume we never finish it, out of interest, can you send ctrl+shift+left to a window by UI Automation?

Their mindset can be summed up by the following comment and tell me this isn't insane:
'Animation has never been a standard feature for GIF images. It's a non-standard extension, and an application that decides to support standard features only isn't broken.'
That exchange was from:
https://stackoverflow.com/questions/413 ... 7_41312249
Although yes I can agree with that point on technicalities.
They are basically grammar Nazis who come up with roundabout philosophical justifications
for failed software.

THEY are the reason I started AutoHotkey, because so much software doesn't work, because of THEIR mindset.
And now when I try to collect the information to fix things, THEY downvote me.
They are fixated and have an internal blue screen error when it comes to software writing.
Do come back at me with multiple things I've said there that you disagree with.

I made these points to them on one of my questions:
questions:
- If you want to challenge the question on philosophical grounds, or state that bug-like behaviours or 'features in name only' are 'by design', please remember that computers were invented as time-saving devices.
- If a programmer wants documented methods for published software, but uses undocumented methods personally in the meantime, something is better than nothing.
- Criticising someone for temporarily using undocumented methods, who is asking for documented methods, is nonsensical.
http://stackoverflow.com/questions/4131 ... s-versions

Frankly and honestly, the first winapi question I posted there, was attacked straightaway,
before I'd even said anything, I knew then the writing on the wall.
Btw one month ago I didn't know how bad the culture there was.
They ruined my life before, although it led to me learning AutoHotkey,
and they're ruining my life again, kind of.
guest3456 wrote:you are ALREADY REWRITING your scripts RIGHT NOW. so therefore there is NO COMPATIBILITY BRIDGE that you speak of.
Yes but that's just me, I mean, not the user 'just me', but me.
This is going to affect EVERYONE.

When I woke up today, after having calmly worked out that conversion for the most part should be doable.
I suddenly realised that all the scripts I *didn't* write would have to be updated to.

Basically with my 'v1 mode within v2' idea, that could very well mean I could have scripts
compatible with both versions, (as well as avoiding difficult conversions),
which would not be true any other way.
The supplementary idea, the 'v2 mode within v1' idea if it happened,
means that I could write all my code in v1, in the more logical v2 fashion,
and ensure that all my AHK v1 scripts could be more or less AHK v2 ready,
before the conversion and double-check stages,
there are enormous advantages to be had here.
guest3456 wrote:since you're using that time rewriting the scripts, you might as well do it the right way and just rewrite them so they are forward compatible with AHK v1 and v2
Yes, that's my intention, however I am not 100% sure I know what all the changes are/are going to be.
Could you point me to a link, that you think covers this as clearly and as extensively as possible.
It's this lack of communication, that risks creating the 'divide' notion I've been warning about.
Or the notion that I'm not a power user here or am new, so my concerns or scripts don't matter as much,
and yet my concerns may reflect those of 80% of the user base.
guest3456 wrote:why don't you do that for your beloved Acc library?
Hahahahahahaha. We mean so much to each other.
Tell me tab control on Firefox/Chrome isn't a must, that I recently provided!
I've posted on the forum, how it's been crashing/failing on certain software
like Windows 7 folder windows and the treeview on AutoHotkey's HTML Help.
I need some answers on this, before I would ever consider rewriting it.

You saw what happened when I wrote Commands As Functions.
Tonnes of correct criticisms. Perhaps its better if someone more expert
corrects Acc, although I will investigate it when I complete my GUI functions.
Plus Acc is shorter than other libraries, less than 200 lines.

Actually you know what, Acc has ****ing saved my life on many occasions,
it can't be praised enough, as has AccViewer, it should be FAR more
visible on the website, also no-one ever recommends it on Stack Overflow.
It blows the standard window spy, AU3_Spy.exe, out of the water.
guest3456 wrote:orly?
vName := "hi"
MsgBox, % "%A_Desktop%\%vName%"
MsgBox("%A_Desktop%\%vName%")
Hahahahaha. I like your coding style here.
In fairness the best guide to AHK changes that I've found is here:
v2-changes
https://autohotkey.com/v2/v2-changes.htm

But most unfortunately the variable changes were not clearly expressed
there unlike in your post here, which makes it very clear:
v1 -> v2 Script Converter - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=25100
MsgBox("The active window is %Title%.")
MsgBox("1+1=%1+1%")
Again communication is really important, regarding the
'divide' notion I mentioned earlier.

I would be grateful if you can show me a page in the documentation,
that clearly describes that particular change.
guest3456 wrote:your time would probably be better spent contributing to the v1 -> v2 script converter
[a comment you made in a previous post]
Btw I am going to experiment with some command to expression style
converting. I do this anyway to make code look more professional
for here and for Stack Overflow. But also for consistency.
My main advice would be to have various filters, e.g.
corrections for very simple lines, and then other ones
for lines that contain " and % already.
And also to leave a comment like ';[AHK2 checked]'
at the end of checked lines.
Also one thing I might write would be to grab certain unresolved lines
with their line numbers, edit them in Notepad,
and then put them back in.

thanks for being my guest

[EDIT: regarding AHK v1 to AHK v2]
If you have some before and after scripts, I can use them to help test my conversion methods.
Also if you have some example lines for most/all of the commands and functions, before and after versions, that would be most helpful, in order to support your projects.

[EDIT 2: AHK v1 style guide]
We need an approved AHK v1 style guide, that makes the code as compatible as
possible/completely compatible with AHK v2.

If there is any AHK v1 code, that can't be written in such a way that it is two-way compatible,
with AHK v1 and AHK v2, then that is the point at which we should consider either making additions to AHK v1
to make it forwards compatible, and/or changes to AHK v2 (e.g. directives/global variables) to make it backwards compatible.
So far I have only seen two areas where this would be necessary: 'SubStr negative' and 'multi-statement'. Please advise as to any others.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 2555
Joined: 09 Oct 2013, 10:31

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

17 Jan 2017, 23:44

you didn't even read my post. you just want to argue your side instead of listen to whats being told to you. i'm guessing thats why you were flamed out on stackoverflow too. i'm done. do whatever you want and waste your time on stuff that wont be used

User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

17 Jan 2017, 23:45

I was just pondering AFK, and then I suddenly had a dark realisation ...

I wouldn't be triumphalist too soon, regarding 'StrCmdStyle'.
You've just given me the *opposite* problem,
and what's more though I like that AutoHotkey v2 has incorporated
my idea without even asking me, it could pose a nightmare.
I said it should be doable, not necessarily the default.

Instead of a 'StrCmdStyle' function I'd need a 'StrPercentLiteral' function,
but presumably that would be impossible, no function
could handle the variables in its own way.

For example in AHK v1 I can do this:
vPath := StrResolvePath("C:\Users\%username%\Desktop\New Folder")
Where I replace the variables myself.
But presumably if I do this in AHK v2, it has already decided
that username is an empty variable before I can do anything with it,
and there would be no way around this.

Is there some acceptable workaround for this.
Escaping percent signs with backticks would not be an acceptable solution for example.
Plus there's the obvious disadvantage that you couldn't then just copy and paste
this into Explorer.
In short I need to be able to do:
vPath := MyFunctionName("C:\Users\%username%\Desktop\New Folder")
and get the same result in both AHK v1 and AHK v2.
And I don't care how ugly it looks behind the scenes as long as its doable.

At the moment I'm looking at backticking all my StrResolvePath entities,
but in terms of sheer ugliness that's a fate worse than death.
I could avoid the SubStr negative problem by creating SubStrEx,
that works differently depending on the version, and replace all instances
of SubStr in the script. Although there may be other complications.
And I could copy the first parameter as the last parameter EVERY time,
I use a multi-statement, but this would be ghastly, and could take
man-months.

You can see how even though I support all of the AHK v2 changes,
without a bit of assistance from on high I don't even want to contemplate
conversion. And I hate asking for assistance.

Btw did anyone ever think of going back to AutoHotkey Basic and adding in Ptr/UPtr,
A_PtrSize and ahk_exe. This is a case of where the creators of AutoHotkey
can fix a problem once and for all, or the users fanny about with it
for the rest of time.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 6488
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

18 Jan 2017, 01:30

Is anybody else actually writing the source code for AHK v1/v2?
Is anybody? You can see the activity, or lack-of-activity, on GitHub.
https://github.com/Lexikos/AutoHotkey_L ... ntributors
But most unfortunately the variable changes were not clearly expressed there
It's covered explicitly, with an example, in the first paragraph under "Expressions". What's not clear?
I would be grateful if you can show me a page in the documentation, that clearly describes that particular change.
The (incomplete) v2 documentation intentionally doesn't cover changes, only what a new user would need to know.

However, there is a fairly obvious example under "Retrieving the contents of variables".
http://lexikos.github.io/v2/docs/Variables.htm
So far I have only seen two areas where this would be necessary: 'SubStr negative' and 'multi-statement'.
Neither one is necessary as both features are redundant. I have always found it sufficient to simply avoid using either feature.
Escaping percent signs with backticks would not be an acceptable solution for example.
It's always been acceptable for commands...

`% represents a literal % in both versions, even in quoted strings.
Btw did anyone ever think of going back to AutoHotkey Basic and adding in Ptr/UPtr, A_PtrSize and ahk_exe.
Clearly at least one person did. (You.)

Then you'd simply have a new fork with those features. The original version by Chris still wouldn't support them. Only the original version supports the /NoDecompile switch, for which the source code appears to have been withheld.
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

18 Jan 2017, 02:27

I'm extremely grateful to both of you for considering/observing my feature ideas, that's as much as I can do, state them and advocate for them, I will be collecting concerns and ideas for AHK v2 on a page at my website shortly to express things in the clearest and best way possible for anyone interested, as well as code, tutorials etc. Thanks once again to both of you.
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: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Commands As Functions (Titan's/polyethene's Functions.ahk update)

08 Mar 2017, 21:11

Re. ByRef variables.
lexikos wrote:Whenever there is an "InputVar" parameter, there is really no reason to use ByRef. However, it usually does no harm.
I'm planning to remove instances of ByRef. However, isn't ByRef usually preferable, or at least for certain text functions/commands? E.g you avoid duplicating a 200MB variable (100MB of text) when you put it into a function, or send it out from a function.

Functions
https://autohotkey.com/docs/Functions.htm
When passing large strings to a function, ByRef enhances performance and conserves memory by avoiding the need to make a copy of the string. Similarly, using ByRef to send a long string back to the caller usually performs better than something like Return HugeString.
Btw do function equivalents of commands (e.g. AHK v2) perform as well as the commands, and do they use certain 'smart' checks to avoid string duplication where possible. I thought that perhaps they might use ByRef.

Some of these concerns lie behind my question:
best way to truncate string - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 6&p=122405

==================================================

Re. Exit.

As a beginner it surprised me that the MsgBox could be reached in this example:

Code: Select all

Sleep 3000
Reload
MsgBox % "hey"
Putting in a Return, after Reload, solves the problem. Return/Exit/ExitApp seem to be safe, and the MsgBox line is not reached.
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 “Scripts and Functions”

Who is online

Users browsing this forum: Google [Bot], robodesign and 58 guests