[solved] IE.Navigate kennt kein getContext() Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

[solved] IE.Navigate kennt kein getContext()

27 Aug 2015, 04:06

Ich hab folgendes AutoHotkey-Script, das mittels AktivX Control mein gut funktionierendes Java-Script benutzt, um ein paar Linien in einem Fenster zu zeichnen:

Code: Select all

#SingleInstance, Force              ; kill old instance
#NoTrayIcon                     	; don't show tray icon at start
#NoEnv                              ; don't check empty variables

Menu, Tray, Icon, %A_WinDir%\System32\shell32.dll, 44
Menu, Tray, Icon ; show

Gui, -MinimizeBox
Gui, Add, ActiveX, w360 h170 E0x200 vIE, Shell.Explorer
Gui, Show,, 3D Mesh

IE.Navigate(A_ScriptDir "\3D Mesh.html")

Esc::
GuiEscape:
GuiClose:
ExitApp
Spoiler
Die .html-Datei mitsamt der .js-Datei klappt prima. Ich hab getestet mit Internet Explorer, FireFox und Opera. Alle diese Browser zeigen mir die zu zeichnenden Linien wie gewünscht an.
Aber wenn ich AHK mit AktivX benutze, bekomme ich folgende Fehlermeldung:
Das Objekt unterstützt die Eigenschaft oder Methode "getContext" nicht.

Ich weiß, daß dies kein Forum für Java-Script ist, ich denke aber, daß mein Problem in den paar Zeilen AHK Code liegt.
Kann mir da jemand auf die Sprünge helfen, wie ich meine Linien im AHK-Fenster zeichnen kann?
Warum kennt die AktivX-Control kein getContext? Im den Browsern geht's doch auch.
Last edited by wolf_II on 31 Aug 2015, 14:21, edited 2 times in total.
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: IE.Navigate kennt kein getContext()

27 Aug 2015, 13:32

hello wolf_II
hier Dein script komplett , mit Mozilla funktioniert's gut
mit shell.explorer Fehlermeldung :
Object doesn't support this property or method

Code: Select all

;-------- http://ahkscript.org/boards/viewtopic.php?f=9&t=9308 ---
#SingleInstance, Force              ; kill old instance
#NoTrayIcon                     	; don't show tray icon at start
#NoEnv                              ; don't check empty variables

f1=%a_scriptdir%\3D_Mesh.html
f2=%a_scriptdir%\3D_Mesh.js
ifnotexist,%f1%
  gosub,a1
ifnotexist,%f2%
  gosub,a2

;xxa=Shell.Explorer   ;- Object doesn't support this property or method
xxa=Mozilla.Browser   ;- OK

Menu, Tray, Icon, %A_WinDir%\System32\shell32.dll, 44
Menu, Tray, Icon ; show

Gui, -MinimizeBox
Gui, Add, ActiveX, w360 h170 E0x200 vIE, %xxa%
Gui, Show,, 3D Mesh
IE.Navigate(F1)
return

Esc::
GuiEscape:
GuiClose:
ExitApp
;------------------------------

