How to 2 different Events at once for just one action

If you have a question or need help, this is the place to be.
Post Reply
Franziskaner88
Posts: 2
Joined: Sat Nov 23, 2019 9:36 pm

How to 2 different Events at once for just one action

Post by Franziskaner88 » Sat Nov 23, 2019 9:44 pm

Hi,

I want to use EventGhost for Hotkeying under Win10 x64.

So far it was no problem, but now i want change the master volume with a key combination with Keyboard + Mousewheel.
Every event works fine as single for this job, but never together in combination.

Is there any option to do this with an indirection? Because AND OR as conjunction is not possible for events.

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to 2 different Events at once for just one action

Post by kgschlosser » Sat Nov 23, 2019 11:57 pm

to date there is not a plugin that handles mouse and keyboard combinations... It is a good idea..

events get processed one at a time so there is no way to "combine" them so to speak. There would have to be a plugin specifically deigned to generate events for the combination.

I will look into it for ya.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: How to 2 different Events at once for just one action

Post by dan Edens » Sun Nov 24, 2019 12:26 am

I looked at it and went Challenenge accepted!

I MEAN it'll toggle the vol with your wheel but it doesnt detect scroll direction soo.....

Don't use this I did it as a joke BUT STILL COUNTS WORKS

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
    <Folder Name="this is a joke don't use this" Enabled="False" XML_Guid="{5E5DB18E-788D-444A-A0DE-1828AB1413DB}" Expanded="True">
        <Macro Name="toggle to down" XML_Guid="{ACBCF379-DC85-461A-8BE5-D86F650E9C47}">
            <Event Name="Keyboard.Down" XML_Guid="{29C29C19-C5A8-4F9D-8E8B-93DF005E7BA8}" />
            <Action XML_Guid="{62020D26-0704-4BC1-83A1-8D67C5B7524F}">
                EventGhost.EnableExclusive(XmlIdLink(4886))
            </Action>
            <Action XML_Guid="{15CC229A-EAEA-4AED-BCB1-7DCA0151DDFF}">
                Window.SendKeys(u'{Down}', False, 2)
            </Action>
        </Macro>
        <Macro Name="toggle to up" XML_Guid="{ACBCF379-DC85-461A-8BE5-D86F650E9C47}">
            <Event Name="Keyboard.Up" XML_Guid="{29C29C19-C5A8-4F9D-8E8B-93DF005E7BA8}" />
            <Action XML_Guid="{15CC229A-EAEA-4AED-BCB1-7DCA0151DDFF}">
                Window.SendKeys(u'{Up}', False, 2)
            </Action>
            <Action XML_Guid="{62020D26-0704-4BC1-83A1-8D67C5B7524F}">
                EventGhost.EnableExclusive(XmlIdLink(4890))
            </Action>
        </Macro>
        <Folder Name="volume changer" XML_Guid="{85B4C233-E35E-4BED-8632-9581C35591B5}">
            <Macro Name="vol down" id="4886" Enabled="False" XML_Guid="{B9F0998A-ACBB-4609-8DA2-272CC6DD5ACD}">
                <Event Name="MouseEvent.MouseWheel" XML_Guid="{198726FE-3C34-42B9-B0EB-168E1B5EB22D}" />
                <Action XML_Guid="{65A7F466-EB8C-4653-9C50-16D2140CBE82}">
                    System.ChangeMasterVolumeBy(-5.0, u'Primary Sound Driver')
                </Action>
            </Macro>
            <Macro Name="vol up" id="4890" XML_Guid="{B9F0998A-ACBB-4609-8DA2-272CC6DD5ACD}">
                <Event Name="MouseEvent.MouseWheel" XML_Guid="{198726FE-3C34-42B9-B0EB-168E1B5EB22D}" />
                <Action XML_Guid="{65A7F466-EB8C-4653-9C50-16D2140CBE82}">
                    System.ChangeMasterVolumeBy(5.0, u'Primary Sound Driver')
                </Action>
            </Macro>
        </Folder>
    </Folder>
</EventGhost>

On the real tho, it's a cool idea. Figuring out a way to get an "And" between 2 triggers would be really useful.
I use alot of "and" conditions in my Tasker triggers.

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to 2 different Events at once for just one action

Post by kgschlosser » Sun Nov 24, 2019 2:33 am

I am going to key something up to see if I can find out if a key is depressed or not from the windows API
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to 2 different Events at once for just one action

