Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - marcusvdt

Pages: [1] 2 3 ... 11
1
If you want to trigger an event using Autoit, I posted an Autohotkey script that controls windows 8.1 netflix app, and I have it trigger events when it starts, stops and when you start and stop a movie as well,

This post has the AutoHotkey script, you can take a look and see an example of how to trigger an event with your autoit script
http://voxcommando.com/forum/index.php?topic=2145.msg18598#msg18598

note:: with my method the script needs to be in the main VC folder, if you wanted to put it in a different folder then you will need to add the file path

Thanks, I've found an example in your code. The syntax in autoit would be similar.
Btw, soon I'll probably port or adapt your Netflix script to autoit. No special reason, it's just easier to me to manage it later. Will need to translate all your commands, check what else I may need, etc. Thanks for providing the source code!

About this way of triggering events, honestly I did not notice yet this is possible. Wonderful!

Thanks guys!

2
James, yes I know!  :bonk

But as you can see in my video, such event gets triggered even when window.focus seem to fail.

But you are right, as I'll be using the autoit script to set the focus, then the "focused" event for that window truly means such window has been put in focus.
And I can double confirm also with the logic block.

Consistent enough!  ;)

3
I'm not sure the problem is related to various process of chrome or not. Maybe it is the issue as you mentioned of the window flashing (but it does not flash because the window in not actually minimized). Don't know.
I'll use an autoit script in the meantime, just not sure yet how my script will send a confirmation to VC. Will try something like an exit code or something. Or maybe I can trigger an event using the API, not sure yet.

Thanks for looking at it!


4
Thanks PegLegTV. While I was recording this video and writing this post, you posted a response which seems to have the same purpose of what I just made. Take a look below...

This is some of the data about the chrome window which I use in my video. In autoit, I can use a combination of any of these parameters below to make sure I'm attaching to the right window:
Title:   Google - Google Chrome
Class:   Chrome_WidgetWin_1
>>>> Visible Text <<<<
Chrome Legacy Window

The video below shows how VC's method is failing and confirming the reason is probably the existence of more than one process for chrome. Btw, the wiki mentions it can fail and I'm sure James already knows the exact situations where it can fail. I'm not complaining at all.

The video also shows how I can solve that situation with external scripting, but wouldn't like to go that path because it makes the stuff more complicated because then I would need to make my script to talk with VC and vice versa. Probably will not justify the effort. Also will need to keep track of external source code, etc, etc...
The interesting thing is that both VC and autoit scripting are using some windows api to get control of windows, so maybe James can find a way to implement different matching techniques? If not, that's fine anyway as I can workaround it with scripts as shown in the video.

https://youtu.be/GI0Z981PbMQ



5
I only noticed that behavior with chrome and I also believe in the same cause that you mentioned. The scripting language I'm used to program, autoit, needs the actual name of a window, ie "Untitled - Notepad" for notepad, so it can attach to such window. Actually it allows for other few things to match to a window, but none of the standard ways use the process name as James uses in VC. Then with autoit it is still possible to use other ways to enumerate all the available windows pertaining to a process and then one can attach to one of those windows.
Long story short, I'm mentioning autoit only because I suppose VC can have the same difficulty to attach to the correct window. What I used to do in autoit is to attach using what is more likely to result in the right window to be selected. But it depends on the target program.


6

In the beginning of the video I show how my last command works with the enhancement proposed by James. Thanks everybody!
But then, in the end of the video I show a weird behavior with window.focus. This is the problem that I noticed accidentally and have mentioned earlier in this thread. Am I doing anything wrong?

https://youtu.be/WUOzp_8vcG8

7
that is more than triple awesome ... I wanted to try this for ages .... but it is a while I have so little time :(

this bring three ideas
1. I will add to gems a thread called gems of the gems ... as in the french saying "crème de la crème" and this will be number 1
2. maybe a board like xml exchange, but will be html exchange so we can exchange or develop together an interface, standards ... etc.
3. originally my idea was to implement a command that scans the command tree and generate the web pages automatically ... this combined with CSS can create awesome interfaces on the fly. the bases for this already exist ... the routine inside VC that generate the help html ... if that html, have tags, and associated CSS it can be access through TCP webserver easily ...

VC community rocks :)
Yeah  ::wiggle! I've talked with James about my interest to do this some weeks ago. The payloads could be loaded in drop down boxes in the web pages. And for optimal user experience, we should be able to:
1. tag what groups we want to add to the html page. We probably don't need all the groups exported to the html page.
2. Create navigation menus on the html page so the commands are put together with some logic in mind. For example, all commands for the living room should be automatically place in a living room menu (sub page).
3. We should be able to choose what or how many payloads would actually be put in the proposed drop down. Commands that deal with huge number of payloads should be excluded to keep the web page easy to load. In fact I think we could maybe tag many individual commands to be excluded from the html page.

This is in my pending list together with many other things. My plan is to use autoit script and/or python to accomplish that. The tags as I mentioned above could be, for example, some specific strings that we can place in the name of groups and commands.
Let me know who are interested in this and maybe we can work together and make this happen sooner.

Thanks!

8
True! Now it is obvious!
I'll try it when I get to my computer. Now I am in the phone.

Thank you.
btw this is one of the reasons VC is so good, you still enjoy it!

9
Yeah, I like the idea of not having the need for the variable. I was already considering an eventual situation where two of the same command would cause problems with that variable. Would you mind posting an example of what you proposed?
I'm not in the computer now, but I will be testing this as soon as possible.

Thanks.

10
Thanks for the tip James. That is what it does. I pass the name of the process and the max number of loops that it can do. The max number of loops reflects half the delay between each loop, in seconds.
If the desired window gets in focus before the max loops has occurred, then I tell the user the program is in focus. If the max number of loops is achieved,  then a timeout has occured and the user is told.
hopefully we are talking the same thing,  but I am increasing the var while you thought about decreasing it?

11
Thanks guys!
I ended up with a command that can be used for confirming any program is in focus. You pass the the process name and the max # of loops in payloads. Now works like a charm!
For automating critical applications it is essential that the focus is reinforced and confirmed at every command. Windows applications sometime get the focus (ie anti virus update dialog pops up in the screen), so confirming the focus before sending commands to a window is desirable.

Thanks for the ideas! This is exactly the help that I was looking for! You rock big time!


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.7-->
<groupCollection open="True" name="Share">
  <commandGroup open="True" name="Launch Chrome" enabled="True" prefix="" priority="0" requiredProcess="" description="">
    <command id="733" name="open url with payload" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <if ifBlockDisabled="False" ifNot="True">
        <ifType>ProcessRunning</ifType>
        <ifParams>chrome&amp;&amp;</ifParams>
        <then>
          <action>
            <cmdType>Launch.RawParam</cmdType>
            <params>
              <param>{Path.PFx86}\Google\Chrome\Application\chrome.exe</param>
              <param>{1}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>TTS.SpeakSync</cmdType>
            <params>
              <param>Launching Chrome</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.Pause</cmdType>
            <params>
              <param>500</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
        </then>
        <else />
      </if>
      <if ifBlockDisabled="False" ifNot="False">
        <ifType>ProcessRunning</ifType>
        <ifParams>chrome&amp;&amp;</ifParams>
        <then>
          <action>
            <cmdType>Results.SetVar</cmdType>
            <params>
              <param>loopsfocus</param>
              <param>0</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.SetEventTimer</cmdType>
            <params>
              <param>2s</param>
              <param>FocusTest</param>
              <param>chrome</param>
              <param>10</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>OSD.ShowText</cmdType>
            <params>
              <param>{1}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>TTS.Speak</cmdType>
            <params>
              <param>Browsing to {PF.1}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
        </then>
        <else>
          <action>
            <cmdType>TTS.Speak</cmdType>
            <params>
              <param>I couldn't open Chrome</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>OSD.ShowText</cmdType>
            <params>
              <param>I couldn't open Chrome</param>
              <param>2000</param>
              <param>1</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
        </else>
      </if>
      <phrase>abrir site</phrase>
      <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\url.xml</payloadFromXML>
    </command>
  </commandGroup>
  <commandGroup open="True" name="Generic focus confirmation" enabled="True" prefix="" priority="0" requiredProcess="" description="">
    <command id="761" name="{1} focus test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <if ifBlockDisabled="False" ifNot="False">
        <ifType>(A)Contains(B)</ifType>
        <ifParams>{1}&amp;&amp;{1</ifParams>
        <then>
          <action>
            <cmdType>OSD.ShowText</cmdType>
            <params>
              <param>Can't check focus. Wrong use of my logics!</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.StopMacro</cmdType>
            <params />
            <cmdRepeat>1</cmdRepeat>
          </action>
        </then>
        <else />
      </if>
      <if ifBlockDisabled="False" ifNot="False">
        <ifType>(A)Contains(B)</ifType>
        <ifParams>{2}&amp;&amp;{2</ifParams>
        <then>
          <action>
            <cmdType>OSD.ShowText</cmdType>
            <params>
              <param>Can't check focus. Wrong use of my logics!</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.StopMacro</cmdType>
            <params />
            <cmdRepeat>1</cmdRepeat>
          </action>
        </then>
        <else />
      </if>
      <if ifBlockDisabled="False" ifNot="False">
        <ifType>ProgramFocused</ifType>
        <ifParams>{1}&amp;&amp;</ifParams>
        <then>
          <action>
            <cmdType>VC.StopEventTimer</cmdType>
            <params>
              <param>FocusTest</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>OSD.ShowText</cmdType>
            <params>
              <param>{1} is now focused</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.TriggerEvent</cmdType>
            <params>
              <param>FocusConfirmed</param>
              <param>{1}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.StopMacro</cmdType>
            <params />
            <cmdRepeat>1</cmdRepeat>
          </action>
        </then>
        <else>
          <action>
            <cmdType>Window.Focus</cmdType>
            <params>
              <param>{1}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.StopEventTimer</cmdType>
            <params>
              <param>FocusTest</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>VC.SetEventTimer</cmdType>
            <params>
              <param>2s</param>
              <param>FocusTest</param>
              <param>{1}</param>
              <param>{2}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>PY.ExecString</cmdType>
            <params>
              <param>result={Var.loopsfocus}+1</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>Results.SetVar</cmdType>
            <params>
              <param>loopsfocus</param>
              <param>{LastResult}</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
        </else>
      </if>
      <if ifBlockDisabled="False" ifNot="True">
        <ifType>(A)&lt;(B)</ifType>
        <ifParams>{Var.loopsfocus}&amp;&amp;{2}</ifParams>
        <then>
          <action>
            <cmdType>VC.StopEventTimer</cmdType>
            <params>
              <param>FocusTest</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>TTS.Speak</cmdType>
            <params>
              <param>I couldn't get {1} in focus, so stopping here.</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
        </then>
        <else />
      </if>
      <event>FocusTest</event>
    </command>
  </commandGroup>
</groupCollection>

12
with program variables such as {j} {i} {#M} and so on, can not be set, at least not in a way that I know of, when your are using
Code: [Select]
Results.SetVar j 30 then in order to use that variable you would have to call it using {Var.j} which the looping block can not see,

heres your command with OSD showing what I mean,
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.7-->
<command id="702" name="Chrome já em foco" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This should stop the loop on the other command.">
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>j</param>
      <param>31</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>program variable j = {j}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>Results.SetVar variable j = {Var.j}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>Focused.chrome</event>
</command>
I guess I can not assign a value to the j variable that is used on the for loop enen if I try to do that inside the loop. It seems I can only read it. Will test it tomorrow, but if I'm right,  then I don't see any way of breaking the loop.

Quote
looking at your first command, it seems to just count down for 30 seconds before moving on, it sounds like your are trying to get it to stop counting down once the window is focused correct?
yes, exactly. As per what I see on the log, it can't be done since an event never gets registered while the loop is running. Instead, I guess any events that occur while the loop is running will be queued and processed only after the loop finishes.

I think I will have to try something else tomorrow.

Thanks.

13
wow, hard stuff to open a website  ::bugeyes


Why did you not use the command line parameter with the launch action?

eample code:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.1-->
<command id="688" name="open url with payload" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Launch.RawParam</cmdType>
    <params>
      <param>{Path.PFx86}\AppData\Local\Google\Chrome\Application\chrome.exe</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>opening {PF.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>opening {PF.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>open site</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\url.xml</payloadFromXML>
</command>


I think this is even better  ;)
thanks, yes that's better,  but still does not guarantee that chrome is in focus. If another software takes the focus from chrome,  then the remaining actions could be sent to another window. In some cases I'll be using the same type of commands for things not so simple as opening a Web page, hence the reason for developing a method in which I can trust to make sure what is the window I'm sending the keyboard actions to.  By the way, the window.focus action did not work for chrome anyway (using windows 8.1 and latest version of Chrome).
I'd like to avoid having to use an external script for this purpose.

14
Output. I'm confused with the sequence the things appear in the log. Chrome was already opened and in focus since loop iteration 3, but then lost the focus and in the end of the macro it was not in focus anymore. The event Focused.chrome appeared only near the end of the sequence.

15
This is the command that I expected to set j variable to a value that would break the loop block above. Unfortunatelly the event appears only after the loop block has finished.
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.7-->
<command id="702" name="Chrome já em foco" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This should stop the loop on the other command.">
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>j</param>
      <param>31</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>Focused.chrome</event>
</command>


Pages: [1] 2 3 ... 11