InGame v2.0

Post gaming related scripts
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

NumpadDot-To-Dot

21 Jun 2017, 09:57

When multilingual keyboards in many cases need to remap NumpadDot to Dot.
For Example In Bulgarian keyboard layout NumpadDot is coded like , (coma) - it is STANDARD but all need . (dot) there.

There many programs that remap keys like KeyTweak and Sharp Keys but all works perfect only in US keyboard layout (and last Windows 10 ignored in other layouts).

Problems:
1. When totally remap NumpadDot (scan code) - we lose DEL functionality.
2. When remap NumpaDot to Dot - worked only in US layout.

Example that I find in internet

Code: Select all

NumpadDel::Send .
represent problem 1 and 2.
In first I modify to

Code: Select all

NumpadDot::Send .
that work perfect and with last Windows 10.

Of course there short code

Code: Select all

NumpadDot::.
It remap button only when NUMPAD is active and work in nonUS keyboard layouts.
Tested on US, Bulgarian - BDS and Bulgarian - Phonetic.

Make NumpadDot-To-Dot.ahk

Code: Select all

#SingleInstance, Force
;Copyright (c) D.Donchev

NumpadDot::.
Rename copy of AutohotkeyU64.exe (for 64Bit OS) or AutohotkeyU32.exe (for 32bit OS) to NumpadDot-To-Dot.exe
Put this 2 files together in some place and set Windows to start NumpadDot-To-Dot.exe at the begining.

So AHK the best choice ever!
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

TypeOf(this)

27 Aug 2017, 07:27

AutoHotkey_2.0-a081-cad307c
Function TypeOf(this) edited ultra compact

Code: Select all

typeOf(this) {
	__type:= __name:= type(this)
	if isObject(this) {
		__type:= "Object"
		try if this.__Class && __name != (__type := "Class")
				throw
		catch 
			return __type "|" __name 
	} 
	return __type
}
Examples: https://autohotkey.com/boards/viewtopic ... 73#p167373
Last edited by _3D_ on 28 Aug 2017, 23:41, edited 1 time in total.
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Gdip+ AutoHotkey_2.0-a081-cad307c

28 Aug 2017, 08:14

AutoHotkey_2.0-a081-cad307c
Correct syntax
  • if expression, expression
    sysget
    sysget Monitor
    loop,
Attachments
Gdip-AHKv2.0-a081-cad307c.zip
(18.95 KiB) Downloaded 355 times
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

DEREF back to AutoHotkey_2.0-a081-cad307c

01 Sep 2017, 00:19

AutoHotkey_2.0-a081-cad307c
Back deref to v2.0 - partial solution - next code replace variables with variables values.

Code: Select all

__deref_Expression:= "" ; <<< expression string
__deref_LABEL: ; deref ---------------------------------- AutoHotkey_2.0-a081-cad307c
	if RegExMatch(__deref_Expression, "i)[%][a-z_]\w*[%]", __deref_Variable) {
		__deref_Expression:= RegExReplace(__deref_Expression
										, "i)" __deref_Variable.Value
										, %subStr(__deref_Variable.Value, 2, -1)% "")
		goto __deref_LABEL
} ; ---------------------------------------------------------------------------------
This code work exactly as removed deref() function:
1. Code recognize only enclosed in %% names and replace with values ("%variable%")
2. Code must be stored at the place where variables must be deref. (Due to variable scope function impossible).
3. Code just replace variable names with there values - no EVALUATION.
4. Loop is implemented as LABEL \ goto LABEL to be visible A_Index and A_Loop... variables

EVALUATION by tidbit

Code: Select all

