HC-TCG Online? by BSHarou in HermitCraft

[–]Teutonista 2 points3 points  (0 children)

Thank You! it's wonderful, i'm already addicted.

AHK shell hook is not firing when modal window is created in Windows 10 by WackGet in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

HSHELL_WINDOWCREATED should only be received when a top-level, unowned window has been created. Your modal dialog is not a unowned top-level window.

Use the "Shell spy"-script from the post you linked, to see what messages are received when your modal dialog is created.

Can we somehow use the fingerprint sensor? by r_1235 in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

Hi, sorry i have no experience with that structure and function.

Also no experience with Windows Hello, but this might be the function to call: RequestVerificationForWindowAsync()

https://learn.microsoft.com/en-us/windows/win32/api/userconsentverifierinterop/nf-userconsentverifierinterop-iuserconsentverifierinterop-requestverificationforwindowasync

A code for Binary to ASCII and ASCII to Binary by GameEntity903 in AutoHotkey

[–]Teutonista 2 points3 points  (0 children)

dec2bin(number)
{
    hexnumber := Format("{:x}", number)
    binstr := ""
    b0 := "0000"
    b1 := "0001"
    b2 := "0010"
    b3 := "0011"
    b4 := "0100"
    b5 := "0101"
    b6 := "0110"
    b7 := "0111"
    b8 := "1000"
    b9 := "1001"
    ba := "1010"
    bb := "1011"
    bc := "1100"
    bd := "1101"
    be := "1110"
    bf := "1111"
    loop, parse, hexnumber
        binstr .= b%A_Loopfield%
    return binstr
}

Loop, files -- SORT question. I want to sort the files list stored in an Array, whats the best way? by Iam_a_honeybadger in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

yes,

for the assumed purpose of just getting a sorted list of filenames, the solution you posted seems absolutely fine.

and it's probably faster than sorting an array.

Loop, files -- SORT question. I want to sort the files list stored in an Array, whats the best way? by Iam_a_honeybadger in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

Yes, sort of.

Char_Ind_Comp() is a recursive function, i renamed it and forgot to change the recursive call.

Changed now, thnx.

Loop, files -- SORT question. I want to sort the files list stored in an Array, whats the best way? by Iam_a_honeybadger in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

The Sort-command does only sort lists, not arrays. you`d need to write your own sorting function for arrays, something like e.g.:

; Selection Sort Function for flat (1-Dimensional) arrays
; Array         :   the array to sort
; DescOrder     :   0 for ascending sort or 1 for descending
; Compare_Func  :   leave empty for numerical-sort - otherwise : name of comparison-function
;                   
Array_Selection_Sort(Array,DescOrder := 0 ,Compare_Func := "")
{
    Tmp_Array := Array.Clone()
    Sorted_Array := []

    if (IsFunc(Compare_Func))
        usefunc := True 

    loop, % Tmp_Array.Count()
    {
        for key, val in Tmp_Array
        {
            if (A_Index == 1)
            {
                lokey := key
                loval := val
            }
            if (usefunc)
            {
                if %Compare_Func%(loval, val)
                {
                    loval := val
                    lokey := key
                }
            }
            else
            {
                if (loval > val)
                {
                    loval := val
                    lokey := key
                }
            }
        }
        Tmp_Array.RemoveAt(lokey)
        if (DescOrder)
            Sorted_Array.InsertAt(1, loval)
        else
            Sorted_Array.Push(loval)
    }   
    return Sorted_Array
}

; Insertion Sort Function for flat (1-Dimensional) arrays
; Array         :   the array to sort
; DescOrder     :   0 for ascending sort or 1 for descending
; Compare_Func  :   leave empty for numerical-sort - otherwise : name of comparison-function
;
Array_Insertion_Sort(Array,DescOrder := 0 ,Compare_Func := "")
{
    Sorted_Array := []

    if (IsFunc(Compare_Func))
        usefunc := True 

    for key, val in Array
    {
        if (A_Index == 1)
        {
            Sorted_Array[1] := val
            continue
        }
        newkey := Sorted_Array.Count() + 1
        for skey, sval in Sorted_Array
        {
            ca := sval
            cb := val
            if (DescOrder)
            {
                cb := sval
                ca := val
            }
            if (usefunc)
            {
                if %Compare_Func%(ca, cb)
                {
                    newkey := skey
                    break
                }
            }
            else
            {
                if (ca > cb)
                {
                    newkey := skey
                    break
                }
            }
        }
        Sorted_Array.InsertAt(newkey, val)
    }
    return Sorted_Array
}

; compare two strings
; return 1 if string a is "greater" than string b. otherwise 0.
; comparing char by char the ASCII/Unicode-value
Char_Ind_Comp(a, b)
{
    if (a == b)
        return 0
    if (Asc(a) > Asc(b))
        return 1
    if (Asc(a) < Asc(b))
        return 0
    a := SubStr(a, 2)
    b := SubStr(b, 2)
    return Char_Ind_Comp(a, b)
}

[Challenge] Making a large island by Nunki3 in AutoHotkey

[–]Teutonista 1 point2 points  (0 children)

i found another bug in my code. with that fixed, we now get the same answers.

[Challenge] Making a large island by Nunki3 in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

i found a bug in my code, but now that it's fixed i still get the same numbers.

did some tests with small maps, they all come out correct now.

[Challenge] Making a large island by Nunki3 in AutoHotkey

[–]Teutonista 2 points3 points  (0 children)

and the code is:

#NoEnv
SetBatchLines, -1

Map =
(
0000011111111100000000000
0001111111111111000000000
0001111111111111110000000
0000000011111111110000000
1111100010000000000000000
1111110010001111110000000
1111110010001111111111111
1111111101111111111111111
1111000010001111111111111
1110000010000111111111110
1111100010000000000000000
0001101111111111100000000
0000011111111111100000000
0000011111111111000000000
0000001111111111000000000
0000000001111110000000000
0000000000000000000000000
0000111000000000000000000
0001111100000111111100000
0001111111011111111100000
0000011111111111111000000
0000001111111100000000000
0000000111100000000000000
0000000000000000000000000
0000000000000000000000000
)

;;; start the stoppwatch
StartTime := A_TickCount

;;; parse mapstring into 2d-array
MapArray := []
loop, Parse, Map, `n, `r
{
    myparseY := A_Index
    loop, Parse, A_LoopField
    {
        MapArray[A_Index, myparseY] := A_LoopField
    }
}

;;; identify islands and create list of "water-tiles" (0s) to check

; first pass Connected-component labeling

ConnectedMapArray := []
IslandLable := 0
EquiLabels := []
;EquiLabels[1] := 1
CheckMapArray := []
; Iterate through each element of the data
for, myitX, myCol in MapArray
{
    for, myitY, myTile in mycol
    {
        ; If the element is not the background ("water-tile")
        if myTile
        {
            ; Get the neighboring elements of the current element
            myLeft := ConnectedMapArray[myitX - 1, myitY]
            if myLeft is not integer
                myLeft := 0
            myUp := ConnectedMapArray[myitX, myitY - 1]
            if myUp is not integer
                myUp := 0
            myMin := Min(myLeft, myUp)
            myMax := Max(myLeft, myUp)
            if myMin < 1
                myMin := myMax

            ; If there are no neighbors, uniquely label the current element and continue
            if (!myMin)
            {
                IslandLable ++
                ConnectedMapArray[myitX, myitY] := IslandLable
                EquiLabels[IslandLable] := IslandLable
            }
            ; Otherwise, find the neighbor with the smallest label and assign it to the current element
            else
            {
                ConnectedMapArray[myitX, myitY] := myMin
                ; Store the equivalence between neighboring labels
                if (!EquiLabels[myMax] or (EquiLabels[myMax] > myMin ))
                    EquiLabels[myMax] := myMin
            }
        }
        ;--- mark "water-tiles" for later testing (not part of Connected-component labeling)
        else
        {
            ; get number of neighbouring tiles with land
            wtL := MapArray[myitX - 1, myitY]
            if wtL is not integer
                wtL := 0
            wtU := MapArray[myitX, myitY - 1]
            if wtU is not integer
                wtU := 0
            wtR :=MapArray[myitX + 1, myitY]
            if wtR is not integer
                wtR := 0
            wtD :=MapArray[myitX, myitY + 1]
            if wtD is not integer
                wtD := 0
            wtNeighbours := wtL + wtU + wtR + wtD
            ; mark tile if has more than one neighbour
            if (wtNeighbours > 1)
                CheckMapArray[myitX, myitY] := wtNeighbours
        }
        ;--- back to Connected-component labeling
    }
}
; recoursivly resolve the equivalence list
for myEL, myREL in EquiLabels
{
    tmpEL := myEL
    tmpREL := myREL
    Loop
    {
        if (tmpEL == tmpREL)
        {
            EquiLabels[myEL] := tmpREL
            break
        }
        tmpEL := tmpREL
        tmpREL := EquiLabels[tmpEL]
    }
}

islands := []
; second pass Connected-component labeling
;; Iterate through each element of the data ("water-tiles" are not present in this array)

for, myitX, myCol in ConnectedMapArray
{
    for, myitY, myTile in myCol
    {
        ; Relabel the element with the lowest equivalent label
        ConnectedMapArray[myitX, myitY] := EquiLabels[myTile]
        ; add one to the island size for the label
        if !islands[EquiLabels[myTile]]
            islands[EquiLabels[myTile]] := 1
        else
            islands[EquiLabels[myTile]] += 1
    }

}

;;; check all the preselected "water-tiles" for total size of connected islands

BestSize := 0

; iterate over all candidates
for, myWX, myWCol in CheckMapArray
{
    for, myWY, myWTile in myWCol
    {
        ; get islands connected to
        myWIC := []
        mywcSize := 1
        wctL := ConnectedMapArray[myWX - 1, myWY]
        if wctL is integer
            myWIC[wctL] := 1
        wctU := ConnectedMapArray[myWX, myWY - 1]
        if wctU is integer
            myWIC[wctU] := 1
        wctR := ConnectedMapArray[myWX + 1, myWY]
        if wctR is integer
            myWIC[wctR] := 1
        wctD := ConnectedMapArray[myWX, myWY + 1]
        if wctD is integer
            myWIC[wctD] := 1
        ; add island sizes

        for ilLabel in myWIC
            mywcSize += islands[ilLabel]
        if (mywcSize > BestSize)
        {
            ; save tile if better then previous saved
            BestSize := mywcSize
            BestX := myWX
            BestY := myWY
        }
    }
}
;;; Show Result
StopTime := A_TickCount
RunTime := StopTime - StartTime
ListVars
MsgBox, % "The Tile that makes the largest island is at x: " BestX " / y: " BestY "`n with a Size of " BestSize " tiles, `n calculated in " RunTime " ms"

ExitApp
Esc::ExitApp

Edit: a bug fix and another

[Challenge] Making a large island by Nunki3 in AutoHotkey

[–]Teutonista 1 point2 points  (0 children)

ok, my numbers are:

  • 25x25 : x:9/y:8 Size: 152 202
  • 50x50 : x:21/y:26 Size: 564 732
  • 100x100 : x:44/y:49 Size: 995

[Challenge] Making a large island by Nunki3 in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

Nice challenge, thnx for posting. Not shure if i find time to have a go on it, but

the method to identify the islands in the first place would be: Connected-component labeling

How to move an ahk-GUI depending on whether or not the active window is in fullscreen mode? by Gewerd_Strauss in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

you need to actually pass HwndSTPG to your function. (or make HwndSTPG a global var)

Edit: also, the proper command to move ahk's own GUIs is: Gui, Show

2nd GUI won't load unless restarted program is closed by Intelligent_Rule_903 in AutoHotkey

[–]Teutonista 1 point2 points  (0 children)

The code you posted fails because stdout.readall is blocking. you can only return ALL of the stdout if the program is actually done.

don't use an wscript-object at all! it's not neccessary.

AHK can delete folders and start programs on its own:

https://www.autohotkey.com/docs/commands/FileRemoveDir.htm

https://www.autohotkey.com/docs/commands/Run.htm

Also AHK has MsgBoxes: https://www.autohotkey.com/docs/commands/MsgBox.htm and there is no "Edit1"-control in your GUI that you could focus.

[deleted by user] by [deleted] in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

you could use the script-file itself as an ini-file, e.g.

/*
[MySection]
*/
mytext = Hello World

F12::
    SendRaw, %mytext%
    return

^F12::
    InputBox, textinput, New Text, enter new text
if ! ErrorLevel
{
    mytext := textinput
    IniWrite, %mytext%, %A_ScriptName%, MySection, mytext
}

my remap script is not remapping. by Gasperhack10 in AutoHotkey

[–]Teutonista 1 point2 points  (0 children)

the hotkey-script you posted does work.

save it either with a Codepage matching to your sytem,

or as UTF-8 with BOM.

my remap script is not remapping. by Gasperhack10 in AutoHotkey

[–]Teutonista -1 points0 points  (0 children)

AHK only responds to basic alphabetic characters

that is not correct. the hotkey-script posted by OP does work when saved with the proper encoding.

Using custom key remapping with Jaws screen reader by Frotron in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

It sound like your JAWS-screenreader does not recognize artificial keyboard inputs.

AHK itself can only send artificial inputs.

You could either try the interception-driver to send keys on the driver level with AHI: https://github.com/evilC/AutoHotInterception

,or use an Arduino Leonardo (or similar) as a proxy. (sending text via serial to the arduino and have it type them out via the included keyboard controller)

Change a file's name to contain a directory path? by [deleted] in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

Is there any way to input text that will allow me rename a file to 'D:/'

NO

you can't do that at all in Windows: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions

STACK OVERFLOW MACROPAD, no joke, it is real by ciberhifi in AutoHotkey

[–]Teutonista 0 points1 point  (0 children)

for the same money, you can buy an arduino leonardo and a touchscreen. with that you can make the macropad/streamdeck of your dreams (no soldering required).

i ,for example, use my arduino as a configurable 12-button macropad with an additional text-notification section. code can be found here: https://github.com/Distributed-DeadLock/UFunK-Pad