Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

[MBS] RemoteControlMBS and PressKey (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] MBS and contextual menus
Next thread: [MBS] Landscape PDF


Re: [MBS] PortAudioStreamRecorderMBS issue   -   Garth Hjelte
  [MBS] RemoteControlMBS and PressKey   -   Jean-Luc Arnaud
   Re: [MBS] RemoteControlMBS and PressKey   -   Christian Schmitz
   Re: [MBS] RemoteControlMBS and PressKey   -   Marnaud
   Re: [MBS] RemoteControlMBS and PressKey   -   Marnaud
    Re: [MBS] RemoteControlMBS and PressKey   -   Jean-Luc Arnaud
    Re: [MBS] RemoteControlMBS and PressKey   -   Jean-Luc Arnaud
   Re: [MBS] RemoteControlMBS and PressKey   -   Marnaud
    Re: [MBS] RemoteControlMBS and PressKey   -   Jean-Luc Arnaud
   Re: [MBS] RemoteControlMBS and PressKey   -   Christian Schmitz
    Re: [MBS] RemoteControlMBS and PressKey   -   Jean-Luc Arnaud

[MBS] RemoteControlMBS and PressKey
Date: 09.01.15 10:17 (Fri, 09 Jan 2015 10:17:37 +0100)
From: Jean-Luc Arnaud
Hi all,

Using MBS class RemoteControlMBS and MacPressKey or WinPressKey, I would
like to send a "F8" key to the frontmost application.

I just have a problem: what code should I use in the PressKey functions,
given that they need an Integer parameter and that I don't know what's
the value for F8?

TIA

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 12:45 (Fri, 9 Jan 2015 12:45:48 +0100)
From: Christian Schmitz

> Am 09.01.2015 um 12:11 schrieb Jean-Luc Arnaud <<email address removed>>:
>
> Works well, thanks!
>
> And sorry, Christian, F8 is 100 (&h64) on Windows too.
> &h77 (119) is "End" key.

Hm, you may talk about scan codes while I told the virtual key code which is &h77 for F8 and &h23 for End.

Nevertheless, I'm happy you solved it.

Greetings
Christian

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 11:32 (Fri, 09 Jan 2015 11:32:47 +0100)
From: Marnaud
Le 9 janv. 2015 à 11:26, Jean-Luc Arnaud <<email address removed>> a écrit:

> I'm sure you're right (and Christian too) because &h64 (Christian's
> value for Mac) is 100 (your decimal value on Mac).

Yes, the Mac version isn't what I referred to, it's indeed the Win32 version that differs.

> Probably, regarding Windows, Parallels Desktop will translate &h64 (Mac) to &h77 (Win).

Yes, that would be highly possible (Parallels Desktop does a lot of translations to make Win32 feeling more “Mac-like”).

> Nevertheless, I will verify the Win value.

Of course. You may then tell which value it was (for the archives).

Regards,
Arnaud
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 11:30 (Fri, 09 Jan 2015 11:30:40 +0100)
From: Marnaud
Le 9 janv. 2015 à 11:19, Jean-Luc Arnaud <<email address removed>> a écrit:

> Yes, of course!
> Your help is greatly appreciated.
>
> May I know where these codes could be found? In the future, I could need
> codes for other functions keys.
>
> Many thanks.

Well, some years ago, I made my own app for that. On a window, put a listbox with 3 columns and an heading (“Key code”, “Key” and “Key ascii”) and a timer (period=1, mode=2). In the open event (in my example, in the window), have this:
dim i As integer
dim s As String

//Fill the list with every key (for searching manually):
for i=0 to 127 //Cover all standard keys on the keyboard
ListMain.AddRow str(i)
s=Keyboard.KeyName(i)
ListMain.Cell(i,1)=s
if len(s)=1 then //That key produces a character, so it's ASCII value is known
ListMain.Cell(i,2)=str(asc(s))
else //For other keys (backspace, tab, etc.), (1) it's better to know its key code (sending the ASCII value has no sense) and (2), it would mean rewriting.
ListMain.Cell(i,2)="?"
end if
Next

In the timer.Action:
dim i As integer
dim j As integer

//Check which keys are pressed (would fail if the key is pressed way too fast, but will that happen?)
for i=0 to 126
if Keyboard.AsyncKeyDown(i) then
j=FindKeycode(i) //See below; looks for the entry of “i” in the list (it would be odd it's not in the list)
if j=-1 then //Well, it's not in the list (?) so add it
ListMain.AddRow str(i)
j=ListMain.ListCount-1
ListMain.Cell(j,1)=Keyboard.KeyName(i)
ListMain.Cell(j,2)=str(asc(Keyboard.KeyName(i)))
end if
ListMain.ListIndex=j //Select the corresponding row
do
if not Keyboard.AsyncKeyDown(i) then Exit //Wait until the key is freed
Loop
end if
Next

Function FindKeycode(KeyCode As integer) As integer
dim i As integer

