Author Topic: Hook and monitoring programs... How?  (Read 10457 times)

0 Members and 1 Guest are viewing this topic.

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Hook and monitoring programs... How?
« on: July 04, 2015, 03:12:43 PM »
Hello everyone!
There is a problem: I have mouse with Xbuttons and after i press XButton1 i  talk in Team speak... In Hook settings is monitoring clicks of mouse, and then i push the XButton1 VC go to standby mode(i done macros this triggers). But then Hook monitoring mouse clicks there are many history in VC and also freezing mouse movements... After i write macros then focus in VC(unfocused.* and focused.*) changing do checking (Process is running ? ts3client_win64) if run do HookEnabled else HookDisable... And also checking then XButoon1 is Up... But after some time Hook don`t work(don`t monitoring mouse clicks). There are my group "Hook":
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.1-->
<commandGroup open="True" name="Hook" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="221" name="Launch Hook" enabled="true" alwaysOn="True" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Hook.Enable</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
  <command id="199" name="Monitoring of Hook" enabled="true" alwaysOn="True" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>ProcessRunning</ifType>
      <ifParams>ts3client_win64&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Hook.Enable</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Hook.Disable</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>focused.*</event>
    <event>Hook.Mouse.Up.XButton1</event>
  </command>
  <command id="190" name="Hook Vc.Stanby" enabled="true" alwaysOn="True" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>ProcessRunning</ifType>
      <ifParams>ts3client_win64&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>VC.Standby</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>Hook.Mouse.Down.XButton1</event>
  </command>
  <command id="206" name="Hook Vc.On" enabled="true" alwaysOn="True" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>ProcessRunning</ifType>
      <ifParams>ts3client_win64&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>VC.On</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>Hook.Mouse.Up.XButton1</event>
  </command>
</commandGroup>

Question: How monitoring programs status in VC in background mode for example Team Speak and return parameter... Then Team Speak is off Hook disable then on enable then changing status of program then and changing parameter and Hook disable/enable.
Or simply then run TS or TS already running Hook is enable then TS shutdown or off Hook is disable...

Sorry my bad English. Thanks.
« Last Edit: July 04, 2015, 03:41:14 PM by Slalomen »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Hook and monitoring programs... How?
« Reply #1 on: July 05, 2015, 10:00:13 AM »
Do you really want to monitor if TeamSpeak is running, or do you actually want to monitor is TeamSpeak is focused?

If you want to enable the Hook plugin only when TeamSpeak is focused, then this is much easier to do, and much less work for VC.

The way you are doing it now, every time you press or release the mouse, VC must scan all running processes to see if TeamSpeak is running.  This is creating too much work for the PC.  This is probably why you see freezing.

You might also want to just leave VC in standby mode while TeamSpeak is running instead of switch back and forth between On and Standby every time you click a mouse.  You can still give VC commands while you are in standby mode by using a prefix.

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #2 on: July 05, 2015, 01:14:22 PM »
Yep really want to monitor TeamSpeak running, because i use VC then i gaming and use also TS... Hook use for switch mode of VC. For examle i play in game and use VC for commands in game and in this time TS is running and i also can speech with friends...

If its possible in VC monitoring the status of programs?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Hook and monitoring programs... How?
« Reply #3 on: July 05, 2015, 07:02:33 PM »
Yes, there are several ways.

A Python script that checks if the process is running in a separate thread is probably safest.

Download the Python script that is attached to this message (processRunningCheck.py) and place it in your VoxCommando\PY folder.

You will need to enable the Python plugin in VoxCommando.

Then you can change your command group to:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.2-->
<commandGroup open="True" name="Hook" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="190" name="Hook VC.Standby" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.Standby</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Hook.Mouse.Down.XButton1</event>
  </command>
  <command id="206" name="Hook VC.On" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.On</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Hook.Mouse.Up.XButton1</event>
  </command>
  <command id="207" name="Load Python script" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\processRunningCheck.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
</commandGroup>

---

The Python script will be executed automatically when you first launch VoxCommando. It will check the current status of the 'ts3client_win64' process every 5 seconds. You can edit the timing if you want.

1. When process running changes to "True", the Python script will enable the Hook plugin.

2. When process running changes to "False", the Python script will disable the Hook plugin.