Post by kgschlosser » Sun Nov 24, 2019 3:02 am

ok so here goes..

Set up a macro that has the event for the mouse wheel scrolling.. then add this code into a python script placed directly after the event

Code: Select all

# BACKSPACE key
VK_BACK = 0x08

# TAB key
VK_TAB = 0x09

# CLEAR key
VK_CLEAR = 0x0C

# ENTER key
VK_RETURN = 0x0D

# SHIFT key
VK_SHIFT = 0x10

# CTRL key
VK_CONTROL = 0x11

# ALT key
VK_MENU = 0x12

# PAUSE key
VK_PAUSE = 0x13

# CAPS LOCK key
VK_CAPITAL = 0x14

# IME Kana mode
VK_KANA = 0x15

# IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
VK_HANGUEL = 0x15

# IME Hangul mode
VK_HANGUL = 0x15

# IME Junja mode
VK_JUNJA = 0x17

# IME final mode
VK_FINAL = 0x18

# IME Hanja mode
VK_HANJA = 0x19

# IME Kanji mode
VK_KANJI = 0x19

# ESC key
VK_ESCAPE = 0x1B

# IME convert
VK_CONVERT = 0x1C

# IME nonconvert
VK_NONCONVERT = 0x1D

# IME accept
VK_ACCEPT = 0x1E

# IME mode change request
VK_MODECHANGE = 0x1F

# SPACEBAR
VK_SPACE = 0x20

# PAGE UP key
VK_PRIOR = 0x21

# PAGE DOWN key
VK_NEXT = 0x22

# END key
VK_END = 0x23

# HOME key
VK_HOME = 0x24

# LEFT ARROW key
VK_LEFT = 0x25

# UP ARROW key
VK_UP = 0x26

# RIGHT ARROW key
VK_RIGHT = 0x27

# DOWN ARROW key
VK_DOWN = 0x28

# SELECT key
VK_SELECT = 0x29

# PRINT key
VK_PRINT = 0x2A

# EXECUTE key
VK_EXECUTE = 0x2B

# PRINT SCREEN key
VK_SNAPSHOT = 0x2C

# INS key
VK_INSERT = 0x2D

# DEL key
VK_DELETE = 0x2E

# HELP key
VK_HELP = 0x2F

# 0 key
VK_0 = 0x30

# 1 key
VK_1 = 0x31

# 2 key
VK_2 = 0x32

# 3 key
VK_3 = 0x33

# 4 key
VK_4 = 0x34

# 5 key
VK_5 = 0x35

# 6 key
VK_6 = 0x36

# 7 key
VK_7 = 0x37

# 8 key
VK_8 = 0x38

# 9 key
VK_9 = 0x39

# A key
VK_A = 0x41

# B key
VK_B = 0x42

# C key
VK_C = 0x43

# D key
VK_D = 0x44

# E key
VK_E = 0x45

# F key
VK_F = 0x46

# G key
VK_G = 0x47

# H key
VK_H = 0x48

# I key
VK_I = 0x49

# J key
VK_J = 0x4A

# K key
VK_K = 0x4B

# L key
VK_L = 0x4C

# M key
VK_M = 0x4D

# N key
VK_N = 0x4E

# O key
VK_O = 0x4F

# P key
VK_P = 0x50

# Q key
VK_Q = 0x51

# R key
VK_R = 0x52

# S key
VK_S = 0x53

# T key
VK_T = 0x54

# U key
VK_U = 0x55

# V key
VK_V = 0x56

# W key
VK_W = 0x57

# X key
VK_X = 0x58

# Y key
VK_Y = 0x59

# Z key
VK_Z = 0x5A

# Left Windows key (Natural keyboard)
VK_LWIN = 0x5B

# Right Windows key (Natural keyboard)
VK_RWIN = 0x5C

# Applications key (Natural keyboard)
VK_APPS = 0x5D

# Computer Sleep key
VK_SLEEP = 0x5F

# Numeric keypad 0 key
VK_NUMPAD0 = 0x60

# Numeric keypad 1 key
VK_NUMPAD1 = 0x61

# Numeric keypad 2 key
VK_NUMPAD2 = 0x62

# Numeric keypad 3 key
VK_NUMPAD3 = 0x63

# Numeric keypad 4 key
VK_NUMPAD4 = 0x64

