Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermitent behabiour with subscribebeyboard and subscribekey #119

Open
wirytiox opened this issue Nov 23, 2024 · 0 comments
Open

Intermitent behabiour with subscribebeyboard and subscribekey #119

wirytiox opened this issue Nov 23, 2024 · 0 comments

Comments

@wirytiox
Copy link

I've tried to make some simple macros that work well with subcribekeyboard. but when i tried to add logic to make shift+T work it just didn't work. seems like subcribekeyboard doesn't handle multiple keypress (that i know of) so i tried subscribing shift alone and using T from subcribekeyboard (not in the provided code) it showed a very weird behavior it would work but after restarting the script it would just not work. i also tried subcribekey to shift and t and it still did the same thing. i installed the driver and followed the tutorials in the repo but everything works but that small function. for some reason waiting seems to solve it. and it seems that when it shows this behavior is like shift is constantly pressesed. Like my normal keyboard would be constantly in shift mode even if no shift key is pressed. that is solved pressing shift in either keyboard (for it to solve it in the controled keyboard it has to have the script shuted down) avoiding the dumb macros. any idea what could be wrong in my code? I'll provide the important snippets and the full code. pardon for the messy this whole problem didn't gave me much time to tidy it.

shiftpress(state){
	global isshiftPressed := state

}

tpress(state){
    global isshiftPressed
	isTpressed := state
	
	if (isshiftPressed && isTpressed)
	{
		Run("*RunAs powershell.exe")
        return
	}
    if(isTpressed && !isshiftPressed){
        Run("powershell.exe")
    }
    


}

#Requires AutoHotkey v2.0

Persistent ; (Interception hotkeys do not stop AHK from exiting, so use this)
#include Lib\AutoHotInterception.ahk
::!game Rust::{!}game Rust{Enter}{!}title Juego al Rust sin chill {!}discord{Enter}
::!game cities::{!}game cities: skylines{Enter}{!}title Juego al Cities de chill {!}discord{Enter}
::!game lol::{!}game league of legends{Enter}{!}title Partiditas de chill {!}discord{Enter}
::!game cyberpunk::{!}game cyberpunk 2077{Enter}{!}title Juego Cyberpunk 2077 {!}discord{Enter}
::!game csgo::{!}game Counter Strike: global offensive{Enter}{!}title Juego CS:GO (soy una bestia) {!}discord{Enter}
::!game drg::{!}game deep rock galactic{Enter}{!}title Juego enanos galacticos minando {!}discord{Enter}
::!game astroneer::{!}game astroneer{Enter}{!}title Juego Astroneer de chill {!}discord{Enter}
::!game brotato::{!}game Brotato{Enter}{!}title Juego brotato uwu {!}discord{Enter}
::!game minecraft::{!}game minecraft{Enter}{!}title Juego mc eternal uwu {!}discord{Enter}
::puteadadross::Una cagada asquerosa, repelente, abyecta, vomitiva, mugrosa, maldita, diarreosa, estercolera, inmunda, malnacida, pudenda, apestosa, maloliente, cabrona, maricona, huevona, pendeja, tarada, cancerígena, jodida, culeada, gilipollesca, pelotuda, encamada, malnacida, retardada, atrasada, inútil, móngola, incestuosa, burda, estúpida, insulsa, putrefacta, traicionera, indigna, chupapollas, soplahuevos, esnifacojones, gueleculo, coprofágica, masca-morrones, infecta, cerda, nauseabunda, cochambrosa, cochina, verdulera, infame, ruin, rastrera, degradada, descerebrada, zopenca, zafia, puta, engreída, esquizofrénica, granulenta, infeliz, profana, calamitosa, deficiente, cretina, lela, ramera, fulana, calientaguevos, ridícula, petarda, pasmarote, fistro, desidiosa, puta, reputa, soputa, recontraputa, hija de puta, hija de un millón de putas, escupepitos, caradepedo, necrofílica, alientoamojón, lambe-bukaka, revuelcaleche, coñoesumadre y de su abuela, conchuda, culoroto, nalgas reventadas, tragasable, succionaditos, esfinterpartido, ojetedesilachado, sorbemocos, capulla, pelmaza, zoquete, masturbadora crónica, espuria, chupa-tampones, regluda, coprófaga, gerontofílica, turra, ojete, atorrante, tierrúa, pajúa, amamaguevos, onanista caradeconcha y MALA PELICULA.{Enter}
global AHI := AutoHotInterception()
global isshiftPressed
/*

to be continued...
*/
alt := false

GuiTriangle := Gui("-Caption +AlwaysOnTop -Border +LastFound +Disabled")

GuiTriangle.BackColor := "Green"
GuiTriangle.Add("Text", "w5 h5")  ; A tiny space for the triangle.
GuiTriangle.Opt("+Owner")
GuiTriangle.Show("x5 y5 NoActivate")  ; Top-left corner.
GuiTriangle.Hide()  ; Initially hidden.


createmygui() {
    global DDL
    Global MyGui
    MyGui := Gui("-Caption +AlwaysOnTop -Border +LastFound +Disabled")
    MyGui.Opt("+Owner")
    DDL := MyGui.Add("DDL", "vcbx w200 Choose", ["LOL", "CSGO", "Cyberpunk", "Rust", "Deep rock galactic", "teraria", "slime rancher", "astroneer"])

    PostMessage(0x0153, 1, 50, DDL)  ; Set height of selection field.
    PostMessage(0x0153, 0, 20, DDL)  ; Set height of list items.D
    MyGui.show("NoActivate")
}

