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

    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf  
    • magmet00
      By magmet00
      Do you have a working imagesearch.au3 with working dll?
      and how can i gethandle and send keyboard/mouse commands to hidden d3d window?
       
      i have tried imagesearch2015 but im getting dll error every time and tried older imagesearchs too in forum what i found.
      i have tried many things to send commands to hidden/background d3dwindow still nothing works.
      Can you help me please?
       
    • Guy_
      By Guy_
      Was testing ControlSend("My Window Name", "", "", "^c") vs the normal Send("^c") or _SendEx("^c") to copy selected text from a window...
      In Windows, I have a setting that when I click the Ctrl key only, my mouse pointer is "highlighted" [that I could of course disable].
      If I use Send("^c"), or do this manually, the mouse pointer is never highlighted, as I wish it to be.
      With ControlSend it *does* highlight...
      I thought that maybe the Ctrl key goes up a few ms too soon in that one and increased AutoItSetOption("SendKeyDownDelay", 5) to way higher, but it doesn't make a difference.
      As it doesn't seem possible to do "^ down", could it be prevented in some way?
      Beside the slight annoyance, it simply alerted me that these seem to work differently [and of course, they are different].
      I also get the early impression that ControlSend [to copy] seems in no way quicker to get something on the clipboard, maybe even slower?
      Thanks 
    • SkysLastChance
      By SkysLastChance
      How would I go about writing a IF Then statement if the conrol send fails?
      Run ("Notepad.exe") WinWaitActive ("Untitled - Notepad") ControlSend("Untitled - Notepad", "", "Edit1", ("Provider Practice Record")) I have been running into lag alot. So my script has been missing input. I would like to be able to have it retry to put in "Provider Practice Record" if it misses. 
      I am assuming  a if then statement is what I need but I am not sure what ControlSend will return if it tries to send to Edit1 and it is not there. 
      Or do I need to just add a timeout? 
       
    • 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