Jump to content

Send variable to PHP


nick2price
 Share

Recommended Posts

Hi, this is my first time using autoit so not too sure what it can do.  I have searched around but I am unable to find a solution.  I have a simple php script which should execute my autoit file

<?php

$output = shell_exec('autoit test2.au3');
echo "<pre>$output</pre>";

The file this should execute contains the following

Global $Process = ('Firefox.exe')

While 1
If ProcessExists ($Process) Then
   Return "EXIST"
Else
  Return "DOESNT EXIST"
ExitLoop
EndIf

When I visit test.php in the browser I was hoping it would execute my autoit file and then display either EXIST or DOESNT EXIST on the screen.  At the moment, nothing happens, just a blank screen.

Is there any way to execute my autoit script via php, and have this script return something for my php to display?

Many thanks

Nick

Edited by nick2price
Link to comment
Share on other sites

Why do you need AutoIt for this?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Try this:

<?php

$output = exec('C:\Program Files (x86)\AutoIt3\AutoIt3.exe test2.au3');
echo "<pre>$output</pre>";

 

TD :)

Edited by TheDcoder
Wrong syntax highlighting

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Thanks :)

One last thing I just wanted to clarify.  So I have this part

If ProcessExists ($Process) Then
    ConsoleWrite ("1")

I dont intend for the ConsoleWrite to be there, I have it for testing purposes.  Instead, if the process exists, I need to make sure it is the active window so I can perform things like CTRL + C within this application.  I see from the docs this function

WinActivate($hWnd)

So is it simply a case of doing something like this?

If ProcessExists ($Process) Then
  ConsoleWrite ("1")
  WinActivate($Process)
  Send("^v")

 

Link to comment
Share on other sites

@nick2price Use

Send('^c')

^v means Ctrl + V not Ctrl+ C (as you would see in command prompt)

 

TD :)

 

Edit: WinActivate won't work, You need the title/hWnd/class of the window to activate the windows, Read the documentation for more info :)

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

@nick2price You can use the AU3Info tool (Tools -> AU3Info in Full Installation of SciTE) to know the class of the window :)

 

P.S You only need one of these: title/hWnd/class, Not all of them :)

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

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