Jump to content

Blocked ControlSend


Go to solution Solved by AutID,

Recommended Posts

Hello everyone,

Someone once posted asking for help on how to Play/Pause VLC media player using hotkeyset, I made a quick script for it and it works like charm, unless a certain application window is having focus.

As many of you may have already guessed, the application window is indeed a game client, however I'm not looking into animating the game or ultering it in any way, I simply want to be able to Pause/Play my songs while playing because I normally have voice chat active and sometimes friends talking, so having a quick way to pause the game instead of Alt+Tab is way more convenient.

I do not want anyone to write the script for me, I do not want anyone posting script snippits that might be used to interact with games, I simply want to know if it's possible to work around the ControlSend block, if there is I will figure it out by myself, I already tried few methods and they all failed, I don't wanna keep trying if it's impossible to do, a simple yes or no will do, thank you in advance.

 

Muhammad

Link to comment
Share on other sites

That indeed is a nice and well coded UDF, however it doesn't work.

if $msg = $pause_button Then
            
    _GUICtrlVLC_Pause($vlc1)
EndIf

 

Pause is triggered by a button click in the example, not even a hotkey, setting a hotkey for that function sends me back to the blocked ControlSend issue.

I was thinking about creating a small GUI with Play/Pause button, but the game's on top properities overrides AutoIt's

Link to comment
Share on other sites

That was Shift and Space.

If hotkeys are being blocked then I guess the games anti automation will interfere with other functions too.

If it were me, I'd complain to the game dudes that they are interfering with processes on your computer that have nothing to do with their game.

EDIT:

For the record, what game is blocking the normal operation of your unrelated autoit scripts?

Maybe other people who use that game can test.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

What about putting LoL as topmost, giving focus to VLC and sending spacebar, then refocusing LoL?
There would be a small timespace that your input would be moved to VLC, but that could be mitigated with blockinput.

Edited by Sori

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Link to comment
Share on other sites

So to clarify.

That UDF works fine and with hotkey on VLC player until you are running that game, then it does not work?

 

Works perfectly fine until the game is running, even if the game launcher gets focus the hotkey is blocked.

What about putting LoL as topmost, giving focus to VLC and sending spacebar, then refocusing LoL?

There would be a small timespace that your input would be moved to VLC, but that could be mitigated with blockinput.

 

And how would I do that without Alt+Tab and without a working hotkey when the game is focused?

Link to comment
Share on other sites

There are ways to get hotkeys.
But to further the discussion... What method would you be using to stop VLC?

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Link to comment
Share on other sites

Help me understand.

You want to be active in LoL.

Listening to your music.

A friend starts saying something, so you press spacebar.

This will cause VLC to pause and you have a conversation with your friend.

Is that all correct?

 

If you want to bypass the lock that LoL has on your keyboard, you'll have to implement a form of hotkey.

I would rather suggest... maybe voice commands?

You're pausing VLC in order to chat, hence you're using a mic.

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Link to comment
Share on other sites

Correct, that is exactly what I want to do.

Voice commands sounds nice, and I could actually try using windows speech recognition, I'll have to test it tomorrow and hopefully get it to work, thanks for the suggestion mate, and thank you JohnOne for the help.

Link to comment
Share on other sites

Windows offers a nice program called Windows Speech Recognition Macros that you can look into. I've used it with autoit before.

?do=embed#entry1145598'' frameborder='0' data-embedContent>>

Or you can dive into the deep end of the pool and mess with SAPI.

This is a crude program I threw together but never really finished.

Maybe you can get it going correctly.

#include <File.au3>
#include <Misc.au3>
#include <Timers.au3>

;Only allow one instance of the program to run.
If _Singleton("Voice Commands", 1) = 0 Then
    Exit
EndIf

Global $hypothesis

Global $h_Context = ObjCreate("SAPI.SpInProcRecoContext")
Global $h_Recognizer = $h_Context.Recognizer ;The ISpRecognizer interface enables applications to control aspects of the speech recognition (SR) engine
Global $h_Grammar = $h_Context.CreateGrammar(1) ;creates an SpRecoGrammar object
$h_Grammar.Dictationload ;loads a dictation topic into the SpRecoGrammar object and the SR engine

;Choose a method of recognition
;$h_Grammar.DictationSetState(1) ;dictation on
;$h_grammar.CmdSetRuleIdState(0, 1) ;Command and Control on

;C & C requires a list of commands in XML format
;$h_grammar.CmdLoadFromFile("") ;Loads C&C keywords

;Create a token for the default audio input device and set it
Global $h_Category = ObjCreate("SAPI.SpObjectTokenCategory")
$h_Category.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\")
Global $h_Token = ObjCreate("SAPI.SpObjectToken")
$h_Token.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\")
$h_Recognizer.AudioInput = $h_Token

Global $i_ObjInitialized = 0

Global $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_")
If @error Then
    ConsoleWrite("ObjEvent error: " & @error & @CRLF)
    $i_ObjInitialized = 0
Else
    ConsoleWrite("ObjEvent created Successfully!" & @CRLF)
    $i_ObjInitialized = 1
EndIf

While $i_ObjInitialized
    Sleep(1000)
    ;Allow the Audio In to finalize processing on the last second capture
    $h_Context.Pause
    ;Resume audio in processing
    $h_Context.Resume
    ;Reset event function allocation (what is this? I think its garbage collection or something, needs clarification)
    $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_")
WEnd

Func SpRecEvent_Hypothesis($StreamNumber, $StreamPosition, $Result)
    ConsoleWrite("Hypothesis(): Hypothized text is: " & $Result.PhraseInfo.GetText & @CRLF)
    $hypothesis = $Result.PhraseInfo.GetText
EndFunc   ;==>SpRecEvent_Hypothesis

;Voice command is recognized
Func SpRecEvent_Recognition($StreamNumber, $StreamPosition, $RecognitionType, $Result)
    ConsoleWrite($RecognitionType & "||" & $Result.PhraseInfo.GetText & @CRLF)
    CheckCommands($Result.PhraseInfo.GetText)
EndFunc   ;==>SpRecEvent_Recognition

Func SpRecEvent_SoundStart($StreamNumber, $StreamPosition)
    ConsoleWrite("Sound Started" & @CRLF)
EndFunc   ;==>SpRecEvent_SoundStart

Func SpRecEvent_SoundEnd($StreamNumber, $StreamPosition)
    ConsoleWrite("Sound Ended" & @CRLF)
EndFunc   ;==>SpRecEvent_SoundEnd

Func CheckCommands($spokenWords)
    If $spokenWords = "" Then
        ;Do some stuff here
    EndIf
EndFunc   ;==>CheckCommands
Edited by Sori

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Link to comment
Share on other sites

 

Windows offers a nice program called Windows Speech Recognition Macros that you can look into. I've used it with autoit before.

?do=embed#entry1145598'' frameborder='0' data-embedContent>>

Or you can dive into the deep end of the pool and mess with SAPI.

This is a crude program I threw together but never really finished.

Maybe you can get it going correctly.

#include <File.au3>
#include <Misc.au3>
#include <Timers.au3>

;Only allow one instance of the program to run.
If _Singleton("Voice Commands", 1) = 0 Then
    Exit
EndIf

Global $hypothesis

Global $h_Context = ObjCreate("SAPI.SpInProcRecoContext")
Global $h_Recognizer = $h_Context.Recognizer ;The ISpRecognizer interface enables applications to control aspects of the speech recognition (SR) engine
Global $h_Grammar = $h_Context.CreateGrammar(1) ;creates an SpRecoGrammar object
$h_Grammar.Dictationload ;loads a dictation topic into the SpRecoGrammar object and the SR engine

;Choose a method of recognition
;$h_Grammar.DictationSetState(1) ;dictation on
;$h_grammar.CmdSetRuleIdState(0, 1) ;Command and Control on

;C & C requires a list of commands in XML format
;$h_grammar.CmdLoadFromFile("") ;Loads C&C keywords

;Create a token for the default audio input device and set it
Global $h_Category = ObjCreate("SAPI.SpObjectTokenCategory")
$h_Category.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\")
Global $h_Token = ObjCreate("SAPI.SpObjectToken")
$h_Token.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\")
$h_Recognizer.AudioInput = $h_Token

Global $i_ObjInitialized = 0

Global $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_")
If @error Then
    ConsoleWrite("ObjEvent error: " & @error & @CRLF)
    $i_ObjInitialized = 0
Else
    ConsoleWrite("ObjEvent created Successfully!" & @CRLF)
    $i_ObjInitialized = 1
EndIf

While $i_ObjInitialized
    Sleep(1000)
    ;Allow the Audio In to finalize processing on the last second capture
    $h_Context.Pause
    ;Resume audio in processing
    $h_Context.Resume
    ;Reset event function allocation (what is this? I think its garbage collection or something, needs clarification)
    $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_")
WEnd

Func SpRecEvent_Hypothesis($StreamNumber, $StreamPosition, $Result)
    ConsoleWrite("Hypothesis(): Hypothized text is: " & $Result.PhraseInfo.GetText & @CRLF)
    $hypothesis = $Result.PhraseInfo.GetText
EndFunc   ;==>SpRecEvent_Hypothesis

;Voice command is recognized
Func SpRecEvent_Recognition($StreamNumber, $StreamPosition, $RecognitionType, $Result)
    ConsoleWrite($RecognitionType & "||" & $Result.PhraseInfo.GetText & @CRLF)
    CheckCommands($Result.PhraseInfo.GetText)
EndFunc   ;==>SpRecEvent_Recognition

Func SpRecEvent_SoundStart($StreamNumber, $StreamPosition)
    ConsoleWrite("Sound Started" & @CRLF)
EndFunc   ;==>SpRecEvent_SoundStart

Func SpRecEvent_SoundEnd($StreamNumber, $StreamPosition)
    ConsoleWrite("Sound Ended" & @CRLF)
EndFunc   ;==>SpRecEvent_SoundEnd

Func CheckCommands($spokenWords)
    If $spokenWords = "" Then
        ;Do some stuff here
    EndIf
EndFunc   ;==>CheckCommands

 

I did not know about the micros, thats pretty interesting to look at, however the speech recognition/voice commands is off the list since music will be playing and voice recognition won't recognize the speech.

Try elevating you programm.

 

I will try that when I get home, thank you.

Link to comment
Share on other sites

since music will be playing and voice recognition won't recognize the speech.

 

No headphones?

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Link to comment
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
 Share

×
×
  • Create New...