# Numeric keypad 5 key
VK_NUMPAD5 = 0x65

# Numeric keypad 6 key
VK_NUMPAD6 = 0x66

# Numeric keypad 7 key
VK_NUMPAD7 = 0x67

# Numeric keypad 8 key
VK_NUMPAD8 = 0x68

# Numeric keypad 9 key
VK_NUMPAD9 = 0x69

# Multiply key
VK_MULTIPLY = 0x6A

# Add key
VK_ADD = 0x6B

# Separator key
VK_SEPARATOR = 0x6C

# Subtract key
VK_SUBTRACT = 0x6D

# Decimal key
VK_DECIMAL = 0x6E

# Divide key
VK_DIVIDE = 0x6F

# F1 key
VK_F1 = 0x70

# F2 key
VK_F2 = 0x71

# F3 key
VK_F3 = 0x72

# F4 key
VK_F4 = 0x73

# F5 key
VK_F5 = 0x74

# F6 key
VK_F6 = 0x75

# F7 key
VK_F7 = 0x76

# F8 key
VK_F8 = 0x77

# F9 key
VK_F9 = 0x78

# F10 key
VK_F10 = 0x79

# F11 key
VK_F11 = 0x7A

# F12 key
VK_F12 = 0x7B

# F13 key
VK_F13 = 0x7C

# F14 key
VK_F14 = 0x7D

# F15 key
VK_F15 = 0x7E

# F16 key
VK_F16 = 0x7F

# F17 key
VK_F17 = 0x80

# F18 key
VK_F18 = 0x81

# F19 key
VK_F19 = 0x82

# F20 key
VK_F20 = 0x83

# F21 key
VK_F21 = 0x84

# F22 key
VK_F22 = 0x85

# F23 key
VK_F23 = 0x86

# F24 key
VK_F24 = 0x87

# NUM LOCK key
VK_NUMLOCK = 0x90

# SCROLL LOCK key
VK_SCROLL = 0x91

# OEM specific
VK_OEM_SPECIFIC_1 = 0x92

# OEM specific
VK_OEM_SPECIFIC_2 = 0x93

# OEM specific
VK_OEM_SPECIFIC_3 = 0x94

# OEM specific
VK_OEM_SPECIFIC_4 = 0x95

# OEM specific
VK_OEM_SPECIFIC_5 = 0x96

# Left SHIFT key
VK_LSHIFT = 0xA0

# Right SHIFT key
VK_RSHIFT = 0xA1

# Left CONTROL key
VK_LCONTROL = 0xA2

# Right CONTROL key
VK_RCONTROL = 0xA3

# Left MENU key
VK_LMENU = 0xA4

# Right MENU key
VK_RMENU = 0xA5

# Browser Back key
VK_BROWSER_BACK = 0xA6

# Browser Forward key
VK_BROWSER_FORWARD = 0xA7

# Browser Refresh key
VK_BROWSER_REFRESH = 0xA8

# Browser Stop key
VK_BROWSER_STOP = 0xA9

# Browser Search key
VK_BROWSER_SEARCH = 0xAA

# Browser Favorites key
VK_BROWSER_FAVORITES = 0xAB

# Browser Start and Home key
VK_BROWSER_HOME = 0xAC

# Volume Mute key
VK_VOLUME_MUTE = 0xAD

# Volume Down key
VK_VOLUME_DOWN = 0xAE

# Volume Up key
VK_VOLUME_UP = 0xAF

# Next Track key
VK_MEDIA_NEXT_TRACK = 0xB0

# Previous Track key
VK_MEDIA_PREV_TRACK = 0xB1

# Stop Media key
VK_MEDIA_STOP = 0xB2

# Play/Pause Media key
VK_MEDIA_PLAY_PAUSE = 0xB3

# Start Mail key
VK_LAUNCH_MAIL = 0xB4

# Select Media key
VK_LAUNCH_MEDIA_SELECT = 0xB5

# Start Application 1 key
VK_LAUNCH_APP1 = 0xB6

# Start Application 2 key
VK_LAUNCH_APP2 = 0xB7

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key
VK_OEM_1 = 0xBA

# For any country/region, the '+' key
VK_OEM_PLUS = 0xBB

# For any country/region, the ',' key
VK_OEM_COMMA = 0xBC

# For any country/region, the '-' key
VK_OEM_MINUS = 0xBD

