Source language: Translate to:

List Of Joysticks

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

List Of Joysticks

Postby Cuttlas » Tue Jul 24, 2012 11:40 pm

Hi

I'm looking for a script which can list connected joysticks.

Look at picture below to see how windows are listed them. Really I know a way which I can get the list of joysticks, but I want to get them just like picture below:

Image

Any help is really appreciated :oops:
User avatar
Cuttlas
 
Posts: 60
Joined: Wed Dec 07, 2011 10:45 am

Re: List Of Joysticks

Postby dpayer » Wed Jul 25, 2012 6:16 am

Cuttlas wrote:Hi

I'm looking for a script which can list connected joysticks.

Any help is really appreciated :oops:


I don't have joysticks on my computer so I am flying a bit blind on this one.

There is a registry key with some info that may be what is used by the joy.cpl app in the control panel.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MediaProperties\PrivateProperties\Joystick

Poke around there for possibilities.

David P.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Cuttlas » Wed Jul 25, 2012 9:38 am

Thanks for reply, really I know that regisrty key and I can get the list of joystick from there, but I do not know how to list them just like in the picture, the order of them is really really important. So I'm looking for a way to get them just like the picture or find out how to they are lisiting like this.
User avatar
Cuttlas
 
Posts: 60
Joined: Wed Dec 07, 2011 10:45 am

Postby Gaev » Wed Jul 25, 2012 10:50 am

Cuttlas:
but I do not know how to list them just like in the picture, the order of them is really really important.

This might be overkill ... but if your Application already used the NeoBookDBPro plugin, you could load the registry entries into an Access Database and then display its contents in a Grid.

Otherwise, look in the NeoBook Resource Center for plugins that enable you to display data in a Spreadsheet format ... I know Hans-Peter has a free one ... and others have ones that cost a nominal amount.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dpayer » Wed Jul 25, 2012 10:59 am

Cuttlas wrote:Thanks for reply, really I know that regisrty key and I can get the list of joystick from there, but I do not know how to list them just like in the picture, the order of them is really really important. So I'm looking for a way to get them just like the picture or find out how to they are lisiting like this.


Why don't you post what that registry section has in it. I bet you will find what you need from there. After that, it is just a formatting issue.

D
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Cuttlas » Wed Jul 25, 2012 11:20 am

Gaev, it is not a normal listing problem, really I can list them in the way they are list in the windows registry. Target registry key is the one which dpayer mentioned it. But there is another problem, there is another way and algorithm which list joystick in another way, I mean windows registry won't help in this case. So I decided to look for a vbscirpt for doing this which can list joysticks just like joy.cpl.

I have a vbsvript which can get you connected usb devices VID and PID informations. It is very good, because I can extract joysticks names via thier VID and PIDs, But again I can not list them like joy.cpl (the picture).
I want a vbscript which can list connected joysticks like joy.cpl.


and here is the vbsciprt which I mentioned, the neobook version of this vbscript is too slow and will freeze publication for some seconds.
Code: Select all
Option Explicit
Dim oWMISrv, collDvcs, collUSBDvcs, iUSBDvc , iDvc, sDvcID, sPID, sVID

Function ReplaceX(ByVal sValue, ByVal sPattern, ByVal sNValue)
    Dim oReg : Set oReg = New RegExp
    oReg.Pattern = sPattern
    ReplaceX = oReg.Replace(sValue, sNValue)
    Set oReg = Nothing
End Function

Set oWMISrv = GetObject("winmgmts:\\.\root\cimv2")
Set collDvcs = oWMISrv.ExecQuery("Select * From Win32_USBControllerDevice")

For Each iDvc In collDvcs
    If InStr(iDvc.Dependent, "VID_") Then ' Except keychain drives

        sDvcID = ReplaceX(iDvc.Dependent, ".*""(.*)""", "$1")
        sPID = ReplaceX(sDvcID, ".*PID_([^\\]*).*", "$1")
        sVID = ReplaceX(sDvcID, ".*VID_([^&]*).*", "$1")

        Set collUSBDvcs = oWMISrv.ExecQuery _
        ("Select * From Win32_PnPEntity Where DeviceID = '" & sDvcID & "'")
        For Each iUSBDvc in collUSBDvcs
            Wscript.Echo "Name : "& iUSBDvc.Description
            Wscript.Echo "VID_" & sVID & "&PID_"& sPID
        Next
        Set collUSBDvcs = Nothing

    End If
Next

Set collDvcs = Nothing
Set oWMISrv = Nothing
User avatar
Cuttlas
 