a1:
e4x=
(
<html>
<body>
<canvas id="Cube" style="border:1px solid #d3d3d3;">
<script src="3D_Mesh.js"></script>
</body>
</html>
)
Fileappend,%e4x%,%f1%
return
;------------------------------
a2:
e5x=
(
//------------------------------------------------------------------------------
// 3D Mesh.js
// by wolf_II
//------------------------------------------------------------------------------
// draw two 3D meshes of a Rubik's Cube
// parameterized for size and order of the cube
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
function draw_R(ctx, s, x, y) { // draw an angled line to the right and down
//------------------------------------------------------------------------------
    // s = scaling factor / size
    // start at the highest point (x, y)
    //--------------------------------------------------------------------------
    ctx.beginPath()
    ctx.moveTo(x, y)
    ctx.lineTo(x + 8 * s, y +  3 * s)
    ctx.lineTo(x + 8 * s, y + 12 * s)
    ctx.stroke()
}

//------------------------------------------------------------------------------
function draw_L(ctx, s, x, y) { // draw an angled line to the left and down
//------------------------------------------------------------------------------
    // s = scaling factor / size
    // start at the highest point (x, y)
    //--------------------------------------------------------------------------
    ctx.beginPath()
    ctx.moveTo(x, y)
    ctx.lineTo(x - 8 * s, y +  3 * s)
    ctx.lineTo(x - 8 * s, y + 12 * s)
    ctx.stroke()
}

//------------------------------------------------------------------------------
function draw_H(ctx, s, x, y) { // draw an angled line to connect horizontally
//------------------------------------------------------------------------------
    // s = scaling factor / size
    // start at the leftmost point (x, y)
    //--------------------------------------------------------------------------
    ctx.beginPath()
    ctx.moveTo(x, y)
    ctx.lineTo(x +  8 * s, y + 3 * s)
    ctx.lineTo(x + 16 * s, y)
    ctx.stroke()
}

//------------------------------------------------------------------------------
function draw_3Dmesh(ctx, s, d, n, x) { // draw a 3D mesh of a Rubik's Cube
//------------------------------------------------------------------------------
    // s = scaling factor / size
    // d = distance from edges
    // n = order of cube, e.g. 3x3x3: n = 3
    // x = x-coord of the highest point
    //--------------------------------------------------------------------------
    for (i = 0; i <= n; i++) {
        if (n == 0) {   // outlines only
            m = 0; h = -12
        } else {        // n sub-divisions
            m = i * s / n
            h = i * 9 / n - 12
        }
        draw_R(ctx, s, x - 8 * m, d + m * 3)
        draw_L(ctx, s, x + 8 * m, d + m * 3)
        draw_H(ctx, s, x - 8 * s, d - h * s)
    }
}

//------------------------------------------------------------------------------
function draw_2cubes(s, n) { // draw 2 cubes next to each other
//------------------------------------------------------------------------------
    // s = scaling factor / size
    // n = order of the cubes
    //--------------------------------------------------------------------------

    // distance from edges is hardcoded here to be equal to the scaling factor
    // it is possible to have d as an additional parameter for this function
    d = s

    canvas = document.getElementById("Cube")
    canvas.width  = s * 36
    canvas.height = s * 17
    ctx = canvas.getContext("2d")
    ctx.lineWidth = "2"

    x = 8 * s + d // x-coord of the highest point
    draw_3Dmesh(ctx, s, d, n,     x)
    draw_3Dmesh(ctx, s, d, n, 3 * x)
}
draw_2cubes(8, 3)
)
fileappend,%e5x%,%f2%
return
;------------------------------
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: IE.Navigate kennt kein getContext()

27 Aug 2015, 14:37

Hi garry,

besten Dank dafür, daß Du Dir die Zeit genommen hast, zu testen. Ich hab Deine Änderung hier getestet, leider ohne Erfolg.
Mit Mozilla.Browser bekomme ich dieselbe Fehlermeldung wie mit dem Shell.Explorer.
(Das Objekt unterstützt die Eigenschaft oder Methode "getContext" nicht.)

Ich hab sowohl mein Script geändert, als auch Dein Script getestet, welches die Dateien ohne Leerzeichen im Namen erzeugt.
Dasselbe Resultat, immer die gleiche Fehlermeldung.

Ich benutze:
- Windows 7 Home Premium (Deutsch)
- Internet Explorer 11 (Update Version 11.0.22)
- FireFox Version 40.0.3
- AutoHotkey v1.1.21.00

Ich werde AHK updaten, und weiter testen.

Edit: AutoHotkey ist jetzt v1.1.22.04, leider gleiches Resultat.
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: IE.Navigate kennt kein getContext()

27 Aug 2015, 15:37

ich habe XP netbook
Internet Explorer nicht verwendet
Mozilla Firefox (40.0.3) und Autohotkey unicode32-bit zip-file (1.1.22.04) , beide neueste Version
ich hatte Dein script nicht geändert , lediglich zusammengefasst ( aut. Erstellung der 2-files )
Joe
Posts: 29
Joined: 02 Oct 2013, 04:21

Re: IE.Navigate kennt kein getContext()  Topic is solved

31 Aug 2015, 10:39

Das Problem ist, dass das ActiveX standardmäßig den IE 7 verwendet, der getContext() noch nicht kann. Man kann aber mit einer Meta-Angabe dafür sorgen, dass die Engine des neuesten im System installierten IE verwendet wird. Die 3D Mesh.html müsste dann so aussehen:

Code: Select all

<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<body>
<canvas id="Cube" style="border:1px solid #d3d3d3;">
<script src="3D Mesh.js"></script>
</body>
</html>
Wenn weiter die Fehlermeldung kommt, einfach den IE-Cache löschen.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: IE.Navigate kennt kein getContext()

31 Aug 2015, 14:20

@Joe:
:D
Ich danke Dir. Das funktioniert genau wie ich das wollte.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 51 guests