Jump to content

AutoItX + PHP


dbzsoft
 Share

Recommended Posts

How I use AutoItX in PHP?...

This is a example in php but where i find those files:"WScript.Shell" and "AutoItX3.Control"... where i can download it... because this script dont work... :blink:

<?php

$oShell = new COM("WScript.Shell");

$oAutoIt = new COM("AutoItX3.Control");

//WScript.Echo "This script will run notepad and type in some text"

$oShell->Run("notepad.exe", 1, FALSE);

$oAutoIt->WinWaitActive("Sans titre - Notepad2", "");

$oAutoIt->Send("Hello, this is line 1{ENTER}");

$oAutoIt->Send("This is line 2{ENTER}This is line 3");

$oAutoIt->Sleep(1000);

$oAutoIt->Send("!{F4}");

$oAutoIt->WinWaitActive("Notepad2", "Enregistrer les modifications de \"Sans titre\"?");

$oAutoIt->Send("!n");

$oAutoIt->WinWaitClose("Sans titre - Notepad2", "");

?>

Please help me...

Link to comment
Share on other sites

  • Developers

Download the installer or ZIP version and register the DLL as described in the Helpfile AutoItX.chm.

Before you can use the COM interface to AutoItX it needs to be "registered" (This is done automatically when you install the full version of AutoIt but you may need to do it manually if you are using AutoItX separately).

To register the COM interface:

1. Open a command prompt

2. Change directory (using CD) to the directory that contains AutoItX3.dll

3. Type regsvr32.exe AutoItX3.dll and press enter

The name of the AutoItX control is AutoItX3.Control

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you for your answer Jos, but that's doesn't work too !! for the first script

I have to do something with WScript.Shell??

But this script worked perfect.....

<?

$obj = new COM("AutoItX3.Control");

$obj->CDTray ("H:", "open");

$obj->Sleep (1000);

$obj->CDTray ("H:", "close");

?>

<html>

<center>CD Tray Opened and closed successfully!</center>

</html>

why didnt work the first script??

Edited by dbzsoft
Link to comment
Share on other sites

  • Developers

You need to go to the Microsoft site to get more info on it.

Likely the wscript DLL isn't properly loaded/registered.

looks for "microsoft wsh"

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Interesting topic that I'll monitor.

dbzsoft, what happens when you run the first PHP script? What result do you get from PHP output? What happens on the PHP server side? Assuming you have the server desktop open/logged in.

Perhaps WScript or rather Windows Scripting Host (WSH) wasn't meant for use outside of the GUI & command line environments (e.g. in web scripts like PHP, ASP, etc.). I don't recall seeing much examples of using WSH inside Microsoft's own web technologies like ASP.

dbzsoft, I suggest you try $oShell->Exec("notepad.exe"...); //you'll have to Google for exact API call, I don't know it. Searching online, came across this post:

http://www.visualbasicscript.com/m34590.aspx

where it is mentioned that Exec doesn't have (command line) Window (control), whereas Run does. I believe Run is the more commonly used version. But the command prompt "window" might be what is giving you trouble because you're calling it from PHP?

As a last resort, if you must script from the web, you should look for options that don't require you to invoke something like WSH to do a shell execute. Look for something that gives you native shell execute functionality. Perhaps these might work for you:

PHP + AutoIt, but use native PHP shell execute funtionality (assuming this works in Windows)

(e.g. http://php.net/manual/en/function.shell-exec.php )

(e.g. http://php.net/manual/en/function.exec.php )

ASP.NET + AutoIt

ActiveState Perlscript + ASP + AutoIt

Edited by daluu
Link to comment
Share on other sites

Executing GUI application (like Notepad) from a Web server script is only possible if the server is run as program on the desktop of currently logged-in user or as service in system context with permission to interact with user's desktop. None of these conditions is usually true, this is for a good reason: Web server interacting with desktop would pose serious security risk.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

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...