majesticartz | 14 Aug 2012 04:31
Picon
Favicon

HARD Question: Triggering the key/mouse interceptor virtually

Greetings Gurus, I have a tough one for you guys.

I have a program that can run an exe, send a WM_Message, or simulate a hotkey press when triggered (Bomes Midi
Translator Pro).

I use powerpros key/mouse dialog extensively to set up keys that do different things based on the active
window using caption lists (+GreenBrowser,=maxthon,c=MozillaUIWindowClass).

Ideally if powerpro's key/mouse dialog could intercept midi triggers the same way it intercepts keys and
mouse buttons I would be done. that is the behavior I am trying to get between these two programs.

How do I make powerpro 'detect' a specific key press via it's command line, wm_message, or intercepting a
virtual key press. PowerPro does not respond to programs sending keypresses just 'Real Physical' keypresses.

So when I touch a specific button on my midi controller, Bome's MTP sends a specific argument to powerpro
(via WM_Message, exe command line, Bome's sendkey method) which says 'someone typed CTRL-F1 so based the
captionlist if i'm in notepad type (sendkey) 'trigger successful'.

So in a nutshell can PowerPro be configured to respond to virtual key presses the same way it responds to real
key presses? So a vbscript would be able to send a key to PP?

Can it be configured to respond to a command line that states powerpro.exe -keymouse /key CTRL-F1
Which would trigger PP to do the function assigned to CTRL-F1 in it's key/mouse list?

Can a WM_Message trigger that same functionality in the key/mouse dialog.

How do I virtually trigger the key/mouse dialog fuctionality?

------------------------------------

(Continue reading)

brucexs | 14 Aug 2012 12:00
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

Hmm, where have a seen this before....?

You still cannot do it directly with keyboard messages.  At least not easily or practically. 

However, there is something new in the latest versions that can intercept WM_APP messages, that is any WM
message between 0x8000 and 0xBFFF and do an different action depending on the contents of the message,
wParam, and lParam.

If your program can send these, it is easy with scripting to do what you want.  You don't need the command line,
just scripting.  

1.  Create a command list called hookappmessages.

2.  The first and only line of this command list is
ProcessAppMessage(arg(1), arg(2), arg(3))

Now you create a script file ProcessAppMessages to do what you want which each different variation that
your midi program sends.  The action could also depend on the active program.

Of course, you need to download and install the latest beta.

--- In power-pro@..., "majesticartz" <majesticartz <at> ...> wrote:
>
> Greetings Gurus, I have a tough one for you guys.
> 
> I have a program that can run an exe, send a WM_Message, or simulate a hotkey press when triggered (Bomes
Midi Translator Pro).
> 
> I use powerpros key/mouse dialog extensively to set up keys that do different things based on the active
window using caption lists (+GreenBrowser,=maxthon,c=MozillaUIWindowClass).
(Continue reading)

majesticartz | 14 Aug 2012 16:28
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

Ok Bruce I'm excited and Almost there.
The CL has one entry whose function is 'ProcessAppMessage(arg1,arg2,arg3)'
I'm getting two error messages.
Both scripts have one line: 'Function ProcessAppMessage(arg1,arg2,arg3)
'

Error 1: Another when I have a script named 'Hookappmessages.powerpro'.
Error 2: When I don't have a script named 'Hookappmessages.powerpro'.

Error 1: Cannot find label or function in script file
ProcessAppMessage

Error occurred near line 0 of script hookappmessages:
ProcessAppMessage (arg(1),arg(2), arg(3)) 

Press Cancel to end all running scripts.

Error 2:Cannot access script file
hookappmessages

Error occurred near line 1 of script hookappmessages:
ProcessAppMessage (arg(1),arg(2), arg(3)) 

Press Cancel to end all running scripts.

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> Hmm, where have a seen this before....?
> 
> You still cannot do it directly with keyboard messages.  At least not easily or practically. 
(Continue reading)

majesticartz | 14 Aug 2012 16:49
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually


The command on the CL is now .ProcessAppMessage(arg(1), arg(2), arg(3))

The script contents is now:

Function ProcessAppMessage(arg1,arg2,arg3)

Local c = arg1

*message arg1

quit (c)

No errors but the parameters don't seem to be there. The messagebox says
'arg1'. Help

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> Hmm, where have a seen this before....?
>
> You still cannot do it directly with keyboard messages. At least not
easily or practically.
>
> However, there is something new in the latest versions that can
intercept WM_APP messages, that is any WM message between 0x8000 and
0xBFFF and do an different action depending on the contents of the
message, wParam, and lParam.
>
> If your program can send these, it is easy with scripting to do what
you want. You don't need the command line, just scripting.
(Continue reading)

brucexs | 14 Aug 2012 17:04
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually


*message 
is an old command which takes the following text literally.

Try something like
win.debug(arg1)

or

messagebox("ok", arg1, "title")

--- In power-pro@..., "majesticartz" <majesticartz <at> ...> wrote:
>
> 
> The command on the CL is now .ProcessAppMessage(arg(1), arg(2), arg(3))
> 
> The script contents is now:
> 
> Function ProcessAppMessage(arg1,arg2,arg3)
> 
> Local c = arg1
> 
> *message arg1
> 
> quit (c)
> 
> 
> 
> No errors but the parameters don't seem to be there. The messagebox says
> 'arg1'. Help
(Continue reading)

majesticartz | 14 Aug 2012 17:30
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

It's working! Thanks a lot. For some reason the '.' prefixed scriptname is the only method that worked
(which is fine).

Now I'll be building the script.
Any suggestions? Is there a 'Select Case' statement that I can use for branching off of the arg1 variable?

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> 
> *message 
> is an old command which takes the following text literally.
> 
> Try something like
> win.debug(arg1)
> 
> or
> 
> messagebox("ok", arg1, "title")
> 
> --- In power-pro@..., "majesticartz" <majesticartz <at> > wrote:
> >
> > 
> > The command on the CL is now .ProcessAppMessage(arg(1), arg(2), arg(3))
> > 
> > The script contents is now:
> > 
> > Function ProcessAppMessage(arg1,arg2,arg3)
> > 
> > Local c = arg1
> > 
(Continue reading)

brucexs | 14 Aug 2012 17:54
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

Sorry, you do need the dot (or you can use the call statement)  Leaving it out was an error on my part.  

--- In power-pro@..., "majesticartz" <majesticartz <at> ...> wrote:
>
> It's working! Thanks a lot. For some reason the '.' prefixed scriptname is the only method that worked
(which is fine).
> 
> Now I'll be building the script.
> Any suggestions? Is there a 'Select Case' statement that I can use for branching off of the arg1 variable?
> 
> --- In power-pro@..., "brucexs" <brucexs <at> > wrote:
> >
> > 
> > *message 
> > is an old command which takes the following text literally.
> > 
> > Try something like
> > win.debug(arg1)
> > 
> > or
> > 
> > messagebox("ok", arg1, "title")
> > 
> > --- In power-pro@..., "majesticartz" <majesticartz <at> > wrote:
> > >
> > > 
> > > The command on the CL is now .ProcessAppMessage(arg(1), arg(2), arg(3))
> > > 
> > > The script contents is now:
> > > 
(Continue reading)

majesticartz | 14 Aug 2012 18:16
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

What script structure do you reccomend for branching based on the arg1 value?

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> Sorry, you do need the dot (or you can use the call statement)  Leaving it out was an error on my part.  
> 
> --- In power-pro@..., "majesticartz" <majesticartz <at> > wrote:
> >
> > It's working! Thanks a lot. For some reason the '.' prefixed scriptname is the only method that worked
(which is fine).
> > 
> > Now I'll be building the script.
> > Any suggestions? Is there a 'Select Case' statement that I can use for branching off of the arg1 variable?
> > 
> > --- In power-pro@..., "brucexs" <brucexs <at> > wrote:
> > >
> > > 
> > > *message 
> > > is an old command which takes the following text literally.
> > > 
> > > Try something like
> > > win.debug(arg1)
> > > 
> > > or
> > > 
> > > messagebox("ok", arg1, "title")
> > > 
> > > --- In power-pro@..., "majesticartz" <majesticartz <at> > wrote:
> > > >
> > > > 
(Continue reading)

brucexs | 14 Aug 2012 19:20
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually


There is no select case but there is if() do ...elseif(...) as detailed in help.

But I would not do it like that because it would be hard to maintain and read.

One idea would be to create a separate function in the file for each branching value nnn, ie

function key_nnn(arg2, arg3)

if (activewindow("c1")) do
do (the conmmand for c1 matching active window)

elseif (activewindow(...)
...
else
...
endif
endfunction

etc -- another function for each arg1 

Then ProcessAppMessage is simply
call (". <at> key_"++arg1, arg2, arg3)  // note . <at> , call needs file name or .

You could precede that call with a range validity check on arg1 first to prevent unknown function call errors.

The above might be OK for you.

But if I was doing this, I'd probably want to maintain everything in a file to make it easier to add or change
key actions.
(Continue reading)

majesticartz | 14 Aug 2012 20:07
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

WOW! That's a serious response (I never thought about keeping it im memory). I came up with a little script
that references 64 scripts (64 buttons on the midi controller). Each script will contain a bunch of if
statements (if (Z_class == "dopus.lister") do). 64 scripts is easier than managing (64 x however many if
statements I have assigned to each button) in ONE file. It's working perfect so far. and the speed is good
enough for now.

Thanks for implementing the WM_APP intercepts. That is an awesome feature. What gave you the idea to do so?

Function ProcessAppMessage(arg1,arg2,arg3)
args Z_Button, Z_ButtonY, Z_ButtonZ
Z_exe = exefilename
Z_title = caption
Z_class = window("class","active")
pathRoot = "C:/Ancient/PowerPro/scripts/Launchpad/"
Z_method = pathRoot ++ "Trigger" ++ (Z_Button - 32767)
Z_method(Z_exe,Z_title,Z_class,Z_Button,Z_ButtonY,Z_ButtonZ)
EndFunction

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> 
> There is no select case but there is if() do ...elseif(...) as detailed in help.
> 
> But I would not do it like that because it would be hard to maintain and read.
> 
> One idea would be to create a separate function in the file for each branching value nnn, ie
> 
> function key_nnn(arg2, arg3)
> 
> if (activewindow("c1")) do
(Continue reading)

brucexs | 14 Aug 2012 21:15
Picon
Favicon

Re: HARD Question: Triggering the key/mouse interceptor virtually

Once I decided to do another release, it was quite straightforward to do WM_APP.  It was your original
request plus I was looking for another way for different powerpro processes to communicate.

I am glad you found some way that works for you.  If it is works and the performance is fine, then just use it,
would be my advice. 

 Keeping separate files is another good idea for making it easier to maintain.  PowerPro holds all functions
in memory once they are called once, so, in terms of performance, it is really not much different from
putting them all in one file.  Plus if most of the functions are small, then it will be just about as fast as
some kind of lookup table.

--- In power-pro@..., "majesticartz" <majesticartz <at> ...> wrote:
>
> WOW! That's a serious response (I never thought about keeping it im memory). I came up with a little script
that references 64 scripts (64 buttons on the midi controller). Each script will contain a bunch of if
statements (if (Z_class == "dopus.lister") do). 64 scripts is easier than managing (64 x however many if
statements I have assigned to each button) in ONE file. It's working perfect so far. and the speed is good
enough for now.
> 
> Thanks for implementing the WM_APP intercepts. That is an awesome feature. What gave you the idea to do so?
> 
> Function ProcessAppMessage(arg1,arg2,arg3)
> args Z_Button, Z_ButtonY, Z_ButtonZ
> Z_exe = exefilename
> Z_title = caption
> Z_class = window("class","active")
> pathRoot = "C:/Ancient/PowerPro/scripts/Launchpad/"
> Z_method = pathRoot ++ "Trigger" ++ (Z_Button - 32767)
> Z_method(Z_exe,Z_title,Z_class,Z_Button,Z_ButtonY,Z_ButtonZ)
> EndFunction
(Continue reading)


Gmane