Sign in to follow this  
Followers 0
Palestinian

Blocked ControlSend

24 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I ran the example, clicked on my desktop then clicked space, it didn't work, Win8 64x

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That doesn't seem to be working at all, removing the Plus sign makes it work as a normal hotkey, still gets blocked.

Edited by Palestinian

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

Can't believe I forgot what the plus sign was, my bad.

The game is League of Legends.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Sending Space.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

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.

Share this post


Link to post
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.

Share this post


Link to post
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.

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

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      Okay so I am not sure if I can do this or not with the code I currently have but, I would like to send lastname and the first name with a comma inbetween. 
      so it would look like "last name,first name" 
      right now I just have it sending the last name.
      any help or sugestions are appreciated. 
       
      $r = 1 Local $aArray = _Excel_RangeRead($oExcel, Default, Default) For $i = 1 To UBound($aArray) - 1 ;$i =0 Start from row A $sR1 = $aArray[$i][0] ;status $sR2 = $aArray[$i][1] ;first name $sR3 = $aArray[$i][2] ;Last name $sR5 = $aArray[$i][5] ;Email Address WinWaitActive ("[CLASS:MGUIWin]") Sleep (100) ControlSend("[CLASS:MGUIWin]", "", "Edit2", $sR3, & @CR) $r = $r + 1 If $r > $sBox Then Exit Endif Next  
    • initspawn
      By initspawn
      Hello,
      I've been trying to automate a process to check in the GUI of a Java program for a certain condition. When I use the Autoit Window information tool I don't get anything under the control tab, which seems to be normal for a Java program. I've been able to automate what I need using ControlSend and checking for the condition using ImageSearch but the Java program will not accept ControlSend unless it is the active window. I'd like to run the script while the window is inactive so I can still use the PC but haven't been able to come up with a solution other than a virtual machine. I even tried sysinternals desktops to create a second virtual desktop but that just causes WinActivate to return a failure after you switch to another virtual desktop. Does anyone have any ideas for getting a window to think its active when its not or an alternative to ControlSend that may work?
      Thanks. 
    • Wingens
      By Wingens
      I am trying to send a CTRL+G to a command prompt.
      It should send something like ^G this to the prompt but instead it sends only the G.
      To give more insight into what I am trying to create here:
      At my work we need a programm to open de cashdrawer using the commandprompt, i created a gui where you can set the COM-port to wich the command should be send.
      This works the COM-port setting is writting in a .ini file to be used every time the program opens.
      I have attached the files to the post.
      Hope someone can help me.
       
       
       
      open.zip
    • killertone
      By killertone
      Greetings!
      I have been trying to get send to this textarea on a website a message through ControlSend because _IEFormElementSetValue doesnt work on it, so i get the hwnd of the IE window then do the ControlSend to the window, and the message it sends doesnt type some of the letters.
      The textarea
      <textarea style="overflow:hidden;height:undefinedpx;" class="form-control input-sm" placeholder="Add a comment" rows="1" data-reactid=".0.3.2.1.2.0.$view.8.1.0.0.1"></textarea> How im getting the textarea:
      $comment_area = _IETagNameGetCollection($oIE,"textarea") for $element in $comment_area if $element.placeholder = "Add a comment" Then _IEAction($element,"focus") Sleep(1500) ;_IEFormElementSetValue($element,$comment_list[$random_index]) ;_IEFormSubmit($element) ControlSend($hIE,"","[CLASS:Internet Explorer_Server; INSTANCE:1]",$comment_list[$random_index],1) ;Send("{ENTER}") Sleep(3000) ;Hacer que sea random EndIf Next When i use _IEFormElementSetValue  it changes the text on the box, but it doesn't change the value or something because when i send an Enter key it doesn't submit the message (I Also tried _IEFormSubmit)
      With ControlSend it does send it but corrupted, for example: Message: Pretty nice Result: ety nice
      Also i know the element is the actual one im referring because if i use _IEAction($element,"focus") it focuses the one i want.
      Any help appreciated!
    • OrangeCoder
      By OrangeCoder
      Hey Guys - I am trying to write a very simple script that just types a value into ONE field and presses and next
      That's it!
      Here is what I am trying to do:
      I have a software product that used Installshield to package it - I wrote a response file per installshield directions /  for the software and it automated almost everything except one window... sadly the company that makes the software doesn't want to help, installshield won't help since I don't have a license . So I am trying to write and autoit script to fill in the one window that doesn't get recorded in the response file to finish the installation
      My write activated the window but when I follow it with a send() it doesn't work
       
      here is what I have
      WinActivate("Server Information") Send("xx-xxx-xx") Send("!n") Send("{SPACE}") any ideas ?