Posts: 60
Joined: Wed Dec 07, 2011 10:45 am

Postby dec » Wed Jul 25, 2012 11:37 am

Hi there,

Really I can't figure why exactly you need the joystick listed exactly like the panel control application, but, maybe you can use this application directly? So you can use the command "Run" to execute the "Joy.cpl".

On the other hand, maybe can you said what you wanted for, not only that you need the information appear exactly like in the native application: maybe in this manner we also can help you a little more.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby Gaev » Wed Jul 25, 2012 12:08 pm

cuttlas:
It is very good, because I can extract joysticks names via thier VID and PIDs, But again I can not list them like joy.cpl (the picture).
I want a vbscript which can list connected joysticks like joy.cpl.

1) vbscript (and javascript) have extremely limited capabilities for displaying information (e.g. alert command)

2) So you have two choices ...

a) modify the vbscript you posted above to pass the extracted information here ...
Code: Select all
For Each iUSBDvc in collUSBDvcs
    Wscript.Echo "Name : "& iUSBDvc.Description
    Wscript.Echo "VID_" & sVID & "&PID_"& sPID
Next
... back to NeoBook ... and use NeoBook's (and those of its plugins') excellent display facilities to display the received information in 'a spreadsheet format'

b) make up an html file which has your vbscript ... as well as some html to display the results in a pretty format (using html tags < table> ... < /table>) ... and run this html file within a WebBrowser Object inside your NeoBook Application.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Cuttlas » Thu Jul 26, 2012 1:14 am

Image

Look at above image, as you can see it is listed joysticks just like the joy.cpl. I mean so many of programs which words with joysticks will list them is the same way. and Really Order of Them is highly important.

So I need to get the list of them just like in the picture.

that vbscript which I had mentioned will get all usb devices informations, and it is tooooooooo slow and and I told before using it in neobbok version will freeze the publication for some seconds. I only wrote it to give a tip for getting a device information.

So What should I do?
User avatar
Cuttlas
 
Posts: 60
Joined: Wed Dec 07, 2011 10:45 am

Postby dpayer » Thu Jul 26, 2012 7:06 am

Cuttlas wrote:that vbscript which I had mentioned will get all usb devices informations, and it is tooooooooo slow and and I told before using it in neobbok version will freeze the publication for some seconds. I only wrote it to give a tip for getting a device information.

So What should I do?


I would get that information at startup and display an informative window while it is getting the information from the WMI. Once you get it, you could store the info in an INI file and at next startup, use the stored information until you could check to make sure it is accurate.

David P.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Cuttlas » Thu Jul 26, 2012 10:10 am

dear dpayer

My problem is not how to handle inforamtions, it is how to get them just like joy.cpl and other applications which list connected joysticks. I'm sure there must be a way through VBScripts :!:
User avatar
Cuttlas
 
Posts: 60
Joined: Wed Dec 07, 2011 10:45 am

Postby dpayer » Thu Jul 26, 2012 1:53 pm

Cuttlas wrote:dear dpayer

My problem is not how to handle inforamtions, it is how to get them just like joy.cpl and other applications which list connected joysticks. I'm sure there must be a way through VBScripts :!:


Well, you can search other parts of the registry by searching for the exact phrase that is given via joy.cpl.

It may be stored in a different location than the one we looked in originaly.

D
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby dec » Thu Jul 26, 2012 2:14 pm

Hi,

I can't help too. I try with the appropiate native functions to retrieve joystick information, but, to my surprise these don't retrieve the same values that appear on my "joy.cpl". On the other hand I have no joystick, and just test it with an emulator: PPJoy. And other rare thing: my "joy.cpl" don't list these emulated joystick, but apparently two "standard joystick" drivers. Trying with a couple of Delphi components the results are unpredictable (to me) since the devices names (when it's retrieved) is not the same that the appear on "joy.cpl". Anyway, maybe I'm not the best person here, since, I repeat, I have no joystick installed at all...
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby Cuttlas » Thu Jul 26, 2012 10:33 pm

dec wrote:I try with the appropiate native functions to retrieve joystick information, but, to my surprise these don't retrieve the same values that appear on my "joy.cpl".


Can you tell us what is those native functions? Did you write a script? can you share please?
User avatar
Cuttlas
 
Posts: 60
Joined: Wed Dec 07, 2011 10:45 am

Postby dec » Fri Jul 27, 2012 3:20 am

Hello,

I try with these functions, in particular with joyGetDevCaps. I also try with WMI, but, unfortunatelly (maybe because I have no joystick installed) the results are not the same that the "joy.cpl" offer...
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Next

Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

cron