createmygui1() {
    global DDL1
    Global MyGui1
    MyGui1 := Gui("-Caption +AlwaysOnTop -Border +LastFound +Disabled")
    MyGui1.Opt("+Owner")
    DDL1 := MyGui1.Add("DDL", "vcbx w200 Choose", ["Compartir pantalla", "ensordecerse", "abrir obs"])
    PostMessage(0x0153, 1, 50, DDL1)
    PostMessage(0x0153, 0, 20, DDL1)
    MyGui1.show("NoActivate")
}

OutputDebug("---------------------------------------------------------------")
keyboardID := AHI.GetKeyboardId(0x1A2C, 0x2D23)

AHI.SubscribeKeyboard(keyboardId, true, KeyEvent)



AHI.SubscribeKey(keyboardId, 42, true, shiftpress)
AHI.SubscribeKey(keyboardId, 20, true, tpress)
shiftpress(state){
	global isshiftPressed := state

}

tpress(state){
    global isshiftPressed
	isTpressed := state
	
	if (isshiftPressed && isTpressed)
	{
		Run("*RunAs powershell.exe")
        return
	}
    if(isTpressed && !isshiftPressed){
        Run("powershell.exe")
    }
    


}


KeyEvent(code, state) {
    ToolTip("Keyboard Key - Code: " code ", State: " state)
    global isshiftPressed
    if (code == 2 && state == 1) {
        Send "https://www.twitch.tv/wirytiox{Enter}"
    }   else if (code == 285 && state == 1) {
        Global MyGui
        if IsSet(MyGui) && MyGui {
            value1 := DDL.Value
            switch (value1)
            {
                Case 0:
                    MyGui.Destroy()
                case 1:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game league of legends{Enter}{!}title Partiditas de chill {!}discord{Enter}"
                        Sleep 50

                    }
                case 2:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game Counter Strike: global offensive{Enter}{!}title Juego CS:GO (soy una bestia) {!}discord{Enter}"
                        Sleep 50

                    }
                case 3:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game cyberpunk 2077{Enter}{!}title Juego Cyberpunk 2077 {!}discord{Enter}"
                        Sleep 50

                    }
                case 4:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game Rust{Enter}{!}title Juego al Rust sin chill {!}discord{Enter}"
                        Sleep 50

                    }
                case 5:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game deep rock galactic{Enter}{!}title Juego enanos galacticos minando {!}discord{Enter}"
                        Sleep 50

                    }
                case 6:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game terraria{Enter}{!}title tmodloader de chill {!}discord{Enter}"
                        Sleep 50

                    }
                case 7:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game slime rancher 2{Enter}{!}title slime rancher de chill {!}discord{Enter}"
                        Sleep 50

                    }
                case 8:
                    try {
                        Click , -266, 350, 1
                        Send "{!}game astroneer{Enter}{!}title Juego Astroneer de chill {!}discord{Enter}"
                        Sleep 50

                    }
            }
            MyGui.Destroy()
            MyGui := ""
        } else {
            CreateMyGui()
        }
            
    }  else if (code == 328 && state == 1) {
        Try DDL.Choose(DDL.Value + 1)
        Try DDL1.Choose(DDL1.Value + 1)
    }  else if (code == 336 && state == 1) {
        Try DDL.Choose(DDL.Value - 1)
        Try DDL1.Choose(DDL1.Value - 1)
    }  else if (code == 310 && state == 1) {

        Global MyGui1
        if IsSet(MyGui1) && MyGui1 {
            value2 := DDL1.Value
            switch (value2)
            {
                Case 0:
                    MyGui1.Destroy()
                case 1:
                    try {
    
                        Sleep 50
                        send "{LCtrl Down}{LAlt Down}{f24 Down}{LCtrl Up}{LAlt Up}{f24 Up}"
                    }
                case 2:
                    try {
                        Sleep 50
                        send "{LCtrl Down}{LAlt Down}{f23 Down}{LCtrl Up}{LAlt Up}{f23 Up}"
                    }
                case 3:
                    try {
                        Sleep 50
                        run "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OBS Studio\OBS Studio (64bit).lnk"
                    }
            }
            MyGui1.Destroy()
            MyGui1 := ""
        } else {
            CreateMyGui1()
        }
    }  else if (code == 3 && state == 1) {
        Send "https://kick.com/elwiry69420uwuomg{Enter}"
    }  else if (code == 4 && state == 1) {
        Send "https://www.youtube.com/channel/UC3yzEiM3bskIfOGzASIW_6Q{Enter}"
    }  else if (code == 309 && state == 1) {
        global alt, GuiTriangle
        alt := !alt  ; Toggle the value of alt
        if alt {
            GuiTriangle.show("NoActivate")  ; Show the green triangle
        } else {
            GuiTriangle.Hide()  ; Hide the green trianglex
        }
    }  else if (code == 325 && state == 1) {
        Send("{NumLock}")
    }  
}
@wirytiox wirytiox changed the title really weird behabiour with AHK script Intermitent behabiour with subscribebeyboard and subscribekey Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant