InGame v2.0

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: InGame v2.0

fast and furious

Post by _3D_ » 23 Sep 2018, 02:55

A simple speed test about sending and running functions as arguments.

Code: [Select all] [Expand]GeSHi © Codebox Plus

The conclusions:
1. If everything fine - try run is faster - due to no any additional check.
2. If is needed check - ternary run is faster - due to faster check.
It is script language and user must keep language rules. So complete propriety check not possible.

Enjoy!

dd_pixelGetColor.ahk

Post by _3D_ » 31 Aug 2018, 03:53

An old project that I use all the time.
https://autohotkey.com/boards/viewtopic.php?f=19&t=2400#p17615
Some in time I add snapShot() that get bmp from screen and save it to file. So this day I revised snapShot() and let see what happen:
The first code:

Code: [Select all] [Expand]GeSHi © Codebox Plus

I see that too many madness in code.
First revise:

Code: [Select all] [Expand]GeSHi © Codebox Plus

Loop Parse instead StrSplit - faster and less ram.
Now how to avoid Goto? A simple test function:

Code: [Select all] [Expand]GeSHi © Codebox Plus

Function needed 4 parameters x, y, w, h
- x and y - start point coordinate
- w and h - end point coordinate or width and height (see syntax in code)
And the result without comments:

Code: [Select all] [Expand]GeSHi © Codebox Plus

And the whole project:

Code: [Select all] [Expand]GeSHi © Codebox Plus


Enjoy!

[POWER of FAT ARROW functions] Part I - Mostly harmless.

Post by _3D_ » 23 Aug 2018, 14:06

Preamble:
https://lexikos.github.io/v2/docs/Varia ... #fat-arrow () => expr it is simple sintax but let see what it can do.
Examples:
Lets begin with something simple.

Code: [Select all]GeSHi © Codebox Plus

sup:= 7
function()
function() {
global ;global scope to function()
out:= 10
;function name is visible inside whole containing body
scop( 5)
;scop()'s variables scope is the same as scope containing scop()
scop(arg) => (msgBox("arg= " arg " out= " out " sup= " sup))
}
To be demonstrated variables visibility all fat arrow functions will be pressent as sub functions. If function() "see" global variables scop() will "see" them too.
The most important things in one alghoritm is divergency and cyclicality.
Let see what about if/else/loop/for/do/while/until.

Code: [Select all] [Expand]GeSHi © Codebox Plus

As if/else/loop/for/do/while/until are not expressions so they not work.
About IF.

Code: [Select all]GeSHi © Codebox Plus

function()	
function() { ;ternary instead if/else
_if(5)
_if(arg) => (arg == 5? MsgBox(arg "==5"): ;if a==5 then MsgBox(arg "==5")
MsgBox(arg "!=5") ; else MsgBox(arg "!=5")
) ;"" must be used as nothing
;_if(arg) => (arg == 5? MsgBox(arg): "") ; at both places (then/else)
}
About LOOP/WHILE.

Code: [Select all]GeSHi © Codebox Plus

