Jump to content

Different Results


Gaev
 Share

Recommended Posts

Hi:

Been playing with AutoItX using both javascript and vbscript ... found some differences in results ... perhaps someone can explain ... or point out the error of my ways.

I have this code in the <head> section of my html document ...

<script type="text/vbscript">
Sub vbEP1()
Set oAutoIt = CreateObject("AutoItX3.Control")
Result_vbEP1 = oAutoIt.RegEnumKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers",1)
msgbox("Result_vbEP1 = " + Result_vbEP1)
End Sub
</script>

<script type="text/javascript">
function jsEP1() {
oAutoIt = new ActiveXObject("AutoItX3.Control");
Result_jsEP1 = oAutoIt.RegEnumKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers",1);
alert("Result_jsEP1 = " + Result_jsEP1)
}
</script>
... the vbscript (vbEP1) correctly returns the value associated with the first printer definition ... the javascript (jsEP1) returns a null (empty ?) value.

This is also true for the 2nd, 3rd and 4th enumerated values.

Any ideas ?

Link to comment
Share on other sites

  • 2 weeks later...

Michel:

Thank you for your suggestion ... unfortunately, it did not make a difference ... I am running XP Pro with SP2 and all subsequent updates from MS ... have you been able to get a non-blank (non-empty) response on your computer ? ... and if so, what are your OS details ?

@AutoIt(X) developers:

a) Does AutoItX officially support running from Javascript ? I notice all examples are vbscript only ... although I have managed to replicate the samples using javascript (albeit with some syntax changes).

B) Is there a bug with values returned from javascript calls or is this something unique to the RegEnumKey method ?

Thank you for your consideration.

Link to comment
Share on other sites

I'm not a dev but I think I may be able to answer your questions:

a. AutoItX runs through the COM interface. Any language that supports this can use AutoItX's functions.

b. I dunno, try something else and see if it works:

function jsEP1() {
var oAutoIt = new ActiveXObject("AutoItX3.Control");
if (oAutoIt.WinExists("Untitled -")) {
alert("An untitled window is open")
}else{
alert("An untitled window is not open")

}
}

try this with and without an Untitled notepad window open.

#)

Edited by nfwu
Link to comment
Share on other sites

Hi, Gaev!

With this code, in a file TOTO.HTA :

<hta:application
 application navigable="yes"
 windowstate="normal"
 caption="yes"
 singleinstance="yes"
 showintaskbar="yes"
 />
<html>
<body onload="jsEP1();">
Test Printer Redistry
<script type="text/javascript">
function jsEP1(){
var oAutoIt = new ActiveXObject("AutoItX3.Control");
var Result_jsEP1 = oAutoIt.RegEnumKey("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Print\\Printers",1);
alert(Result_jsEP1);
}
</script>
</body>
</html>

Give me : "Adobe PDF" on a XP-SP2 with Active-X, in IE, authorized.

Link to comment
Share on other sites

Michel Claveau:

Thank you for your second suggestion ... it worked for me too ... it was then that I realized that your first suggestion also works ... didn't work initially because I did not catch the part about the double back-slashes in your first suggestion ... :D ... sorry about that and thank you for your assistance.

Thank you nfwu for your assistance as well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...