ClickSendSleepControl() & MinifyClickSendSleep()

Post your working scripts, libraries and tools for AHK v1.1 and older
CyL0N
Posts: 211
Joined: 27 Sep 2018, 09:58

ClickSendSleepControl() & MinifyClickSendSleep()

06 Dec 2018, 23:08

Unified Click,Send,Sleep & ControlClick by means of ControlClickByControlText().

NOTE:The Only Caveat is that commands must be separated by two spaces FROM EACHOTHER,so that single space can be used normally as part of the other commands...s{Up 5} for example.


Those functionalities are reduced to prefixes as follows:

  • s to send input
    _s to send play - more reliable for games.
    r to send raw input
    c to click based on params to which it's appended
    _c to click on a control given it's ControlText AND/OR ClassNN AND/OR WinTitle

    Sleep doesn't require a prefix,any integer unbounded to any prefix is an implicit sleep command...
Function is meant to be passed multiple parameters,so that it's exception handler proves more useful but also ,BUT MAINLY for ease of readability...


Basic Usage Is something like this:

Code: Select all

ClickSendSleepControl("s;hello  500  r!  200  s{Backspace 7}  500  _cSomeNonExistentButtonAroundHere  Intentional Error Ignore Me!  cLeft")
ClickSendSleepControl.ahk <Function

Code: Select all

;===========================================================================================================================
;NOTE: ALL COMMANDS MUST BE DOUBLE,YES,    DOUBLE SPACE    DELIMITED to allow space to be used normally for other things like:
;.... 's{Ctrl down}' or 'sHello world,how you been'
;commands are executed in the order of params & in the order spefied in individual params..
;===========================================================================================================================
/*
	Usage: Add the prefixes specified below to any string separated by TWO SPACES from prior string,
	ex.
	WRONG: "sEcho r!"
	RIGHT: "sEcho  r!"
	
	PREFIX KEYWORDS:
	c	;click
	_c	;control click, clicks on any existing control matching controlText AND/OR controlClassNN AND/OR windowTitle
	s	;send input
	r	;send raw input,for inputs like '!' or '+' which are otherwise mapped to modifiers
	
	ANY Integer separated by DOUBLE SPACES from either side is considered a sleep command.
	
	---->Function Has Accurate Exception Handling for Debugging, to identify in which param,in which string & in which command was improperly defined...
*/

ClickSendSleepControl(params*){
	for index,param in params
		for i,cmd in StrSplit(param,"  ")
			signifier := SubStr(cmd,1,1),thisCmd := SubStr(cmd,2,StrLen(cmd))
			,( signifier = "c" ? Click(thisCmd )
					: signifier = "s" ? Send(thisCmd)
					: signifier = "r" ? SendRaw(thisCmd)
					: SubStr(cmd,1,2) = "_s" ? SendPlay(LTrim(cmd,"_s"))
					: SubStr(cmd,1,2) = "_c" ? (cssc := StrSplit(SubStr(cmd,3,StrLen(cmd)),",")) & ControlClickByControlText(cssc .1,cssc .2,cssc .3,cssc .4)
					: IsInt(cmd) ? Sleep(cmd) : MsgBox("Uknown Command: `n==================`nparam:	" param "`n==================`ncmd:	" cmd  "`n`nparam:	" index, A_ScriptName,"0x40010") )
}
Click(Params*){
	local i, Param, Args
	for i, Param in Params
		Args .= " " . Param
	Click % Args
}
Send(Keys){
	SendInput % Keys
}
SendPlay(Keys){
	SendPlay % Keys
}
SendRaw(Keys){
	SendRaw % Keys
}
Sleep(Time){
	Sleep % time
}

IsInt(string){
	If string is integer
		Return True
}

;NOTE: if any text in control is underlined that letter must be prefixed by '&' as in the first example above...
ControlClickByControlText(searchStr, controlName:="", winTitle:="",passes:=1){	;loops through all visible windows and clicks on any window with a control that contains a matching string.}
	BL := A_BatchLines
	SetBatchLines, -1
	Loop % passes ? passes : 1 {	;the more passes the more reliable it is,though rarely necessary to go beyond 2
		WinGet, id, list
		Loop, %id%{
			this_id := id%A_Index%
			WinGet, thisControlList, ControlList, ahk_id %this_id%
			WinGetTitle, thisTitle, ahk_id %this_id%
			If thisControlList{
				Loop, Parse, thisControlList, `n
				{
					Try ControlGetText, thisControlText, %A_LoopField%, ahk_id %this_id%
						If !winTitle
							( thisControlText = searchStr AND !controlName AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : (thisControlText = searchStr AND controlName = A_LoopField AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : "" ) )
					Else
						( thisControlText = searchStr AND !controlName AND winTitle = thisTitle AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : (thisControlText = searchStr AND controlName = A_LoopField AND winTitle = thisTitle AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : "" ) )
				}
			}
		}
	}
	SetBatchLines, % BL
}

ControlClick(ControlOrPos:="", WinTitle:="", WinText:="", WhichButton:="", ClickCount:="", Options:="", ExcludeTitle:="", ExcludeText:=""){
	ControlClick, % ControlOrPos, % WinTitle, % WinText, % WhichButton, % ClickCount, % Options, % ExcludeTitle, % ExcludeText
}

ControlGetText(Control:="", WinTitle:="", WinText:="", ExcludeTitle:="", ExcludeText:=""){
	Try ControlGetText, controlText, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
		Return controlText
}

;MsgBox("Error", A_ScriptName,"0x40010")
;MsgBox("Question", A_ScriptName, "0x40020")
;MsgBox("Warning", A_ScriptName, "0x40030")
;MsgBox("Info", A_ScriptName, "0x40040")
MsgBox(Text:="", Title:="", Options:="0x40040", TimeOut:=""){	;default is info
	MsgBox, % Options, % Title, % Text, % TimeOut
	IfMsgBox, Yes
		Return Text
	IfMsgBox, Ok
		Return Text
}




;Examples
ClickSendSleepControl Demo.ahk

Code: Select all

;===========================================================================================================================
;NOTE: ALL COMMANDS MUST BE DOUBLE,YES,    DOUBLE SPACE    DELIMITED to allow space to be used normally for other things like:
;.... 's{Ctrl down}' or 'sHello world,how you been'
;commands are executed in the order of params & in the order spefied in individual params..
;===========================================================================================================================
/*
	Usage: Add the prefixes specified below to any string separated by TWO SPACES from prior string,
	ex.
	WRONG: "sEcho r!"
	RIGHT: "sEcho  r!"
	
	PREFIX KEYWORDS:
	c	;click
	_c	;control click, clicks on any existing control matching controlText AND/OR controlClassNN AND/OR windowTitle
	s	;send input
	r	;send raw input,for inputs like '!' or '+' which are otherwise mapped to modifiers
	
	ANY Integer separated by DOUBLE SPACES from either side is considered a sleep command.
	
	---->Function Has Accurate Exception Handling for Debugging, to identify in which param,in which string & in which command was improperly defined...
*/

;Example 1 - Debugging & exception handling
MsgBox("NOTE: There Are Some Intentional Errors In This Example!")
ClickSendSleepControl("asdasda  100"
,"s;hello  500  r!  200  s{Backspace 7}  _cSomeButtonAroundHere  Intentional Error Ignore Me!  cLeft")

;Example 2
CoordMode, Mouse, Screen
Run, Notepad
WinWait, ahk_exe Notepad.exe ahk_exe Notepad2.exe
ExecScript("MsgBox, 0x40040, %A_ScriptName%, test started:Script should terminate this message box itself`nSleep 6000",false)
WinMove, 0, 0
WinActivate, ahk_exe Notepad.exe ahk_exe Notepad2.exe

ClickSendSleepControl("sHello world,how you been.  c500,500,Right  200  c400,500,Left  s{shift down}  400  s{down 5}  1000  s{shift up}{up 5}"
, "600  s{Ctrl down}{End}{Ctrl up}{Enter}  200  sWell I've got really nothing more to say,so...{Enter}  1000  sByeee  r!  3000  _cOk  _c&Ok"
, "s{Alt down}{F4}{Alt up}  1000  sn  _cNo,button2,,2  _c&No,button2,,2")

TrayTip, ClickSendSleepControl, Test Complete!
Sleep 1000
ExitApp


ClickSendSleepControl(params*){
	for index,param in params
		for i,cmd in StrSplit(param,"  ")
			signifier := SubStr(cmd,1,1),thisCmd := SubStr(cmd,2,StrLen(cmd))
			,( signifier = "c" ? Click(thisCmd )
					: signifier = "s" ? Send(thisCmd)
					: signifier = "r" ? SendRaw(thisCmd)
					: SubStr(cmd,1,2) = "_s" ? SendPlay(LTrim(cmd,"_s"))
					: SubStr(cmd,1,2) = "_c" ? (cssc := StrSplit(SubStr(cmd,3,StrLen(cmd)),",")) & ControlClickByControlText(cssc .1,cssc .2,cssc .3,cssc .4)
					: IsInt(cmd) ? Sleep(cmd) : MsgBox("Uknown Command: `n==================`nparam:	" param "`n==================`ncmd:	" cmd  "`n`nparam:	" index, A_ScriptName,"0x40010") )
}
Click(Params*){
	local i, Param, Args
	for i, Param in Params
		Args .= " " . Param
	Click % Args
}
Send(Keys){
	SendInput % Keys
}
SendPlay(Keys){
	SendPlay % Keys
}
SendRaw(Keys){
	SendRaw % Keys
}
Sleep(Time){
	Sleep % time
}

IsInt(string){
	If string is integer
		Return True
}

;NOTE: if any text in control is underlined that letter must be prefixed by '&' as in the first example above...
ControlClickByControlText(searchStr, controlName:="", winTitle:="",passes:=1){	;loops through all visible windows and clicks on any window with a control that contains a matching string.}
	BL := A_BatchLines
	SetBatchLines, -1
	Loop % passes ? passes : 1 {	;the more passes the more reliable it is,though rarely necessary to go beyond 2
		WinGet, id, list
		Loop, %id%{
			this_id := id%A_Index%
			WinGet, thisControlList, ControlList, ahk_id %this_id%
			WinGetTitle, thisTitle, ahk_id %this_id%
			If thisControlList{
				Loop, Parse, thisControlList, `n
				{
					Try ControlGetText, thisControlText, %A_LoopField%, ahk_id %this_id%
						If !winTitle
							( thisControlText = searchStr AND !controlName AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : (thisControlText = searchStr AND controlName = A_LoopField AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : "" ) )
					Else
						( thisControlText = searchStr AND !controlName AND winTitle = thisTitle AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : (thisControlText = searchStr AND controlName = A_LoopField AND winTitle = thisTitle AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : "" ) )
				}
			}
		}
	}
	SetBatchLines, % BL
}

ControlClick(ControlOrPos:="", WinTitle:="", WinText:="", WhichButton:="", ClickCount:="", Options:="", ExcludeTitle:="", ExcludeText:=""){
	ControlClick, % ControlOrPos, % WinTitle, % WinText, % WhichButton, % ClickCount, % Options, % ExcludeTitle, % ExcludeText
}

ControlGetText(Control:="", WinTitle:="", WinText:="", ExcludeTitle:="", ExcludeText:=""){
	Try ControlGetText, controlText, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
		Return controlText
}

;MsgBox("Error", A_ScriptName,"0x40010")
;MsgBox("Question", A_ScriptName, "0x40020")
;MsgBox("Warning", A_ScriptName, "0x40030")
;MsgBox("Info", A_ScriptName, "0x40040")
MsgBox(Text:="", Title:="", Options:="0x40040", TimeOut:=""){	;default is info
	MsgBox, % Options, % Title, % Text, % TimeOut
	IfMsgBox, Yes
		Return Text
	IfMsgBox, Ok
		Return Text
}










;MISC FUNCTIONS FOR EXAMPLES....

; ExecScript: Executes the given code as a new AutoHotkey process.
ExecScript(Script, Wait:=true)
{
	shell := ComObjCreate("WScript.Shell")
	exec := shell.Exec("AutoHotkey.exe /ErrorStdOut *")
	exec.StdIn.Write(script)
	exec.StdIn.Close()
	if Wait
		return exec.StdOut.ReadAll()
}



WrapText(Text, LineLength) {
	StringReplace, Text, Text, `r`n, % A_Space, All
	while (p := RegExMatch(Text, "(.{1," LineLength "})(\s|\R+|$)", Match, p ? p + StrLen(Match) : 1))
		Result .= Match1 ((Match2 = A_Space || Match2 = A_Tab) ? "`n" : Match2)
	return, Result
}


Put(string){		;as an alternative to send,to instantly place a string
	ClipSaved := ClipboardAll
	clipboard := ""
	clipboard := string
	clipwait
	BlockInput, on
	Send ^v
	BlockInput, off
	Clipboard := ClipSaved
}

Get(whichSideOfCaret:=""){		;gets everything to left or right of cursor, if none gets selection(ctrl+c)	---> set param to 'L' or 'R'
	ClipSaved := ClipboardAll, clipboard := ""
	BlockInput, on
	( whichSideOfCaret = "R" ? Send("{Shift down}{end}{Shift up}{Ctrl down}{c}{Ctrl up}{Left}") : (whichSideOfCaret = "L" ? Send("{Shift down}{home}{Shift up}{Ctrl down}{c}{Ctrl up}{Right}") : (!whichSideOfCaret ? Send("{Ctrl down}{c}{Ctrl up}") : "")) )	
	BlockInput, off
	clipwait, 2	;timeout in 2sec
	string := clipboard, Clipboard := ClipSaved
	Return string
}




MinifyClickSendSleep.ahk
Select code as in the example with a sequence of Click's & Send's, then press F2... to test it out....

Code: Select all

;Make Sure nothing other than Click,Send,Sleep are selected...
F2::Put(MinifyClickSendSleep(Get(),125))	;Minify selected code to 125 char max width


MinifyClickSendSleep(code,lineLength:=125){
For i,line in  StrSplit(ClickSendSleepControlTranspose(code,lineLength), "`n")
	( i = 1 ? (minified := "ClickSendSleepControl(" . """" Trim(line)  """") : (minified .= "`n`t,""" Trim(line)  """") )
Return minified . ")"
}

ClickSendSleepControlTranspose(code,maxLineLength:=""){
	For k,line in StrSplit(StrReplace(StrSplit(code,";")[1],"`r"), "`n"){
		line := Trim(line)
		If InStr(line,"Sleep"){
			cssct .= " " StringTrim(StringTrim(line,"Sleep"),",") " " 
		}Else If InStr(line,"SendPlay"){
			cssct .=  " _s" StringTrim(StringTrim(line,"SendPlay"),",") " " 
		}Else If InStr(line,"Send"){
			cssct .=  " s" StringTrim(StringTrim(line,"Send"),",") " " 
		}Else If InStr(line,"Click"){
			cssct .=  " c" StringTrim(StringTrim(line,"Click"),",") " " 
		}
		cssct .= maxLineLength ? (StrLen(RegExReplace(cssct, ".*`n(.*)", "$1")) > maxLineLength ? "`n" : "") : ""	;regex retrieves last line to...
	}
	return cssct
}

;omitNumberOfChar allows specifying number of char to trim instead of string to trim...
StringTrim(string:="", omitStrLeft:="", omitStrRight:="", omitNumberOfChar:=false, caseSense:=false,trimByChar:=false){
	stringInverse :=_strFlip(string) , omitStrRight := omitStrRight ? _strFlip(omitStrRight) : ""
	If (trimByChar && omitStrRight)
		For i,c in StrSplit(stringInverse)
			( c==SubStr(omitStrRight,i,1) && !mismatchR ? "" : (mismatchR:=true) & (trimstr.=c) )
	If ( omitNumberOfChar || omitStrLeft AND !caseSense AND SubStr(String, 1, StrLen(omitStrLeft)) = omitStrLeft || omitStrLeft AND caseSense AND SubStr(String, 1, StrLen(omitStrLeft)) == omitStrLeft )
		If trimByChar
			For i,c in StrSplit(trimstr ? _strFlip(trimstr)t : string)
				( c==SubStr(omitStrLeft,i,1) && !mismatchL ? "" : (mismatchL:=true) & (trimstrL.=c) )
		Else, StringTrimLeft, string, string, % !omitNumberOfChar ? StrLen(omitStrLeft) : omitStrLeft
	If ( omitNumberOfChar || omitStrRight AND !caseSense AND SubStr(String, StrLen(String)-StrLen(omitStrRight)+1, StrLen(string)) = omitStrRight || omitStrRight AND caseSense AND SubStr(String, StrLen(String)-StrLen(omitStrRight)+1, StrLen(string)) == omitStrRight )
		StringTrimRight, string, string, % !omitNumberOfChar ? StrLen(omitStrRight) : omitStrRight

	Return Trim(trimByChar ? trimstrL?trimstrL:_strFlip(trimstr) : string)
}
; https://msdn.microsoft.com/en-us/library/9hby7w40.aspx
_strFlip(str){
	Return % DllCall("msvcrt.dll\_wcsrev", "UPtr", &str, "CDecl str")
}

ClickSendSleepControl(params*){
	for index,param in params
		for i,cmd in StrSplit(param,"  ")
			signifier := SubStr(cmd,1,1),thisCmd := SubStr(cmd,2,StrLen(cmd))
			,( signifier = "c" ? Click(thisCmd )
					: signifier = "s" ? Send(thisCmd)
					: signifier = "r" ? SendRaw(thisCmd)
					: SubStr(cmd,1,2) = "_s" ? SendPlay(LTrim(cmd,"_s"))
					: SubStr(cmd,1,2) = "_c" ? (cssc := StrSplit(SubStr(cmd,3,StrLen(cmd)),",")) & ControlClickByControlText(cssc .1,cssc .2,cssc .3,cssc .4)
					: IsInt(cmd) ? Sleep(cmd) : MsgBox("Uknown Command: `n==================`nparam:	" param "`n==================`ncmd:	" cmd  "`n`nparam:	" index, A_ScriptName,"0x40010") )
}
Click(Params*){
	local i, Param, Args
	for i, Param in Params
		Args .= " " . Param
	Click % Args
}
Send(Keys){
	SendInput % Keys
}
SendPlay(Keys){
	SendPlay % Keys
}
SendRaw(Keys){
	SendRaw % Keys
}
Sleep(Time){
	Sleep % time
}

IsInt(string){
	If string is integer
		Return True
}

;NOTE: if any text in control is underlined that letter must be prefixed by '&' as in the first example above...
ControlClickByControlText(searchStr, controlName:="", winTitle:="",passes:=1){	;loops through all visible windows and clicks on any window with a control that contains a matching string.}
	BL := A_BatchLines
	SetBatchLines, -1
	Loop % passes ? passes : 1 {	;the more passes the more reliable it is,though rarely necessary to go beyond 2
		WinGet, id, list
		Loop, %id%{
			this_id := id%A_Index%
			WinGet, thisControlList, ControlList, ahk_id %this_id%
			WinGetTitle, thisTitle, ahk_id %this_id%
			If thisControlList{
				Loop, Parse, thisControlList, `n
				{
					Try ControlGetText, thisControlText, %A_LoopField%, ahk_id %this_id%
						If !winTitle
							( thisControlText = searchStr AND !controlName AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : (thisControlText = searchStr AND controlName = A_LoopField AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : "" ) )
					Else
						( thisControlText = searchStr AND !controlName AND winTitle = thisTitle AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : (thisControlText = searchStr AND controlName = A_LoopField AND winTitle = thisTitle AND WinExist("ahk_id " . this_id) ? ControlClick(A_LoopField, "ahk_id " this_id) : "" ) )
				}
			}
		}
	}
	SetBatchLines, % BL
}

ControlClick(ControlOrPos:="", WinTitle:="", WinText:="", WhichButton:="", ClickCount:="", Options:="", ExcludeTitle:="", ExcludeText:=""){
	ControlClick, % ControlOrPos, % WinTitle, % WinText, % WhichButton, % ClickCount, % Options, % ExcludeTitle, % ExcludeText
}

ControlGetText(Control:="", WinTitle:="", WinText:="", ExcludeTitle:="", ExcludeText:=""){
	Try ControlGetText, controlText, % Control, % WinTitle, % WinText, % ExcludeTitle, % ExcludeText
		Return controlText
}

;MsgBox("Error", A_ScriptName,"0x40010")
;MsgBox("Question", A_ScriptName, "0x40020")
;MsgBox("Warning", A_ScriptName, "0x40030")
;MsgBox("Info", A_ScriptName, "0x40040")
MsgBox(Text:="", Title:="", Options:="0x40040", TimeOut:=""){	;default is info
	MsgBox, % Options, % Title, % Text, % TimeOut
	IfMsgBox, Yes
		Return Text
	IfMsgBox, Ok
		Return Text
}










;MISC FUNCTIONS FOR EXAMPLES....

; ExecScript: Executes the given code as a new AutoHotkey process.
ExecScript(Script, Wait:=true)
{
	shell := ComObjCreate("WScript.Shell")
	exec := shell.Exec("AutoHotkey.exe /ErrorStdOut *")
	exec.StdIn.Write(script)
	exec.StdIn.Close()
	if Wait
		return exec.StdOut.ReadAll()
}



WrapText(Text, LineLength) {
	StringReplace, Text, Text, `r`n, % A_Space, All
	while (p := RegExMatch(Text, "(.{1," LineLength "})(\s|\R+|$)", Match, p ? p + StrLen(Match) : 1))
		Result .= Match1 ((Match2 = A_Space || Match2 = A_Tab) ? "`n" : Match2)
	return, Result
}


Put(string){		;as an alternative to send,to instantly place a string
	ClipSaved := ClipboardAll
	clipboard := ""
	clipboard := string
	clipwait
	BlockInput, on
	Send ^v
	BlockInput, off
	Clipboard := ClipSaved
}

Get(whichSideOfCaret:=""){		;gets everything to left or right of cursor, if none gets selection(ctrl+c)	---> set param to 'L' or 'R'
	ClipSaved := ClipboardAll, clipboard := ""
	BlockInput, on
	( whichSideOfCaret = "R" ? Send("{Shift down}{end}{Shift up}{Ctrl down}{c}{Ctrl up}{Left}") : (whichSideOfCaret = "L" ? Send("{Shift down}{home}{Shift up}{Ctrl down}{c}{Ctrl up}{Right}") : (!whichSideOfCaret ? Send("{Ctrl down}{c}{Ctrl up}") : "")) )	
	BlockInput, off
	clipwait, 2	;timeout in 2sec
	string := clipboard, Clipboard := ClipSaved
	Return string
}

I've found too many scripts on the forums over the years that were written as in the script below and such scripts are ofcourse almost exclusively confined to AskForHelp & Gaming subforums because it's the best way to make the most out of Ahk knowing the least about it,i figure at the very least this function makes it easier to understand scripts like these by minifying them...decluttering really... And At most i hope it makes it easier to use these features for new users,without making their scripts unreadable at the eventual AskForHelp post...


Code: Select all

Sleep, 200
Click, 1024, 581, 0
Sleep, 200
Click, 1024, 581 Left, Down
Sleep, 93
Click, 1024, 581 Left, Up
Sleep, 300
Send, +fox
Sleep, 150
Send, {Enter}
Sleep, 300
Click, 795, 249, 0
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +sigr
Sleep, 150
Send, {Enter}
Sleep, 300
Click, 795, 249, 0
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +gangs
Sleep, 150
Send, {Enter}
Sleep, 300
Click, 795, 249, 0
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +thief
Sleep, 150
Send, {Enter}
Sleep, 300
Click, 795, 249, 0
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +boots{Space}+of{Space}+gloom
Sleep, 150
Send, {Enter}
Sleep, 300
Click, 795, 249, 0
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +hero
Sleep, 150
Send, {Enter}
Sleep, 300
Click, 795, 249, 0
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +thief{Space}+dagger
Sleep, 100
Send, {Enter}
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 94
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +body{Space}+enhanc
Sleep, 100
Send, {Enter}
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 125
Click, 795, 249 Right, Up
Sleep, 998
Click, 795, 249 Right, Down
Sleep, 141
Click, 795, 249 Right, Up
Sleep, 936
Click, 795, 249 Right, Down
Sleep, 140
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +crim
Sleep, 100
Send, {Enter}
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 125
Click, 795, 249 Right, Up
Sleep, 998
Click, 795, 249 Right, Down
Sleep, 141
Click, 795, 249 Right, Up
Sleep, 200
Send, {LAlt Up}
Sleep, 300
Send, +excellent
Sleep, 100
Send, {Enter}
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 78
Click, 795, 249 Right, Up
Sleep, 200
send, {LAlt Up}
Sleep, 300
Send, +harpy{Space}+egg
Sleep, 100
Send, {Enter}
Sleep, 200
Send, {LAlt Down}
Sleep, 200
Click, 795, 249 Right, Down
Sleep, 78
Click, 795, 249 Right, Up
Sleep, 200
send, {LAlt Up}
Sleep, 300
Send, !e
Sleep, 200
Becomes:
-->Snippet from this script: https://autohotkey.com/boards/viewtopic ... 0&p=250085#

Code: Select all

;The Above Minified...
ClickSendSleepControl("200  c1024, 581, 0  200  c1024, 581 Left, Down  93  c1024, 581 Left, Up  300  s+fox  150  s{Enter}  300  c795, 249, 0  200  s{LAlt Down}"
	,"200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+sigr  150  s{Enter}  300  c795, 249, 0  200  s{LAlt Down}"
	,"200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+gangs  150  s{Enter}  300  c795, 249, 0  200  s{LAlt Down}"
	,"200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+thief  150  s{Enter}  300  c795, 249, 0  200  s{LAlt Down}"
	,"200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+boots{Space}+of{Space}+gloom  150  s{Enter}  300"
	,"c795, 249, 0  200  s{LAlt Down}  200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+hero  150  s{Enter}"
	,"300  c795, 249, 0  200  s{LAlt Down}  200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+thief{Space}+dagger"
	,"100  s{Enter}  200  s{LAlt Down}  200  c795, 249 Right, Down  94  c795, 249 Right, Up  200  s{LAlt Up}  300  s+body{Space}+enhanc"
	,"100  s{Enter}  200  s{LAlt Down}  200  c795, 249 Right, Down  125  c795, 249 Right, Up  998  c795, 249 Right, Down  141  c795, 249 Right, Up"
	,"936  c795, 249 Right, Down  140  c795, 249 Right, Up  200  s{LAlt Up}  300  s+crim  100  s{Enter}  200  s{LAlt Down}  200  c795, 249 Right, Down"
	,"125  c795, 249 Right, Up  998  c795, 249 Right, Down  141  c795, 249 Right, Up  200  s{LAlt Up}  300  s+excellent  100  s{Enter}"
	,"200  s{LAlt Down}  200  c795, 249 Right, Down  78  c795, 249 Right, Up  200  s{LAlt Up}  300  s+harpy{Space}+egg  100  s{Enter}"
	,"200  s{LAlt Down}  200  c795, 249 Right, Down  78  c795, 249 Right, Up  200  s{LAlt Up}  300  s!e  200")

I Understand that to some, it might seem less readable, it infact is it's more readable, because when Minified it provides the bigger picture with little obfuscation,imagine doing a puzzle with all the pieces in different rooms as opposed to all of them infront of you,which is easier to work with?.

I'm just posting it to give people an option to better using these prolific commands,it's more readable(matter*of*opinion) but it's also MUCH EASIER to work with & More Robust/Durable...

Cheers...
live ? long & prosper : regards

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Gio710 and 145 guests