3. Also, if the status of the process changes, the script will trigger a "True" event in VoxCommando (if process is now running) or a "False" event (if process is now quit). You do not need to use the event, but it is there just in case it is helpful for you or for someone else who wants to adapt the Python code. You will see these events in the History window.

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #4 on: July 05, 2015, 07:27:30 PM »
Thanks very much... Maybe I soon start learn this language... Very interesting! Thanks!

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #5 on: July 05, 2015, 07:48:50 PM »
Hmm... TS is running then i do full restart of VC, and yes py file load and then after 5 sec checked and VC write Hook enable , but Hook don`t work, in plugins chekboks of Hook is active, not understand why Hook don`t work((( And then after i shut down TS this in logs:

7/6/2015 1:56:48 AM   652   [vcevent] Process.ts3client_win64.False

7/6/2015 1:56:48 AM   665   action repeat set to: 1
7/6/2015 1:56:48 AM   665   Action:  Hook.Disable -
7/6/2015 1:56:48 AM   665   [action] Hook.Disable:

7/6/2015 1:56:48 AM   696   Action ERROR: System.ComponentModel.Win32Exception (0x80004005): Invalid hook handle
   в MouseKeyboardActivityMonitor.WinApi.Hooker.ThrowLastUnmanagedErrorAsException()
   в MouseKeyboardActivityMonitor.WinApi.Hooker.Unsubscribe(Int32 handle)
   в MouseKeyboardActivityMonitor.BaseHookListener.Stop()
   в MouseKeyboardActivityMonitor.BaseHookListener.set_Enabled(Boolean value)
   в vcPlugin.ctlMain.checkBoxEnabled_CheckedChanged(Object sender, EventArgs e)
   в System.Windows.Forms.CheckBox.OnCheckedChanged(EventArgs e)
   в System.Windows.Forms.CheckBox.set_CheckState(CheckState value)
   в System.Windows.Forms.CheckBox.set_Checked(Boolean value)
   в vcPlugin.ctlMain.setEnabled(Boolean isEnabled)
   в vcPlugin.Plugin.doAction(String[] parsedActions, String[] parsedParams)
« Last Edit: July 05, 2015, 07:59:23 PM by Slalomen »

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #6 on: July 05, 2015, 08:10:16 PM »
There is problem in then TS already running  and i run VC py script work incorrect or don`t work, but if run VC is first and after run TS script work good... Very bad but i don`t understood py language yet((( Pls help is it possibly...
« Last Edit: July 05, 2015, 08:12:50 PM by Slalomen »

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #7 on: July 05, 2015, 08:30:27 PM »
Modify some commands in VC, now then VC started automatically Hook switch in disable mode, and after then loaded the script and checking after 5 sec then Hook is enable... And this work!)) But i want know how correct the py script what work good this out my change... I already know html and php , maybe i can change and py script... Thanks!
« Last Edit: July 05, 2015, 08:33:18 PM by Slalomen »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Hook and monitoring programs... How?
« Reply #8 on: July 05, 2015, 09:27:56 PM »
We will investigate the problem further.

For now, please try the following:

In your Hook plugin settings, make sure that Hook is disabled by default. (Save the settings).

Replace the command that loads the python script with this command:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.2-->
<command id="207" name="Load Python script" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecFile</cmdType>
    <params>
      <param>PY\processRunningCheck.py</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Hook.Enable</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Hook.Disable</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>VC.Loaded</event>
</command>

And then restart VoxCommando.

Does this solution work properly for you? (Or is this the solution that you have used already?)
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Hook and monitoring programs... How?
« Reply #9 on: July 05, 2015, 09:46:14 PM »
@Slalomen: are you using a laptop with a track pad and an external mouse attached as well?  In other words, do you have two mice on your system?  I think the hook plugin may have some difficulty in initializing the hook for mouse clicks when you have 2 mice.  I need to do some tests.

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #10 on: July 05, 2015, 09:58:57 PM »
I work with one mouse(Bloody T7)

And this my command:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.1-->
<command id="225" name="Load Python script" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Hook.Disable</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecFile</cmdType>
    <params>
      <param>PY\processRunningCheck.py</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>VC.Loaded</event>
</command>

looks how in you, because Hook is enable by default, and its work normally...

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #11 on: July 05, 2015, 10:02:12 PM »
But how without this switching do what py script work good its possibly? Thanks! Starting downloading py courses ))

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #12 on: July 06, 2015, 01:24:35 AM »
Hmm... After some time Hook is not work not response of mouse clicks(( I don`t know what do(( No switches form on off of Hook but after some time not work((( It`s bad...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Hook and monitoring programs... How?
« Reply #13 on: July 06, 2015, 08:20:56 AM »
For us, this solution is working, but we cannot test it for very long periods.

Does the Hook plugin continue to work for you without errors if you leave it enabled always, for a long time?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Hook and monitoring programs... How?
« Reply #14 on: July 06, 2015, 10:15:07 AM »
Today i launch VC and hook was enable always and working good but after i start use VC commands for example loops of 200 iteration 3 or 4 times after without problems in logs Hook is not response of mouse clicking... And yesterday after i starting use commands in VC after some time Hook is not response... I use DXInput for my commands...