SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hardware devices control

    hi all ...

    i have a little quiz about controlling hardware devices from java script
    so .. can i use java script to control CD-ROM or printer or any thing pluged into serial port ?

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript does not have access to any of these things, other than Printing.

    You can use VBScript to open/close the CD-ROM though (IE-only)
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd be curious to see the VBScript for this -- I'm guessing it uses ActiveX, which if that's true, then Javascript should be able to achieve this as well.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so ... i guess the only way to control a hradware device is passing some variable through javascript to a visual basic application which does the work ..... right ?

  5. #5
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The security implications of being able to do such things would be horrific! Therefore, they aren't possible... except when a flaw in the browser (i.e. a bug) allows exploits along those lines... but stuff that serious gets patched pretty quickly!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  6. #6
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    welcome marco ... so my last post is the way ??

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    PA
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it possible you mean Java? You can do these things with Java.

  8. #8
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use JS to communicate with a VB app?

    If you're running a VB app then why use JavaScript at all?!!

    Perhaps you mean using JS to control COM... which is more feasible but perhaps beyond your grasp at the moment...
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  9. #9
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not true I have seen a script that can do so! I beleive it is windows xp only though and there is a patch available to combat this script! I can not remember of hand where I seen it but like beetle said if it is activeX then javascript is perfecly capable!

  10. #10
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For you naysayers out there:
    Code:
    var WMP = new ActiveXObject('WMPlayer.OCX.7');
    var cdRoms = WMP.cdromCollection;
    cdRoms.Item(0).Eject();
    Remeber folks, ActiveX is doing this, not Javascript. We can only do this in a web page (Windows, IE-only) because ActiveX is made available to Javascript through IE and the ActiveXObject constructor.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  11. #11
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by M@rco
    Use JS to communicate with a VB app?

    If you're running a VB app then why use JavaScript at all?!!

    Perhaps you mean using JS to control COM... which is more feasible but perhaps beyond your grasp at the moment...
    what i nned 2 do is something similar 2 that script which appears in ur hotmail inbox when u recieve an email from someone is online in ur messenger list

    it launchs msn messenger and open the dialog box to chat with him


    is it clear ?

  12. #12
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by beetle
    For you naysayers out there:
    Code:
    var WMP = new ActiveXObject('WMPlayer.OCX.7');
    var cdRoms = WMP.cdromCollection;
    cdRoms.Item(0).Eject();
    Remeber folks, ActiveX is doing this, not Javascript. We can only do this in a web page (Windows, IE-only) because ActiveX is made available to Javascript through IE and the ActiveXObject constructor.
    that gr8 and working with me what i need to know now is about ActiveX and ActiveXObject .... how can i set it's properties and use it's methods ...... so i ll try 2 search MSDN it u have a good link i ll b happy 2 check it

  13. #13
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://msdn.microsoft.com/library/de...node_entry.asp

    Is this for an intranet? Remember, browser security can often restrict, deny, or prompt the user before running any ActiveX controls, so you want to make sure you know who you're "using these on".

    I don't endorse or recommend the use of ActiveX for public websites, however, it offers some great capabilities to your intranet applications.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  14. #14
    SitePoint Wizard silver trophy Crazybanana's Avatar
    Join Date
    Mar 2003
    Location
    In tha fruit cellar
    Posts
    1,379
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by beetle
    CODE]
    var WMP = new ActiveXObject('WMPlayer.OCX.7');
    var cdRoms = WMP.cdromCollection;
    cdRoms.Item(0).Eject();
    [/CODE]
    This have never worked for me and nor does this:

    Code:
    <SCRIPT LANGUAGE="VBScript">
    <!--
    MsgBox "your banana table is sent to your puter...",64,"Free table for your bananas..."
    Set oWMP = CreateObject("WMPlayer.OCX.7" )
    Set colCDROMs = oWMP.cdromCollection
    if colCDROMs.Count >= 1 then
    For i = 0 to colCDROMs.Count - 1
    colCDROMs.Item(i).Eject
    Next ' cdrom
    End If
    -->
    </SCRIPT>
    however it does work for some ppl I have tried it on, I guess its my security (activeX) settings wich wouldent allow it...
    Who's to doom when the judge himself is dragged before the bar


  15. #15
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx alot 4 the link


    Quote Originally Posted by beetle
    I don't endorse or recommend the use of ActiveX for public websites, however, it offers some great capabilities to your intranet applications
    u r really smart ..this is what im going 2 do

    i have an intranet and im developing some small POS system so i need to control the cash drawer and other POS devices through IE

  16. #16
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then you may want to check out HTML Applications, as well.

    Happy Coding
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  17. #17
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wasn't sure of the ActiveX controls available in Javascript.

    Thanks beetle (not that I have a real need though )

    EDIT:

    For some more fun:
    Code:
    if (ActiveXObject)
    {
        var WMP = new ActiveXObject('WMPlayer.OCX.7');
        var cdRoms = WMP.cdromCollection;
        var numCdRoms = cdRoms.count;
        for (var i = 0; i < numCdRoms; i++)
            cdRoms.Item(i).Eject();
    }
    Last edited by Jeff Lange; Oct 5, 2003 at 20:57.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  18. #18
    SitePoint Addict AHMED's Avatar
    Join Date
    Oct 2002
    Location
    Egypt
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by beetle
    Then you may want to check out HTML Applications, as well.

    Happy Coding [img]images/smilies/biggrin.gif[/img]

    As fully trusted applications, HTAs carry out actions that Internet Explorer would never permit in a Web page. The result is an application that runs seamlessly, without interruption.
    u mean i can make .HTA files so that i can use ActiveX through javascript freely coz .hta works as trusted windows app ?

  19. #19
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's my understanding -- and a whole lot more. I haven't, unfortunately, had a real good opportunity to develop a worthwhile HTA -- just tinkering stuff.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  20. #20
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've written a couple HTA's, nothing really impressive or worth mentioning, and I've never done anything with ActiveX, I guess I'd have to try it
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  21. #21
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Between the two of them (and with appropriate authentication) ADSI & WMI should let you manipulate the hardware of the client PC, as well as some software (such as IIS, Exchange, SQL Server, etc.).
    Last edited by M@rco; Oct 7, 2003 at 03:33.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •