DeviceManager_SelectedDeviceIndex = -1

Questions, comments and suggestions concerning VintaSoft Twain ActiveX.

Moderator: Alex

Post Reply
alexei
Posts: 15
Joined: Thu Jun 09, 2016 9:04 pm

DeviceManager_SelectedDeviceIndex = -1

Post by alexei » Mon Jun 13, 2016 11:53 pm

Hi

I have upgraded the VintaSoft ActiveX driver from v5.2 to v6.0. and updated my scanning javascript accordingly, but now I'm getting an issue that when I'm using the VSTwain.DeviceManager_ShowDefaultDeviceSelectionDialog() and I select a scanner from the list, The VSTwain.Device_Open() hangs the browser window. I decided to check the DeviceManager_SelectedDeviceIndex and it appears that it is on -1. That means that my selection is not passed to the VSTwain object.

Code Snipet:

Code: Select all

    // Open the default Twain Drivers dialog box
    if (VSActiveX4Scan.DeviceManager_ShowDefaultDeviceSelectionDialog() != 1) {
        if (VSActiveX4Scan.HttpUpload_ErrorCode != 0) {
            document.getElementById('Layout_wt63_block_wtMainContent_Scanning_wt49_block_wtSelectSourceErrorLink').click();
            VSActiveX4Scan.Device_Close();
            VSActiveX4Scan.DeviceManager_Close();
            return;
        }

        document.getElementById('Layout_wt63_block_wtMainContent_Scanning_wt49_block_wtSelectSourceCancelLink').click();
        VSActiveX4Scan.Device_Close();
        VSActiveX4Scan.DeviceManager_Close();
        return;
    }   
    var selectedDeviceIndex = VSActiveX4Scan.DeviceManager_SelectedDeviceIndex;
    // Open The data source
    if (VSActiveX4Scan.Device_State == 0 ){  
       VSActiveX4Scan.Device_Open();
     }
    else {
       VSActiveX4Scan.Device_Close();
       VSActiveX4Scan.Device_Open();
    }
I Have added a variable SelectedDeviceIndex to be able to capture the value of the DeviceManager_SelectedDeviceIndex, property in order for me to check it while debugging the JavaScript through IE ( F12 developers toolbar).

Can someone shed some light on this matter?

Alexei
Last edited by alexei on Wed Jun 15, 2016 5:11 pm, edited 2 times in total.

Alex
Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

Re: DeviceManager_SelectedDeviceIndex = -1

Post by Alex » Tue Jun 14, 2016 2:51 pm

Hello Alexei,

I think you have the problem because there are no devices installed in the system, i.e. value of DeviceManager_DeviceCount property is equal 0. Am I right?

Best regards, Alexander

alexei
Posts: 15
Joined: Thu Jun 09, 2016 9:04 pm

Re: DeviceManager_SelectedDeviceIndex = -1 When selecting a scanner in the DeviceManager_ShowDefaultDeviceSelectionDialo

Post by alexei » Tue Jun 14, 2016 9:29 pm

Alex thanks for your response.

no you are not right. :D
I have 3 scanners installed which one is being used right now. The JavascriptDemo.html works when I use it, but I think the issue is that the Default dialog is not passing the selected scanner to the VSTwain object. To bad I cannot add print screens of the debug session in the browser, but When I check the values the DeviceManager_DeviceCount = 4 and the selectedDeviceIndex = -1. I select the EPSON GT-S55 in the list, then I hit the button Select. it closes the dialogbox, but does not set the selectedDeviceIndex.

troubleshooting:
I have created a copy of the JavascriptDemo.html and I have commented out the part that it takes the scanner from the dropdown and add the part of the VSTwain1.DeviceManager_ShowDefaultDeviceSelectionDialog() . It opens the dialog box and I can select a scanner and then it will do the Device_Open() Without any problems. and it scans.

What I notices is that the DefaultDialogBox that opened in the Demo html page shows the scanner drivers with a little more information than when I open it through my Website on the same machine, it puts the version and the (32-32) behind them:

Default DialogBox opened from my JavascriptDemo.html:


Select Source
EPSON GT-S55 3.67(32-32)

Default DialogBox opened from my website:

Select Source
EPSON GT-S55

-----


regards,

Alexei

Alex
Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

Re: DeviceManager_SelectedDeviceIndex = -1

Post by Alex » Thu Jun 16, 2016 9:01 pm

Hello Alexei,

The DeviceManager_ShowDefaultDeviceSelectionDialog method allows to change the default device. After executing of DeviceManager_ShowDefaultDeviceSelectionDialog method you can get the default device index using the DeviceManager_DefaultDeviceIndex property.

In your application you need:
  • Execute the DeviceManager_ShowDefaultDeviceSelectionDialog method
  • Get device index using the DeviceManager_DefaultDeviceIndex property
  • Set the device index using the DeviceManager_SelectedDeviceIndex property
For more info please read the "Programming" section of documentation:
http://www.vintasoft.com/docs/vstwain/

Best regards, Alexander

alexei
Posts: 15
Joined: Thu Jun 09, 2016 9:04 pm

Re: DeviceManager_SelectedDeviceIndex = -1

Post by alexei » Fri Jun 17, 2016 4:08 pm

Hi Alex,

thanks for helping me find out what is the issue.

I have done that also and it hanged at this location VSTwain1.DeviceManager_SelectedDeviceIndex = selectedDeviceInde :

Code: Select all

 var deviceSelectedElement = document.getElementById("DevicesSelect");
                var deviceSelected = deviceSelectedElement.options[deviceSelectedElement.selectedIndex].text;								
                var selectedDeviceIndex = VSTwain1.DeviceManager_FindDevice(deviceSelected);
                if (selectedDeviceIndex != VSTwain1.DeviceManager_SelectedDeviceIndex)
                    VSTwain1.DeviceManager_SelectedDeviceIndex = selectedDeviceIndex;

It is like on my machine, the Windows 10 Pro (64 bit), in the IE 11, It does not access the deviceManager properly if I run the code from my website. and locally ( JavaScriptDemo.html) It works fine. As I took another machine running Windows 7 32 bits, it runs the code just fine from my website.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest