1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

How to create Drill select hotkey

Discussion in 'General Discussion' started by nickkardash, Apr 3, 2022.

  1. nickkardash

    nickkardash Bison Rider

    Messages:
    14
    Hello. This is a feature that I have always wanted and finally found a way to get it done. With the help of a image search program found here https://www.the-automator.com/automatemytask/ , i created a script that would find the picture of the drill in inventory, then click on it. this will require getting a program called autohotkey. this allows to run scrips and hotkey them to stuff. in the file I have set the hotkey to control 9. so I then set a macro to my mouse that has extra buttons on the thumb, or set it to whatever you want. I set the input to push f, control 9, then release f. I set the release f to 200 milliseconds, if not it didnt allow enough time on my system to grab it. Then there is another issue, this only works in windowed mode. nothing i could figure out to do it in fullscreen. my windowed mode had a problem as my monitor is a ultrawide and the resolution couldn't get just right. so, if you have this problem download this program https://store.steampowered.com/app/388080/Borderless_Gaming/ . This will take the windowed version and make it look full screen quite nicely. mine did mess up the pointer location slightly, but ill get used to it. Here is the code to cut and paste into a autohotkey script . that
    ^9:: command near the front is what sets the hotkey. ^ is the control command, then put whatever you want after that.



    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn ; Enable warnings to assist with detecting common errors.
    SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
    ^9::
    WinGetActiveTitle,Title
    Perform_Action({Type:"Mouse",Action:"Left",Actual:1,ClickCount:4,RestorePOS:0,Wait:1,WindowWait:2,Comment:"Mouse Click",Match:1,OffsetX:20,OffsetY:15,Area:"King Arthur's Gold (Build 3900) ahk_class CIrrDeviceWin32",Bits:"00000000000000000000000000000000000000000000000000000000z000003w00003ww0000Dnk0000nDk0003Az000DwzDk00znwz03wDzknkDkzz3D0zAzwA33wnzkkADwzzkzwznzz3zkzzDnzw3zwzDzk0DnDzk00zAzz000Dnz0000zDw0000zw00003zk00U",Ones:396,Zeros:804,Threshold:88,W:40,H:30})

    WinActivate,%Title%
    ;~ Do Not Change From Here
    Perform_Action(Actions*){
    static Ptr:=A_PtrSize?"UPtr":"UInt",PtrP:=Ptr "*",MyFunc
    static x32:="5589E557565383EC348B7D388B47048945CC8B47088945C88B470C8945EC8B47108945E48B45EC8945D43B45E47D068B45E48945D431C03B453C0F8D910000008B1C878B4C8704C745D000000000C745D800000000895DF08B5C8708894DE08B4DF0895DC4894DE8894DDC8B75C43975D87D568B75DC03752C31C98975C03B4DE07D2F8B75D08B5DC001CE803C0B3175118B55F08B5D3089349389D343895DF0EB0D8B55E88B5D34893493428955E841EBCC8B4DE085C9790231C98B5D20014DDCFF45D8015DD0EBA283C007E966FFFFFF8B45088B5D2040C1E0078945E085DB790231DB8D049D00000000C745E80000000031FF8945DCC745F0000000008B45E83B45247D4A8B45288B55F031C903551401F88945D83B4D207D280FB642026BF0260FB642016BC04B01F00FB6326BF60F01F03B45E08B45D80F9204084183C204EBD38B4DDC01DF014DF0FF45E8EBAE8B45202B45CCC745DC000000008945D88B55188B452403550CC745F0000000002B45C88955CC8945D08B451C034510C1E0108945E031C08B4DD0394DF00F8F9200000031C93B4DD87F748B7DDC8D14398955E831D28B75E80375283B55D47D273B55EC7D0D8B5D308B3C9301F7803F0175493B55E47D0D8B5D348B3C9301F7803F00753742EBD48B7DCC8D50018D340F8B7D400B75E08934873B55447D358B5DE831C0035D283B45EC7D0E8B7D308B34874001DEC60600EBED89D041EB878B4D20FF45F08145E000000100014DDCE964FFFFFF89D083C4345B5E5F5DC2400090"
    static x64:="4157415641554154555756534883EC28488B8424D00000008B5804895424788B780C894C2470895C24108B5808897C2408895C24148B581039DF89DF895C240C0F4D7C240831D2897C2418399424D80000000F8E8E000000448B14904531E431DB8B7C90088B6C90044489D6897C241C4489D73B5C241C7D644C63EE4C03AC24B80000004531DB4439DD7E3643807C1D0031478D341C7514488B8C24C00000004D63FA41FFC2468934B9EB11488B8C24C80000004C63FFFFC7468934B949FFC3EBC585ED41BB00000000440F49DDFFC34403A424A00000004401DEEB964883C207E965FFFFFF8B44247041BB000000008D4801C1E10783BC24A000000000440F499C24A000000031ED31F631FF468D2C9D000000003BAC24A80000007D554863DE48039C24B00000004863C74531D24C01C844399424A00000007E2D0FB65002446BE2260FB650016BD24B4401E2440FB620456BE40F4401E239CA420F92041349FFC24883C004EBC94401EF4401DEFFC5EBA244038424980000004531DB31C04531D28BBC24A00000008BAC24A80000008B9424900000002B7C241041C1E0102B6C2414035424784139EA0F8FDB0000004531C94139F90F8FB6000000438D1C1931C9394C24184189CC7E52394C24087E204C8BB424C00000004C8BBC24B0000000418B348E01DE4863F641803C37017579443964240C7E204C8BB424C80000004C8BBC24B0000000418B348E01DE4863F641803C3700755248FFC1EBA5428D340A4C8BB424E00000008D48014409C63B8C24E8000000418934867D4D31C0394424087E234C8BBC24C00000004C8BB424B0000000418B348748FFC001DE4863F641C6043600EBD74863C141FFC1E941FFFFFF41FFC24181C00000010044039C24A0000000E91EFFFFFF89C84883C4285B5E5F5D415C415D415E415FC3909090"
    ;~ Do Not Remove This Line
    BCH:=A_BatchLines,Mode:=A_TitleMatchMode,CoordMode:=A_CoordModeMouse
    SetTitleMatchMode,2
    Setbatchlines,-1
    CoordMode,Mouse,Screen
    for a,b in Actions{
    Bits:=b.Bits
    for c,d in StrSplit("0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
    i:=c-1,Bits:=RegExReplace(Bits,"\Q" d "\E",(i>>5&1)(i>>4&1)(i>>3&1)(i>>2&1)(i>>1&1)(i&1))
    Bits:=RegExReplace(SubStr(Bits,1,InStr(s,"1",0,0)-1),"[^01]+"),Info:=[b.W,b.H,b.Threshold,b.Ones,b.Zeros,b.Match+0?b.Match:"100"],All:=[]
    if(b.Type="Window"){
    End:=(Start:=A_TickCount)+(b.WindowWait*1000)
    while(A_TickCount<End){
    if(WinExist(b.Area))
    Continue,2
    Sleep,100
    }Error:="Unable to find Window " """" b.Area """"
    Goto,PA_Exit
    }End:=(Start:=A_TickCount)+(b.WindowWait*1000)
    while(A_TickCount<End){
    if(WinExist(b.Area)){
    WinGet,List,List,% b.Area
    Loop,% List{
    WinGetPos,X,Y,W,H,% "ahk_id" HWND:=List%A_Index%
    All.Push({X:X,Y:Y,W:W,H:H,HWND:HWND})
    }if(!All.1){
    Error:="Unable To Find Window:`n`n`t" Area
    Goto,PA_Exit
    }Goto,PA_NextStep
    }Sleep,100
    }if(!All.Count()){
    Error:="Unable to find Window " b.Area
    Goto,PA_Exit
    }
    PA_NextStep:
    End:=(Start:=A_TickCount)+(b.Wait*1000)
    while(A_TickCount<End){
    Arr:=[]
    for c,d in All{
    K:=StrLen(Bits)*4,VarSetCapacity(In,28),VarSetCapacity(SS,d.W*d.H),VarSetCapacity(S1,K),VarSetCapacity(S0,K),VarSetCapacity(AllPos,Info.6*4)
    for e,f in [0,Info.1,Info.2,Info.4,Info.5,0,0]
    NumPut(f,&In,4*(A_Index-1),"Int")
    Cap:=VarSetCapacity(Scan,d.W*d.H*4),Stride:=((d.W*32+31)//32)*4,Win:=DllCall("GetDesktopWindow",Ptr),HDC:=DllCall("GetWindowDC",Ptr,Win,Ptr),MDC:=DllCall("CreateCompatibleDC",Ptr,HDC,Ptr),VarSetCapacity(BI,40,0),NumPut(40,BI,0,Int),NumPut(d.W,BI,4,Int),NumPut(-d.H,BI,8,Int),NumPut(1,BI,12,"Short"),NumPut(32,BI,14,"Short")
    if(hBM:=DllCall("CreateDIBSection",Ptr,MDC,Ptr,&BI,Int,0,PtrP,PPVBits,Ptr,0,Int,0,Ptr))
    OBM:=DllCall("SelectObject",Ptr,MDC,Ptr,hBM,Ptr),DllCall("BitBlt",Ptr,MDC,Int,0,Int,0,Int,d.W,Int,d.H,Ptr,HDC,Int,X,Int,Y,UInt,0x00CC0020|0x40000000),DllCall("RtlMoveMemory",Ptr,&Scan,Ptr,PPVBits,Ptr,Stride*d.H),DllCall("SelectObject",Ptr,MDC,Ptr,OBM),DllCall("DeleteObject",Ptr,hBM)
    DllCall("DeleteDC",Ptr,MDC),DllCall("ReleaseDC",Ptr,Win,Ptr,HDC)
    if(!MyFunc){
    ;CodeHere
    VarSetCapacity(MyFunc,Len:=StrLen(Hex:=A_PtrSize=8?x64:x32)//2)
    Loop,%Len%
    NumPut((Value:="0x" SubStr(Hex,2*A_Index-1,2)),MyFunc,A_Index-1,"UChar")
    DllCall("VirtualProtect",Ptr,&MyFunc,Ptr,Len,"Uint",0x40,PtrP,0)
    }OK:=DllCall(&MyFunc,"UInt",Info.3,"UInt",d.X,"UInt",d.Y,Ptr,&Scan,"Int",0,"Int",0,"Int",d.W,"Int",d.H,Ptr,&SS,"AStr",Bits,Ptr,&S1,Ptr,&S0,Ptr,&In,"Int",7,Ptr,&AllPos,"Int",Info.6),Arr:=[]
    Loop,%OK%{
    if(Arr.Count()>=b.Match)
    Break,3
    Arr.Push({X:(Pos:=NumGet(AllPos,4*(A_Index-1),"Int"))&0xFFFF,Y:Pos>>16,W:Info.1,H:Info.2,HWND:HWND,Action:Action})
    }Sleep,100
    }if(Arr.1)
    Break
    Sleep,100
    }if(b.Match="Return")
    return Arr
    if(!Arr.1){
    Error:="Unable to find the Pixel Group"
    Goto,PA_Exit
    }if(!Obj:=Arr[b.Match]){
    Error:="Unable to find the " b.Match " occurrence."
    Goto,PA_Exit
    }WinGetPos,X,Y,,,% "ahk_id" Obj.HWND
    if(b.Type="InsertText"){
    Pos:="x" Obj.X+Round(b.OffSetX)-X " y" Obj.Y+Round(b.OffSetY)-Y,CB:=ClipboardAll
    while(Clipboard!=b.Text){
    Clipboard:=b.Text
    Sleep,10
    }BlockInput,On
    ControlClick,%Pos%,% "ahk_id" Obj.HWND
    if(b.SelectAll){
    Sleep,50
    Send,^a
    }Sleep,50
    Send,^v
    BlockInput,Off
    Clipboard:=CB
    Sleep,100
    }else if(b.Type="Mouse"&&b.Action!="Move"){
    ;********************restore mouse position***********************************
    if(b.RestorePOS)
    MouseGetPos,RestoreX,RestoreY
    if(b.Actual){
    MouseClick,Left,% Obj.X+Round(b.OffSetX),% Obj.Y+Round(b.OffSetY),% b.ClickCount ;Added b.clickcount by Joe as it was missing
    if(b.RestorePOS)
    MouseMove,% RestoreX,RestoreY ;change this to an if the thing was selected
    }else{
    Pos:="x" Obj.X+Round(b.OffSetX)-X " y" Obj.Y+Round(b.OffSetY)-Y
    ControlClick,%Pos%,% "ahk_id" Obj.HWND,,% b.Action,% b.ClickCount
    }
    }else if(b.Type="Mouse"&&b.Action="Move")
    MouseMove,% Obj.X+Round(b.OffSetX),% Obj.Y+Round(b.OffSetY)
    }
    PA_Exit:
    CoordMode,Mouse,%CoordMode%
    SetTitleMatchMode,%Mode%
    SetBatchLines,%BCH%
    if(A_ThisLabel="PA_Exit"){
    ;MsgBox,262144,Error,%Error%
    Exit
    }
    return "ahk_id" Obj.HWND
    }
    ;~ To Here
     
    ShamWow-SuperRag likes this.
  2. ThePiemaster

    ThePiemaster Haxor

    Messages:
    20
    Congrats on getting it to work, but I don't think hotkeys should be used in games; it gives a hugely unfair advantage.
     
  3. nickkardash

    nickkardash Bison Rider

    Messages:
    14
    so, you are saying the builder hotkeys they added in are unfair for players who actually utilize them? because it does give a big advantage, but it takes work and practice to get good at them. I have always thought the drill should just be in the same category as it is quite annoying and clunky to select this . To me, not optimizing your game is what perpetual noobs do. thats just not how i roll. also as a side note, this script i posted brakes every update. you must go in and edit the game version so it matches your current one.
     
  4. 8x

    8x Elimination Et Choix Traduisant la Realité Forum Moderator Staff Alumni Tester
    1. The Young Blood Collective - [YB]

    Messages:
    1,324
    That looks like a dedicated effort, gratz on it though. Do you find it faster or better than doing it by hand?
     
    nickkardash likes this.
  5. nickkardash

    nickkardash Bison Rider

    Messages:
    14
    Once i got it set up it just stays that way pretty much. so its really not effort after that. it is so much better this way. much improved then by hand and it can keep the focus on the game. it makes the experience feel more fast pace and exciting
     
  6. The_Osz

    The_Osz Bison Rider

    Messages:
    20
  7. nickkardash

    nickkardash Bison Rider

    Messages:
    14
    what is ew? we must continue this discussion. We are the most active thing on this forum for a long time
     
  8. Eluded

    Eluded Haxor Official Server Admin

    Messages:
    132
    Wow ::D:
    This kind of thing should just be part of the in-game controls though.
    We should make it easier to add more kinds of hotkeys aside from just shift-1, shift-2 etc. for blocks
     
  9. ThePiemaster

    ThePiemaster Haxor

    Messages:
    20
    Yes the key bindings are part of the game. But making more macros, to select drill for instance, is cheating. Congrats on figuring how to do it, but you can't use it in games with a good conscious.
     
  10. nickkardash

    nickkardash Bison Rider

    Messages:
    14
    I do it this way every time i play in good conscious. i also use a mouse with extra buttons on the mouse to map the builder items too. these are advantages over someone who doesnt do that stuff. its not hacking, or altering anything. its just using resources and dedication to up my game. I dont have a damaged conscience for developing better ways to play that give me an edge and there really is no way to say that im not allowed to do it, because its all vanilla and the game cant know im doing it anyway so there is no way to detect it. and, i have posted it here, so if anyone really wanted to do the same thing they could have the same advantage. i consider it a feature that should be in the game already and since no one would do something about it , i did it myself