if ListMain.ListCount=0 then Return -1
for i=0 to ListMain.ListCount-1
if ListMain.Cell(i,0)=str(KeyCode) then Return i
Next
Return -1
End Function

(I could send you the project or app, but it's more complicated; tell me if you found something to improve).
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 12:26 (Fri, 09 Jan 2015 12:26:08 +0100)
From: Jean-Luc Arnaud
Arnaud,

I just added this in the CompareRows event of the listbox:

Select case column
Case 1 // This is a string column. Let the listbox manage it by
returning false
Return False

Case 0,2 // This is our numerical value columns. Let's do the work
ourselves
result = Sign(Val(me.Cell(row1, column)) - Val(me.Cell( row2, column)))
Return True

End Select

in order to sort first and third columns numerically (adapted code from
the Language Reference example).

Jean-Luc Arnaud

Le 09/01/2015 11:30, Marnaud a écrit :
> Le 9 janv. 2015 à 11:19, Jean-Luc Arnaud <<email address removed>> a écrit:
>
>> Yes, of course!
>> Your help is greatly appreciated.
>>
>> May I know where these codes could be found? In the future, I could need
>> codes for other functions keys.
>>
>> Many thanks.
> Well, some years ago, I made my own app for that. On a window, put a listbox with 3 columns and an heading (“Key code”, “Key” and “Key ascii”) and a timer (period=1, mode=2). In the open event (in my example, in the window), have this:
> dim i As integer
> dim s As String
>
> //Fill the list with every key (for searching manually):
> for i=0 to 127 //Cover all standard keys on the keyboard
> ListMain.AddRow str(i)
> s=Keyboard.KeyName(i)
> ListMain.Cell(i,1)=s
> if len(s)=1 then //That key produces a character, so it's ASCII value is known
> ListMain.Cell(i,2)=str(asc(s))
> else //For other keys (backspace, tab, etc.), (1) it's better to know its key code (sending the ASCII value has no sense) and (2), it would mean rewriting.
> ListMain.Cell(i,2)="?"
> end if
> Next
>
> In the timer.Action:
> dim i As integer
> dim j As integer
>
> //Check which keys are pressed (would fail if the key is pressed way too fast, but will that happen?)
> for i=0 to 126
> if Keyboard.AsyncKeyDown(i) then
> j=FindKeycode(i) //See below; looks for the entry of “i” in the list (it would be odd it's not in the list)
> if j=-1 then //Well, it's not in the list (?) so add it
> ListMain.AddRow str(i)
> j=ListMain.ListCount-1
> ListMain.Cell(j,1)=Keyboard.KeyName(i)
> ListMain.Cell(j,2)=str(asc(Keyboard.KeyName(i)))
> end if
> ListMain.ListIndex=j //Select the corresponding row
> do
> if not Keyboard.AsyncKeyDown(i) then Exit //Wait until the key is freed
> Loop
> end if
> Next
>
> Function FindKeycode(KeyCode As integer) As integer
> dim i As integer
>
> if ListMain.ListCount=0 then Return -1
> for i=0 to ListMain.ListCount-1
> if ListMain.Cell(i,0)=str(KeyCode) then Return i
> Next
> Return -1
> End Function
>
> (I could send you the project or app, but it's more complicated; tell me if you found something to improve).
> _______________________________________________
> Mbsplugins_monkeybreadsoftware.info mailing list
> <email address removed>
> https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 12:11 (Fri, 09 Jan 2015 12:11:29 +0100)
From: Jean-Luc Arnaud
Works well, thanks!

And sorry, Christian, F8 is 100 (&h64) on Windows too.
&h77 (119) is "End" key.

Jean-Luc Arnaud

Le 09/01/2015 11:30, Marnaud a écrit :
> Le 9 janv. 2015 à 11:19, Jean-Luc Arnaud <<email address removed>> a écrit:
>
>> Yes, of course!
>> Your help is greatly appreciated.
>>
>> May I know where these codes could be found? In the future, I could need
>> codes for other functions keys.
>>
>> Many thanks.
> Well, some years ago, I made my own app for that. On a window, put a listbox with 3 columns and an heading (“Key code”, “Key” and “Key ascii”) and a timer (period=1, mode=2). In the open event (in my example, in the window), have this:
> dim i As integer
> dim s As String
>
> //Fill the list with every key (for searching manually):
> for i=0 to 127 //Cover all standard keys on the keyboard
> ListMain.AddRow str(i)
> s=Keyboard.KeyName(i)
> ListMain.Cell(i,1)=s
> if len(s)=1 then //That key produces a character, so it's ASCII value is known
> ListMain.Cell(i,2)=str(asc(s))
> else //For other keys (backspace, tab, etc.), (1) it's better to know its key code (sending the ASCII value has no sense) and (2), it would mean rewriting.
> ListMain.Cell(i,2)="?"
> end if
> Next
>
> In the timer.Action:
> dim i As integer
> dim j As integer
>
> //Check which keys are pressed (would fail if the key is pressed way too fast, but will that happen?)
> for i=0 to 126
> if Keyboard.AsyncKeyDown(i) then
> j=FindKeycode(i) //See below; looks for the entry of “i” in the list (it would be odd it's not in the list)
> if j=-1 then //Well, it's not in the list (?) so add it
> ListMain.AddRow str(i)
> j=ListMain.ListCount-1
> ListMain.Cell(j,1)=Keyboard.KeyName(i)
> ListMain.Cell(j,2)=str(asc(Keyboard.KeyName(i)))
> end if
> ListMain.ListIndex=j //Select the corresponding row
> do
> if not Keyboard.AsyncKeyDown(i) then Exit //Wait until the key is freed
> Loop
> end if
> Next
>
> Function FindKeycode(KeyCode As integer) As integer
> dim i As integer
>
> if ListMain.ListCount=0 then Return -1
> for i=0 to ListMain.ListCount-1
> if ListMain.Cell(i,0)=str(KeyCode) then Return i
> Next
> Return -1
> End Function
>
> (I could send you the project or app, but it's more complicated; tell me if you found something to improve).
> _______________________________________________
> Mbsplugins_monkeybreadsoftware.info mailing list
> <email address removed>
> https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 11:06 (Fri, 09 Jan 2015 11:06:02 +0100)
From: Marnaud
Le 9 janv. 2015 à 10:17, Jean-Luc Arnaud <<email address removed>> a écrit:

> Hi all,
>
> Using MBS class RemoteControlMBS and MacPressKey or WinPressKey, I would
> like to send a "F8" key to the frontmost application.
>
> I just have a problem: what code should I use in the PressKey functions,
> given that they need an Integer parameter and that I don't know what's
> the value for F8?

Hello,

The F8 key has the key number 100 (perhaps they chose F8 because its key code is round? :-P). You're lucky here, because F8 won't change among keyboard layouts.
Perhaps I'm wrong (because Christian told otherwise in the meantime (I saw he also responded while I was writing my message)), but in a Virtual Machine (Win7), F8 is also 100 (is that a mapping of Parallels Desktop?). I don't have a real PC to try on.

Also, I bet you already know (but better to say it twice), that's the KeyCode, not the CharCode.
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 11:26 (Fri, 09 Jan 2015 11:26:22 +0100)
From: Jean-Luc Arnaud
Thanks Arnaud.

I'm sure you're right (and Christian too) because &h64 (Christian's
value for Mac) is 100 (your decimal value on Mac). Probably, regarding
Windows, Parallels Desktop will translate &h64 (Mac) to &h77 (Win).
Nevertheless, I will verify the Win value.

> Also, I bet you already know (but better to say it twice), that's the KeyCode, not the CharCode.
Of course.

Jean-Luc Arnaud

Le 09/01/2015 11:06, Marnaud a écrit :
> Le 9 janv. 2015 à 10:17, Jean-Luc Arnaud <<email address removed>> a écrit:
>
>> Hi all,
>>
>> Using MBS class RemoteControlMBS and MacPressKey or WinPressKey, I would
>> like to send a "F8" key to the frontmost application.
>>
>> I just have a problem: what code should I use in the PressKey functions,
>> given that they need an Integer parameter and that I don't know what's
>> the value for F8?
> Hello,
>
> The F8 key has the key number 100 (perhaps they chose F8 because its key code is round? :-P). You're lucky here, because F8 won't change among keyboard layouts.
> Perhaps I'm wrong (because Christian told otherwise in the meantime (I saw he also responded while I was writing my message)), but in a Virtual Machine (Win7), F8 is also 100 (is that a mapping of Parallels Desktop?). I don't have a real PC to try on.
>
> Also, I bet you already know (but better to say it twice), that's the KeyCode, not the CharCode.
> _______________________________________________
> Mbsplugins_monkeybreadsoftware.info mailing list
> <email address removed>
> https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 10:53 (Fri, 9 Jan 2015 10:53:35 +0100)
From: Christian Schmitz

> I just have a problem: what code should I use in the PressKey functions,
> given that they need an Integer parameter and that I don't know what's
> the value for F8?

Well, on Windows the virtual key code for F8 is &h77.
For Mac the key code is &h64.

if I looked right. Does that help?

Greetings
Christian

Re: [MBS] RemoteControlMBS and PressKey
Date: 09.01.15 11:19 (Fri, 09 Jan 2015 11:19:38 +0100)
From: Jean-Luc Arnaud
Yes, of course!
Your help is greatly appreciated.

May I know where these codes could be found? In the future, I could need
codes for other functions keys.

Many thanks.

Jean-Luc Arnaud

Le 09/01/2015 10:53, Christian Schmitz a écrit :
>> I just have a problem: what code should I use in the PressKey functions,
>> given that they need an Integer parameter and that I don't know what's
>> the value for F8?
> Well, on Windows the virtual key code for F8 is &h77.
> For Mac the key code is &h64.
>
> if I looked right. Does that help?
>
> Greetings
> Christian
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info