# For any country/region, the '.' key
VK_OEM_PERIOD = 0xBE

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key
VK_OEM_2 = 0xBF

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key
VK_OEM_3 = 0xC0

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key
VK_OEM_4 = 0xDB

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key
VK_OEM_5 = 0xDC

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key
VK_OEM_6 = 0xDD

# Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key
VK_OEM_7 = 0xDE

# Used for miscellaneous characters; it can vary by keyboard.
VK_OEM_8 = 0xDF

# OEM specific
VK_OEM_SPECIFIC_6 = 0xE1

# Either the angle bracket key or the backslash key on the RT 102-key keyboard
VK_OEM_102 = 0xE2

# OEM specific
VK_OEM_SPECIFIC_7 = 0xE3-E4

# OEM specific
VK_OEM_SPECIFIC_8 = 0xE4

# IME PROCESS key
VK_PROCESSKEY = 0xE5

# OEM specific
VK_OEM_SPECIFIC_9 = 0xE6

# Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP
VK_PACKET = 0xE7

# OEM specific
VK_OEM_SPECIFIC_10 = 0xE9

# OEM specific
VK_OEM_SPECIFIC_11 = 0xEA

# OEM specific
VK_OEM_SPECIFIC_12 = 0xEB

# OEM specific
VK_OEM_SPECIFIC_13 = 0xEC

# OEM specific
VK_OEM_SPECIFIC_14 = 0xED

# OEM specific
VK_OEM_SPECIFIC_15 = 0xEF

# OEM specific
VK_OEM_SPECIFIC_16 = 0xF0

# OEM specific
VK_OEM_SPECIFIC_17 = 0xF1

# OEM specific
VK_OEM_SPECIFIC_18 = 0xF2

# OEM specific
VK_OEM_SPECIFIC_19 = 0xF3

# OEM specific
VK_OEM_SPECIFIC_20 = 0xF4

# OEM specific
VK_OEM_SPECIFIC_21 = 0xF5

# Attn key
VK_ATTN = 0xF6

# CrSel key
VK_CRSEL = 0xF7

# ExSel key
VK_EXSEL = 0xF8

# Erase EOF key
VK_EREOF = 0xF9

# Play key
VK_PLAY = 0xFA

# Zoom key
VK_ZOOM = 0xFB

# PA1 key
VK_PA1 = 0xFD

# Clear key
VK_OEM_CLEAR = 0xFE


VIRTUAL_KEY = VK_W

import ctypes
from ctypes.wintypes import SHORT, INT

user32 = ctypes.windll.User32

# SHORT GetKeyState(
#   int nVirtKey
# );

GetKeyState = user32.GetKeyState
GetKeyState.restype = SHORT

HIGH_ORDER_MASK = 0x8000

if not GetKeyState(INT(VIRTUAL_KEY)) & HIGH_ORDER_MASK:
    eg.StopMacro()
    eg.Exit()

you will have to modify this script and change the line

Code: Select all

VIRTUAL_KEY = VK_W
the VK_W is the key to check that is the part to change to one of the variables listed above that line.
and after the python script add the other actions you want to perform..

if the key is not being depressed when the mouse wheel event takes place the macro will not run past this script..
if the key is being depressed then the rest of the actions(s) will run.
If you like the work I have been doing then feel free to Image

Franziskaner88
Posts: 2
Joined: Sat Nov 23, 2019 9:36 pm

Re: How to 2 different Events at once for just one action

Post by Franziskaner88 » Sun Nov 24, 2019 1:50 pm

Wow, thanks! It seems to be working so far.

But 3 more things...
  • can I push 2 keys at keyboard (virutal keys) instead of one?
  • can I disable the scrolling function at a document / website while pushing the keyboard key/s?
  • can I show the Master-Volume OSD while changing the Volume?
The settings with "Key V + Mousewheel Scrolling" to Change the Volume +/-5%

Code: Select all

 not allowing, thanks the boards spam guard 
then here as picture:
eventghost volume.png
eventghost volume.png (18.19 KiB) Viewed 2728 times

after 3 times trying to post this reply, i got the following message:
Forbidden. Data submitted too often. Please wait a few minutes.
Because the attached settings allegedly containing a contact. but there was neither contact nor email address.
Hrs later it was possible to post this reply.
The responsible ones should set the board correctly, otherwise it is a torture to use this board.
kgschlosser wrote:
Sun Nov 24, 2019 3:02 am
ok so here goes..

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to 2 different Events at once for just one action