dd_tidbitEval(expression) { ; 
	obj:=ComObjCreate("HTMLfile")  ;tidbit code -------------------------------------------
	obj.write("<body><script>document.body.innerText=eval('" expression "');</script>") ;--
	return obj.body.innerText
}
Functions not allowed (it is HTML evaluation). I can`t experiment with AutoHotkey.dll due to user defined functions limitation.
User can put functions values as variables in expression string and then evaluate.

Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Timers inGame

17 Oct 2017, 03:45

There many things that player must check and use. It is example howto keep bufs and auto select nearest mob.

Code: Select all

#SingleInstance Force
;Copyright (c) D.Donchev

SendMode("Event")
CoordMode("Mouse", "Screen")
CoordMode("Pixel", "Screen")
SetKeyDelay(150, 90)
Sleep(500)
goSub("!B")
goSub("$CapsLock")

$CapsLock::
	tooltip("<<< " ((State:=!State)? "Kill": "Pause") " >>>", midx(State? -62: -71), A_ScreenHeight-75, 20)
GRB_KILL:
	SetTimer("GRB_KILL", "OFF") ;label not init so name needed (only in global scope)
	if State {
		if pixelGetColor(midx(-4), 28) != 0x252525
			Send(1) ;attack
	SetTimer("GRB_KILL",   100) ;
	}
return

!B::
	loop 4 {
		Sleep(500)
		GoSub("$Numpad" A_Index) ;gosub init labels
	}
return

!G::ExitApp

$Numpad1::Send("{Numpad1 5}"), SetTimer(, 180000) ;no label name needed
$Numpad2::Send("{Numpad2 5}"), SetTimer(, 170000)
$Numpad3::Send("{Numpad3 5}"), SetTimer(, 300000)
$Numpad4::Send("{Numpad4 5}"), SetTimer(, 900000)	

midx(x:=0) {
	static mx:= A_ScreenWidth//2
	return mx+x
}
midy(y:=0) {
	static my:= A_ScreenHeight//2
	return my+y
}
CapsLock activate/deactivate killing state.
Numpad buttons activates bufs and reset timers - so player can forced bufs timer independently.

Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[FUNCTION] contain(this, needle)

18 Oct 2017, 08:48

FIRST try to create function that can return result if this contain needle.
First of all we need strong criterion what we need to find and how to represent it? In most cases we have VALUE and in some cases KEY:VALUE, but in both we have stronger division VALUE or KEY. So let say that this two things we need to search in complete order (mean KEY == NEDDLE or VAL == NEEDLE) and let say that we need sign where KEY/VAL begin and where KEY/VAL ended. If we know that we can convert any AHK type to string and in last to search with InStr().
I chose "|" for begin and "|" for end in this case:
KEY become |KEY|
VAL become |VAL|

Code: Select all

#SingleInstance Force
;Copyright (c) D.Donchev

class t {
	__new(arg) {
		this.valu:= arg
}	}

a:= [{"asd":[{new t("zxc"):234}, {"sdf":789}, 2, 3]}, {"qwe":345}, 1, 2, 3, 4, 12.34]
;b:= [2, 3, 4]
b:= new t("zxc")

msgBOX(toStr(a))
msgBOX(toStr(b))
msgBOX(contain(a, b)) ; if contain(a, b)

contain(this, needle) {
	return inStr(toStr(this), toStr(needle))
}

toStr(this) {
	if isObject(this) {
			for key, val in this 
				str .= (type(key) != "Integer"? toStr(key): "") toStr(val)
			return str		
	} else	return "|" this "|"
}
Code extremely small but check if this exactly contain needle. Due to same converting algorithm we have strong equal for the equal objects.
disadvantage - no difference what we found KEY or VAL but it exist into this.
disadvantage - [1:1, 2:2] is equal to [12:1, 23:2] - if key integer key not present in string.

Enjoy!
Last edited by _3D_ on 20 Oct 2017, 03:19, edited 2 times in total.
AHKv2.0 alpha forever.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: InGame v2.0

18 Oct 2017, 12:24

You have some interesting stuff here. I only
browsed the first page for now. The switch is nifty . I think you need a table of contents though ;)
Thanks for sharing, cheers :thumbup:
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Helgef

19 Oct 2017, 03:12

Thanks Helgef for the great idea.
Cheers. :beer:
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[FUNCTION] ColorIs() - revized

30 Oct 2017, 08:41

In https://autohotkey.com/boards/viewtopic ... 40#p112863
I describe function that check for given colors and do defined for that colors actions. Now without for.

Code: Select all

ColorIs(sec, byRef pix:="", mis:= 998) {
	loop sec {
		tooltip(sec--) ;
		if dd_varExist(pix[pix.c:= PixelGetColor(pix.x, pix.y)]) ;add c to pix
			return pix[pix.c]
		sleep(mis)
	}	
	return "" ;return "" instead of 0
}
Now function check if is there "key" that is equal to current color and if true return defined value.

Code: Select all

dd_varExist(ByRef v) { ;check if v exist
	return !(&v == &_) 
} ;==========
Enjoy!
[Edit] And revision without external functions:

Code: Select all

ColorIs(sec, byRef pix:="", txt:= "", mis:= 998) {
	loop sec {
		tooltip(txt sec--)
		if pix[pix.c:= PixelGetColor(pix.x, pix.y)] != "" ;add c to pix
			return pix[pix.c]
		sleep(mis)
	}	
	return ""
}
In this case when value is "" then variable don`t exist. (I prefer to check if variable exist).
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

