AutoInput Hold onscreen until instructed to release.

Discussion in 'AutoApps' started by pocget, Oct 24, 2019.

  1. pocget

    pocget New Member

    Joined:
    Oct 24, 2019
    Messages:
    3
    Likes Received:
    0
    First post here so please excuse any formatting mistakes. I also posted this on Reddit so I'll include a link to that post here.

    Anyways, to whoever ends up reading this here is my issue: I am trying to map volume up to hold a press on an onscreen location until I release volume up. This is for the app Discord which has a Push-To-Talk button but no way to physically map it. Basically I want my volume up key to work like a Walkie-talkie.

    What I have so far is a profile that suppresses the volume up key while the "Push to talk button" is on screen using an AutoInput UI State, as an exit task it re-enables it. This stops my volume from being cranked up while using the app, but it works normally when I'm not.

    I have another profile setup to activate when volume up is pressed and I can limit its tasks to running if the first profile is active via %PACTIVE. And this is where I am stuck. I dont know how to hold down the button.

    I can get the button to click, long click, and even loop back and keep pressing it, but this rapid fire presses it and doesn't actually work, I need the on screen button held.

    As a side note to anyone attempting to help with this, there is a variable (%aikeyaction) that is 0 when volume up is depressed and 1 when it is not, that seems like it could help and its what i used to loop, but again a loop didn't work.

    If anyone can help with this I would appreciate it, I'll be eagerly awaiting replies as I am lost at this point.

    Thanks,
    pocget.
     
  2. pocget

    pocget New Member

    Joined:
    Oct 24, 2019
    Messages:
    3
    Likes Received:
    0
    On the off chance that anyone googles "Discord Tasker Push-To-Talk" and finds this I have a downgraded version of this that uses toggle mute rather than PPT, figured I would share while I wait for my savior to answer my original post.

    Code (Text):
    If the Discord notification is there, disable the headset button (#79 in my case), when its gone, re-enable it.
    -------------------------------------------------------------------------------------------------------------------------
        Profile: Discord_Notification (5)
            State: AutoNotification Intercept [ Configuration:Notification App: Discord
        Notification Title: Connected
        Get All Fields : true ]
        Enter: PTT_Enable (6)
            A1: AutoInput Modes [ Configuration:Key Suppress: Enable
        Manual Key Codes: 79 Timeout (Seconds):2 ]
     
        Exit: PTT_Disable (11)
            A1: AutoInput Modes [ Configuration:Key Suppress: Disable
        Manual Key Codes: 79 Timeout (Seconds):2 ]
            A2: Variable Set [ Name:%DMUTED To:Mute Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
    -------------------------------------------------------------------------------------------------------------------------



    If the headset is plugged in set a variable to 1, set it to 0 when unplugged
    -------------------------------------------------------------------------------------------------------------------------
        Profile: Headset_Plugged (38)
            State: Headset Plugged [ Type:Any ]
        Enter: HSVar1 (41)
            A1: Variable Set [ Name:%HSVAR To:1 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
     
        Exit: HSVar2 (42)
            A1: Variable Set [ Name:%HSVAR To:0 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
    -------------------------------------------------------------------------------------------------------------------------


    Presses any button that contains "mute" on the discord notification, catches both 'mute' and 'unmute' the two states.
    -------------------------------------------------------------------------------------------------------------------------
        Profile: Toggle_Mute (7)
            Event: AutoInput Key [ Configuration:Keys: Headsethook
        Key Action: Key Down
        Manual Key Codes: 79 ]
        Enter: Toggle_Mute (10)
            A1: AutoNotification Actions [ Configuration:Notification Apps: Discord
        Button Text: mute (case ins) Timeout (Seconds):20 ] If [ %PACTIVE ~ *,Discord_Notification,* ]
            A2: AutoNotification Query [ Configuration:Notification Apps: Discord
        Title: Connected Timeout (Seconds):20 ]
            A3: Variable Set [ Name:%DMUTED To:%anbutton2text() Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
            A4: Flash [ Text:%DMUTED Long:Off ]
            A5: Perform Task [ Name:BeepIfMuted Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]
    -------------------------------------------------------------------------------------------------------------------------
     
    This is the task called in Toggle_Mute, it beeps every 5 seconds as long as my discord is muted and my headphones are plugged in
    -------------------------------------------------------------------------------------------------------------------------
        BeepIfMuted (18)
         A1: Beep [ Frequency:3000 Duration:500 Amplitude:15 Stream:0 ] If [ %DMUTED ~ Unmute & %HSVAR ~ 1 ]
         A2: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ]
         A3: Goto [ Type:Action Number Number:1 Label: ] If [ %DMUTED ~ Unmute ]
       

    Known issue is if you hit the mute button on your phone rather than using the headset it breaks a couple variables as they update on physical button press, but I'm not to worried about that. EDIT to this part, it also doesn't work when the phone is locked but the app keeps it unlocked.

    Other than that I'm still hoping someone can come in with a solution to my original problem just thought in would share this in the meantime.
     
    Last edited: Oct 25, 2019
  3. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Unfortunately I don't think there's a way to keep holding a "virtual finger" on the screen like that with Tasker, sorry :(
     
  4. pocget

    pocget New Member

    Joined:
    Oct 24, 2019
    Messages:
    3
    Likes Received:
    0
    Drats, guess I'll have to refine my second work around script. Thanks for the reply saves me a lot of time searching.
     

Share This Page