Post by kgschlosser » Sun Nov 24, 2019 6:50 pm

I need to see the exact error you are getting from the forum. This is the first time I am getting a report of a problem like this.

also I know it is an aggravation with the spam settings.. I have changed your account so you are no longer in the "new user" pool. that should make things a bit easier for ya.

unfortunately because of the spam bots we sometimes have to make a trade off. in the last 30 days alone we have had 3800 spam attacks. and of that 3800 only 4 or 5 have managed to get in. typically if one gets in it will flood the board with posts depending on the bot it can be anywhere from 3 to 50 messages. for each attack..

do that math on that.. that is one hell of a mess to try and clean up if the whole 3800 get in. I have tried using all kinds of captcha. and a lot of spam bots end up getting around it. I used the question and answer.. and that is only good for a short period before it has to be changed. the length of time before a change is needed is random. it could be a week it could be 2 months. the only way to know is when they get past it and flood the board. again which leads to a lot of work to do cleanup.

this is the only anti spam hat seems to work 99% of the time. and it does not make the user go through the whole captcha process, and that is a +

It is not perfect by any stretch But it is the best thing I have been able to locate thus far.. I am sorry for the problem you have encountered. There is a list of usernames the service provider has that are considered "known" spam usernames. It could be that the username you are using might be in this list. you should b able to check it out on www.cleantalk.org
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: How to 2 different Events at once for just one action

Post by kgschlosser » Sun Nov 24, 2019 7:27 pm

Now as far as you question regarding key combinations.

yes it can be done.

you see this line in that script I sent you

Code: Select all

if not GetKeyState(INT(VIRTUAL_KEY)) & HIGH_ORDER_MASK:
you would want to change it to the following.

Code: Select all

SECOND_VIRTUAL_KEY = VK_X

if not GetKeyState(INT(VIRTUAL_KEY)) & HIGH_ORDER_MASK or not GetKeyState(INT(SECOND_VIRTUAL_KEY )) & HIGH_ORDER_MASK:
This is not going to handle keys like shift, alt or ctrl. if you are wanting to use one of those let me know I will have to do some research on how to get the low order byte as a mask.

as far as the displaying of the OSD.

add your volume change action then add a wait action and set it to 0.1 seconds..
then add the OSD action.
In the Text to display of the OSD config dialog put this in there

Code: Select all

{"Volume: %.2f %%" % (eg.WinApi.SoundMixer.GetMasterVolume("Speakers (Realtek High Definiti"),)}
you are going to need to change the "Speakers (Realtek High Definiti " to your sound card...
how you get the proper thing to put in there is you will want to right click on the Change Volume By action you made and then click on "copy as python"

then paste the information into a text file you are going to see this

Code: Select all

eg.plugins.System.ChangeMasterVolumeBy(5.0, u'Primary Sound Driver')
this is the bit you want

Code: Select all

u'Primary Sound Driver'
replace the u' in the beginning and the ' on the end with double quotes (")
you end up with

Code: Select all

"Primary Sound Driver"
the final version will look like so.

Code: Select all

{"Volume: %.2f %%" % (eg.WinApi.SoundMixer.GetMasterVolume("Primary Sound Driver"),)}
a little breakdown of the OSD text

Code: Select all

{ - tells EG to evaluate the following information as a python expression

"Volume: %.2f %%" - this is a string format. the %.2f means the data we want to replace this with is a float (decimal number). and the .2 means to limit it to 2 decimal places and the f means float.

the %% is to add a % on the end of it.
so the data between the double quotes is the OSD text to display. once we replace the formatter with the data we end up with

"Volume: 100.00 %"


 % - this tell python that we want to replace the formatter with the data that follows.
 
 ( - beginning of data
 
 eg.WinApi.SoundMixer.GetMasterVolume("Primary Sound Driver"), - this is the actual data. It is a function that we call to get the data... but it all works the same. the data returned from calling this function is the volume
 
 ) - end of data

} - stop the evaluation

a plugin has to be written to handle the {} marks. so not all plugins will use this.. you can always try and see if it does or not.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: How to 2 different Events at once for just one action

Post by dan Edens » Sun Nov 24, 2019 7:51 pm

wow this is smooth.
This is really powerful stuff, great addition to the tool belt.
Thanks Kevin, once again you are the best.

Post Reply