function()
function() { ;recursion instead loop/while
_loop(10)
_loop(arg) => (
arg > 0 ? tooltip(arg) sleep(1000) _loop(arg-1) ;no comma
: tooltip()
)
}
Don`t forget recursion is powerful but must be guaranteed end of recursion and think about stack (most arguments - most stack).
Different expressions not enclosed and not comma separated it is possible but not well.
Yet another recursion example.

Code: [Select all] [Expand]GeSHi © Codebox Plus

And another one but here fat arrow function inside fat arrow function.

Code: [Select all] [Expand]GeSHi © Codebox Plus


Conclusions:

Code: [Select all] [Expand]GeSHi © Codebox Plus


All examples in one only code:

Code: [Select all] [Expand]GeSHi © Codebox Plus



Working example - fat arrow function as function argument.

Code: [Select all]GeSHi © Codebox Plus

myToolTip("111", 200, 200, 20, 3000)
myToolTip("222", 100, 100, , 2000)

myToolTip(text, x:="", y:="", w:="", time:="") {
tooltip(text, x, y, w)
if(time is "number")
SetTimer(()=>tooltip(,,,w), time<0?time:-time) ;fat as argument
}


Fat arrow functions and classes.

Code: [Select all] [Expand]GeSHi © Codebox Plus

Code: [Select all]GeSHi © Codebox Plus

	_Class  : A -> String		(ok)
var : 1 -> Integer (ok)
met : -> Func (ok)

fat is invisible lol --> (no)
is not a member of A (ok)
All fat arrow functions defined inside class definition becomes global.

Code: [Select all] [Expand]GeSHi © Codebox Plus

Comments inside the code. Most important is that all functions related to classes must have at least one argument because all methods are called with first argument this.
Again:
Enclose all individual expression in () and separate expressions with comas. Enclose all expressions in () like {} for best reading. "" can be used as nothing (NOP). Ternary instead IF/ELSE and recursion instead LOOP/WHILE.

Code: [Select all]GeSHi © Codebox Plus

[FatArrowFunctionName]([agruments])=>(
(expression),
(expression) ;last expression is return value
)


Enjoy!

[POWER of FAT ARROW functions] Part II

Post by _3D_ » 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.php?f=19&t=2400&p=231721#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] [Expand]GeSHi © Codebox Plus

(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!

[SetTimer] Crazy syntax.

Post by _3D_ » 03 Aug 2018, 06:19

And one more:

Code: [Select all]GeSHi © Codebox Plus

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

Code: [Select all]GeSHi © Codebox Plus

$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!

[SetTimer] Crazy syntax.

Post by _3D_ » 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]GeSHi © Codebox Plus

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

Code: [Select all]GeSHi © Codebox Plus

$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]GeSHi © Codebox Plus

#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!

Socket

Post by _3D_ » 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] [Expand]GeSHi © Codebox Plus

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".

[Function] Tip

Post by _3D_ » 28 Jun 2018, 08:30

One more crazy syntax using associative array.

Code: [Select all]GeSHi © Codebox Plus

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!

Universal Communications

Post by _3D_ » 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]GeSHi © Codebox Plus

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] [Expand]GeSHi © Codebox Plus


Enjoy!

Universal Communications

Post by _3D_ » 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]GeSHi © Codebox Plus

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]GeSHi © Codebox Plus

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]GeSHi © Codebox Plus

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!

Universal Communications

Post by _3D_ » 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]GeSHi © Codebox Plus

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

Code: [Select all]GeSHi © Codebox Plus

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

Code: [Select all]GeSHi © Codebox Plus

Tip("Tray tip to test")
sleep(1000)
Tip()
Tip("Done the tray up the tool", "tool")
sleep(1000)
Enjoy!

Xerox Counters [Out of InGame v2.0]

Post by _3D_ » 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] [Expand]GeSHi © Codebox Plus

It is needed INI file with name AHKscript.ahk.ini
Next is example ini file

Code: [Select all]GeSHi © Codebox Plus

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]GeSHi © Codebox Plus

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

Code: [Select all]GeSHi © Codebox Plus

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!

class Task (Task.List:= [])

Post by _3D_ » 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.php?p=192392#p192392
https://autohotkey.com/boards/viewtopic.php?p=192750#p192750
Revised class Task
:

Code: [Select all] [Expand]GeSHi © Codebox Plus

It is completely compatible with early version.
Last edit 11.Jan.2018

IniReadPixel() and ColorIs()

Post by _3D_ » 07 Nov 2017, 08:34

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

Code: [Select all] [Expand]GeSHi © Codebox Plus

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!

[FUNCTION] ColorIs() - revized

Post by _3D_ » 30 Oct 2017, 08:41

In https://autohotkey.com/boards/viewtopic.php?f=19&t=2400&start=40#p112863
I describe function that check for given colors and do defined for that colors actions. Now without for.

Code: [Select all]GeSHi © Codebox Plus

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]GeSHi © Codebox Plus

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

Code: [Select all]GeSHi © Codebox Plus

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).

Helgef

Post by _3D_ » 19 Oct 2017, 03:12

Thanks Helgef for the great idea.
Cheers. :beer:

Re: InGame v2.0

Post by Helgef » 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:

[FUNCTION] contain(this, needle)

Post by _3D_ » 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] [Expand]GeSHi © Codebox Plus

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!

Timers inGame

Post by _3D_ » 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] [Expand]GeSHi © Codebox Plus

CapsLock activate/deactivate killing state.
Numpad buttons activates bufs and reset timers - so player can forced bufs timer independently.

Enjoy!

DEREF back to AutoHotkey_2.0-a081-cad307c

Post by _3D_ » 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]GeSHi © Codebox Plus

__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]GeSHi © Codebox Plus

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!

Top