Sign in to follow this  
Followers 0
Remixed

Need help with hotkey to rebind my Push-To-Talk Key

2 posts in this topic

Hey, I'm fairly new to Autoit. I am trying to get Autoit to press F11(Xsplit PPT key) when I press my Mouse4(X1) button. This is what I have so far and I'm not sure what else to do. I looked into the function _IsPressed and the send function. My script is telling me that WEnd on the last line is giving me an error. Any help would be appreciated, thanks!

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.1
 Author:         

 Script Function:
    Turns on Push to talk button for Xsplit.

#ce ----------------------------------------------------------------------------

#include <Misc.au3>
; Press Esc to terminate script, Pause/Break to "pause"
Global $g_bPaused = False

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{X1}", "PPT")

Func Terminate()
Exit 1
EndFunc

Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
 EndFunc

Func PPT()
$pressed = 0
While 1
    If _IsPressed("05") Then
        If Not $pressed Then
            ToolTip("PPT is turned on")
            Send("{F11}")
            $pressed = 1
         EndIf
         Sleep(250)
         EndFunc
      WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can't rebind the key directly in XSplit?

As far as your code, I would imagine its because you put EndFunc before your WEnd.  Also you have two If statements and only a single EndIf.

But I also think what you want to do here is better to do without a loop, as if your in your loop  your other functions are not going to work.

The last time I did a "toggle" I handled it like this.

If $nMsg = $Button13 Then
    $sound += 1
    If Mod($sound, 2) = 0 Then
        SoundPlay("")
        Else
        SoundPlay(@TempDir & "\miketyson.mp3")
        EndIf
EndIf

In your case you would strip off the first if statement and can put that in your function.  Something like this perhaps.

 

Func PPT()
$vPPT += 1
If Mod($vPPT, 2) = 0 Then
Send("{F11}")
Tooltip("PPT is ON")
Else
Send("{F11}")
Tooltip("PPT is OFF")
EndFunc

This is assuming you have F11 set to toggle PPT, if you need to hold it down you would need some slightly different commands, still I think much of what you need to do you can do from XSplit itself to help make your code easier to manage.  Also you may have already paid for XSplit and that is fine, but I left that program a while back from OBS (Open Broadcaster) and have not looked back as its a great free alternative.

Edited by ViciousXUSMC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0