IniReadPixel() and ColorIs()

07 Nov 2017, 08:34

I made and revision of IniReadPixel() and little revision of ColorIs()

Code: Select all

#SingleInstance Force
;Copyright (c) D.Donchev

CoordMode("Pixel", "Screen")
msgBOX(ColorIs(10, IniReadPixel(, "IE8-W7", "OPEN_chk", p), "Wait ")) ;ini is A_ScriptName
for key, val in  p
	msgBOX(key ":=" val)
ExitApp

IniReadPixel(f:="", s:="", varr:="", byRef pixl:= "") { ;set f and s for further use
	static file:= A_ScriptName, sect:= ""
		if f
			file:= f
		if s
			sect:= s
	if varr != "" {
		pixl:= [] ;create object
		loop parse, IniRead(file, sect, varr), ",| " ;replace StrSplit and for
			if A_LoopField != "" 
				if ++cnt == 1
					pixl.x:= A_LoopField 
				else if cnt == 2
					pixl.y:= A_LoopField 
				else {
					val:= strSplit(A_LoopField, ":", " ")
					pixl[val[1]]:= val[2]
	}			}
	return pixl
}
ColorIs(sec, byRef pix, txt:= "", mis:= 998) { 
	if isObject(pix) {
		while sec { ;negative value check infinitely
			if pix[pix.c:= PixelGetColor(pix.x, pix.y)] != "" { ;add c to pix
				tooltip()
				return pix[pix.c] ;if pix.c not exist and/or pix[pix.c] not exist return ""
			}	
			tooltip(txt sec--)
			sleep(mis)
	}
	tooltip()	
	return ""
}
/* ;This line prevent AutoHotkey.exe to void errors. NEXT IS INI
[IE8-W7]
OPEN_chk	= 645, 354, 0xFFFFF1:1, 0xC9CED4:0
This is working example that will wait 10 seconds to become pixel(645:354) 0xFFFFF1 or 0xC9CED4 and will return result and pixel object.
[Edit] I add try catch return"" if pix argument is not Object.
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

class Task (Task.List:= [])

04 Jan 2018, 06:16

As I see that no ALL task forced closed
https://lexikos.github.io/v2/docs/commands/For.htm
Existing key-value pairs may be modified during the loop, but inserting or removing keys may cause some items to be skipped or enumerated multiple times. One workaround is to build a list of keys to remove, then use a second loop to remove the keys after the first loop completes.
I start investigate why and result:
https://autohotkey.com/boards/viewtopic ... 92#p192392
https://autohotkey.com/boards/viewtopic ... 50#p192750
Revised class Task
:

Code: Select all

;Copyright (c) D.Donchev
class Task {
	static List:= []   ;static list
	;mode
	;		0x01 - terminate task and delete from list (keep/kill child when parent close)
	;		0x02 - delete default VAR file
	;		0x04 - delete script file
	;		0x08 - kill task
	;
	;		0x10 - runwait
	;		0x20 - run when new Task() (run without using this.run())
	;		0x40 - end when new Task() (end without using this.end())
	;example:
	;		new Task(".\test.ahk", 0x73) ;just one line
	;			run test.ahk
	;			wait to close
	;			delete from list
	;			delete var file
	;default
	;		0x13 - runwait|delete var file|close task
	;most used
	;		0x73 - run auto|end auto|runwait|delete var file|close task
	__new(name, mode:= 0x13) {
		this.mode:= mode
		this.name:= name
		Task.List[this]:= ""
		this.ini()			;set default values
		if this.mode & 0x20
			this.run()		;run task
		if this.mode & 0x40
			this.end()		;end task
	}
	set(var, val, opt:="") { ;var val [ini:iniName sec:iniSection]
		this.ini(ini, sec, opt)
		iniWrite(val, ini, sec, var)
		return   val
	}
	get(var,      opt:="") { ;var [ini:iniName sec:iniSection]
		this.ini(ini, sec, opt)
		return iniRead(ini, sec, var)
	}
	;mode   1 - wait
	;		0 - dont wait
	;	   -1 - use this.mode (default)
	run(para:="", wait:= -1) { 					;execute task
		run("autohotkey.exe " this.name " " para,,,pid) ;send parameters correctly
		this.PID:= pid 										  ;take PID immediately 
		if (wait == -1? this.mode & 0x10: wait)
			ProcessWaitClose(this.PID) 						  ;runwait
		return this	
	}
	static 	end:= func("__Task_end") ; byRef this external function
	__delete() {
		if this.mode != "" {			;prevent second run
			;0x08 - kill or 0x01 - close
			if this.mode & 0x80
				ProcessClose(this.pid)
			else if this.mode & 0x09 {	
				DetectHiddenWindows("On")
				winClose("ahk_pid " this.PID)
			}
			if this.mode & 0x02		;0x02 - delete default task.ahk.VAR !!!
				FileDelete(this.name ".VAR")	
			if this.mode & 0x04		;0x04 - delete task.ahk
				FileDelete(this.name)
			this.mode:= this.name:= ""	;prevent second run
	}	}
	; ini(ini, sec)								;current values
	; ini(ini, sec, "ini:file.ini|sec:input")	;temporary values
	; ini(ini, sec, "set:|ini:ini.ext|sec:1")	;set new values
	;		|									;delimiter (space is not delimiter)
	;		set:								;set command
	;		ini:c:\long path\long name.ini		;ini file name
	;		sec:some text						;section name
	; ini(ini, sec, 0)							;reset values
	ini(byRef ini:= "", byRef sec:= "", opt:= "") { ;DRY set:|ini:iniName|sec:iniSection
		;if this.file not set OR opt == 0 (0 or "0")
		if !this.file || opt == 0 ;set default values
			this.file:= "ini:" this.name "|sec:VAR"
		;if opt != 0 (0 or "0" or "") use opt else use this.file	
		opt:= opt? opt: this.file
		if RegExMatch(opt, "i)ini:([\w\\:. ]+)(p*)", arg) ;ini:
			ini:= arg[1]
		if RegExMatch(opt, "i)sec:([\w ]+)(p*)"    , arg) ;sec:
			sec:= arg[1]
		if RegExMatch(opt, "i)set:",                 arg) ;set:
			this.file:= "ini:" ini "|sec:" sec
		;dont forget it is your script - using it incorrect doing incorrect
	}
} 
__Task_end(byRef this) { ;clear reference in list and in calling var
	if type(this) != "Class" {
		Task.List.Delete(this)
		this.__delete() ;forced   __delete() if other references
		this:= ""		;autocall __delete() if no more references
}	} ;class Task ------------------------------------------------------------------
__onExit() {
	;Task.List:= [] ;https://autohotkey.com/boards/viewtopic.php?p=192750#p192750
	while !isEmpty {
	isEmpty:= 1
	for key in Task.List {
		key.end()
		isEmpty:= 0 
}	}	}
OnExit(         "__onExit")
__scExit() { ;script exit
	ExitApp
}
OnMessage(0x10, "__scExit") ;WM_CLOSE 
OnMessage(0x11, "__scExit") ;WM_QUERYENDSESSION
It is completely compatible with early version.
Last edit 11.Jan.2018
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Xerox Counters [Out of InGame v2.0]

13 Jan 2018, 07:32

This is a small out of course InGame project.
The idea is to get counters for given Xerox machines with web interface.

Code: Select all

#SingleInstance Force
;Copyright (c) D.Donchev

html:= A_ScriptFullPath ".html"
xOut:= FileOpen(A_ScriptFullPath ".txt", "w")

loop read, A_ScriptFullPath ".ini" {
	if A_LoopReadLine {
		if inStr(A_LoopReadLine, "|") {
			machine:= strSplit(A_LoopReadLine, "|", " `t")
			TrayTip("Take counters from: " machine[1])
			Download(machine[2], html)
			if (counters:= !ErrorLevel) {
				text:= FileRead(html)
				xOut.Write((nextLine? "`r`n": "") machine[1])
				nextLine:= 1
		}	} else if counters {
			if RegExMatch(text, "[0-9]+", match, inStr(text, A_LoopReadLine) + strLen(A_LoopReadLine)) {
				xOut.Write("," match.Value)
}	}	}	}
xOut.Close()
FileDelete(html)
TrayTip("Take counters DONE!")
msgBox("Done!")
ExitApp
#!F4::ExitApp
It is needed INI file with name AHKscript.ahk.ini
Next is example ini file

Code: Select all

wc232.xcc.cs | http://wc232.xcc.cs/properties/billing/billingCounters.dhtml
gAllMarkedImages
gBlackCopyImages
gBlackCopySheets

m55.xcc.cs | http://m55.xcc.cs/properties/billingCounters.dhtml
markedBWandColorImages
markedBWCopyImages
markedBWPrintImages
Output:

Code: Select all

wc232.xcc.cs,269606,173481,139125
m55.xcc.cs,1845940,1343841,501892
Syntax:

Code: Select all

machine | machine/web/page/that_contain/counters
counterName
Limitations:
• counterName can be right before counterDigits (mean no any other digits between).
• missed download links take about 30 seconds each till ErrorLevel be set.
It is Saturday small project - but very useful for copy centers with Xerox machines.
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Universal Communications

01 Mar 2018, 08:45

This days I completely down the games and work on communicate to kitchen printers wire and wireless (esp8266).
There is a working set - but still in test mode. So I first will post some functions then complete project.
[FUNCTION] Tip - it is a simple function that combine toolTip and trayTip together.
Classic mode:

Code: Select all

Tip(text:= "", what:= "tray") {
	if inStr(what, "tray") {
		traytip(text,,0x10)
		return
	}			
	if inStr(what, "tool") {
		tooltip(text)
		return
}	}
Switch mode:

Code: Select all

Tip(text:= "", what:= "tray") {
	try {
		goto(what)
			tray:
				traytip(text,,0x10)
				return
			tool:
				tooltip(text)
				return
}	}
And Usage:

Code: Select all

Tip("Tray tip to test")
sleep(1000)
Tip()
Tip("Done the tray up the tool", "tool")
sleep(1000)
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Universal Communications

04 Mar 2018, 03:06

[FUNCTION] encoding().
AHK have brilliant system for changing encoding, unfortunately Bulgarian DOS code page never supported by Microsoft https://en.wikipedia.org/wiki/MIK_(character_set) and Bulgarian WIN code page is CP1251.
Function convert data buffer from to CP1251 and CPMIK (no standard number, in some documentations CP856).

Code: Select all

encoding(byRef addr, size, enco) {
	if enco:= inStr(enco, "WIN")? +64: inStr(enco, "DOS")? -64: 0 {
		loop size
			if (char:= numGet(addr, A_Index-1, "UChar")) >= 0x80
				numPut(char + enco, addr, A_Index-1, "UChar")
}	}
Usage:

Code: Select all

file:= "c:\path\file.txt"
data:= FileRead(file, "RAW")
size:= FileGetSize(file)
encoding(data, size, "WIN") ;convert CPMIK to CP1251
encoding(data, size, "DOS") ;convert CP1251 to CPMIK
As I use object to put data into:

Code: Select all

encoding(byRef port, enco) {
	if enco:= inStr(enco, "WIN")? +64: inStr(enco, "DOS")? -64: 0 {
		addr:= port.getAddress("data") ;Helgef
		loop port.size
			if (char:= numGet(addr, A_Index-1, "UChar")) >= 0x80
				numPut(char + enco, addr, A_Index-1, "UChar")
}	}
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Universal Communications

26 Apr 2018, 12:30

[Function] writesize
It is a simple function that calculate offset and size of buffer that we can send trough comm port or socket port.

Code: Select all

writesize(offs, buff, size) {
	if offs < size && (res:= size - offs) >= buff
		res:= buff? buff: res
	return res
}
Yes it is just one IF.

[Function] CommMove
Write given file (buffer) to given comm port.

Code: Select all

CommMove(file, ByRef port) {
	if comm:= FileOpen(port.dest, "w") {
		Tip("[ " port.sect " ] " port.dest)
		VarSetCapacity(DCB, 80, 0) ;DCB structure - init port settings for example: 9600,n,8,1 
		if port.init && DllCall("BuildCommDCB", "str", port.init, "UInt", &DCB)
				DllCall("SetCommState", "UInt", comm.Handle, "UInt", &DCB) ; ---------------
		addr:= port.getAddress("data")		
		offs:= 0		
		while size:= writesize(offs, port.buff, port.size) {
			comm.RawWrite(addr+offs, size)
			comm.Handle
			offs += size
			sleep(port.wait)
		}	
		comm.Close()
		FileDelete(file) ;input file will be deleted only when transfer is complete
}	}
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[Function] Tip

28 Jun 2018, 08:30

One more crazy syntax using associative array.

Code: Select all

Tip(text:= "", what:= "") {
	tray(t) => traytip(t,,0x10)	;different arguments list
			  ;tooltip(t)
	
	;if key not exist list will return ""
	static tarr:= {"tray":"tray", "tool":"tooltip"} 
	static ttip:= tarr["tray"]
	
	;if "" use last known
	%(ttip:= tarr[what]? tarr[what]: ttip)%(text)
}
No try, no catch, just one ternary.
Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Socket

16 Jul 2018, 12:23

[Function] SocketMove
Move data to given socket (like CommMove) fully compatible with Virtual Serial Ports Emulator (VSPE) http://www.eterlogic.com/Products.VSPE.html

Code: Select all

SockMove(file, byRef port) {
	addr:= StrSplit(port.dest, ":", " `t")
	VarSetCapacity(wsad, 32)
	if !DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", &wsad)
		&& (sock:= DllCall("Ws2_32\socket", "Int", 2, "Int", 1, "Int", 6)) != -1 {
			VarSetCapacity(sadd, 16)
			numPut(										 	2, sadd, 0, 2)
			numPut(DllCall("Ws2_32\htons", "UShort", addr[2]), sadd, 2, 2) ;port
			numPut(DllCall("Ws2_32\inet_addr","AStr",addr[1]), sadd, 4, 4) ;ip
			if !DllCall("Ws2_32\connect", "UInt", sock, "UInt", &sAdd, "Int", 16) {
				Tip("[ " port.sect " ] " port.dest)
				Sleep(100)
				addr:= port.getAddress("data")
				offs:= 0
				while size:= writesize(offs, port.buff, port.size) {
					DllCall("Ws2_32\send", "UInt", sock, "Uint", addr+offs, "Int", size, "Int", 0)
					offs += size
					sleep(100)
					sleep(port.wait)
				}
				FileDelete(file)
	}		}		
	DllCall("Ws2_32\WSACleanup")
}
Functions FileMove, CommMove and SockMove covered 90% of possibilities for data transferring to kitchen printers.
The whole project can work as data "transmitter", data "router" and data "server".
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[SetTimer] Crazy syntax.

01 Aug 2018, 06:47

Due to SetTimer changed to get as first argument function, here some crazy syntax to keep things.
WAS

Code: Select all

$Numpad1::Send("{Numpad1}"), SetTimer("$Numpad1", 2000)
NOW - shortest crazy syntax

Code: Select all

$Numpad2::numpad2(), numpad2()=> (Send("{Numpad2}"), SetTimer(A_ThisFunc, 2000))
!!! put the fat function code into () - this way A_ThisFync worked.
Complete test code

Code: Select all

#SingleInstance Force

$Numpad1::Send("{Numpad1}"), SetTimer("$Numpad1", 2000) ; <<< this line not work
$Numpad2::numpad2(), numpad2()=> (Send("{Numpad2}"), SetTimer(A_ThisFunc, 2000))

#!Q::ExitApp
What the code do:
1.When NumpadX - NumpadX is send to game and Timer is set.
2.When Timer - NumpadX is send to game.
"Auto Clicker" - I use this mechanism to keep buffs in time.

Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[SetTimer] Crazy syntax.

03 Aug 2018, 06:19

And one more:

Code: Select all

$Numpad1::numpad1(), setTimer(numpad1() => (send("{Numpad1}")), 2000)
In this case only body of numpad1() will be executed without setTimer.

Code: Select all

$Numpad1::numpad1(), SetTimer(numpad1() => (Send("{Numpad1 5}")), 180000)
$Numpad2::numpad2(), SetTimer(numpad2() => (Send("{Numpad2 5}")), 170000)
$Numpad3::numpad3(), SetTimer(numpad3() => (Send("{Numpad3 5}")), 300000)
$Numpad4::numpad4(), SetTimer(numpad4() => (Send("{Numpad4 5}")), 900000)
Real and working set.

Enjoy!
AHKv2.0 alpha forever.
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

[POWER of FAT ARROW functions] Part II

22 Aug 2018, 06:26

Why PART II first?
PART I is more complicated and longer. I still write examples to PART I, but here some conclusions that works.
Everything started in search to find possibilities to have external format string and passed it as argument.
https://autohotkey.com/boards/viewtopic ... 21#p168236

Now I completely change that idea and now send fat arrow function instead of string.
It is extremely small example that contain most of my researches on fat arrow function.

Code: Select all

#SingleInstance Force
;Copyright (c) D.Donchev

formatArr:= {
	;MsgBox with format
	MB	: (arg, var) => MsgBox(
			format("format: {:02d} var:= {:d} arg:= {:d} res:= {:.2f}", A_Index, var, arg, (var+arg)/A_Index)
			,,"T1"),
	;ToolTip without format
	TT	: (arg, var) => (
			tooltip("noformat: " A_Index " var:= " var " arg:= " arg " res:= " (var+arg)/A_Index),
			sleep(1000))	
}

myFunc(100) 				;(1) default format
myFunc(100, formatArr.MB) 	;(2)
myFunc(100, formatArr.TT)	;(3)
 
myFunc(arg, fmt:="") { ;unsuported fat arrow function as default parameter
	;make internal format to avoid checking in any loop
	fmt:= type(fmt) == "Func"? fmt: ()=>"" ;nothing (arguments not needed)
	var:= 20
	loop 5 { 
		;deref and calculate as arguments
		;put all loclal variables and arguments that are needed
		%fmt%(arg, var) ;call fat arrow function
		arg += var		;change arguments
		var *= 2		;change local variables
		;the same with global variables
}	}
(1) - here no visual output
(2) - here MsgBox as visual output
(3) - here ToolTip as visual output
All examples (1)(2)(3) passed fat arrow function as argument and myFunc call it. All "deref" and "calculations" becomes native and avoid needs of second pars and external calculation, variable visibility and so on. And in addition I can control visual format and visual method that represent that format.

In PART I - I will explain what we can do, how, and what is best syntax to produce powerful fat arrow function.
Enjoy!
AHKv2.0 alpha forever.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 2 guests