Jump to content
nick2price

Send variable to PHP

Recommended Posts

nick2price

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

Share this post


Link to post
Share on other sites
guinness

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

Share this post


Link to post
Share on other sites
nick2price

I dont specifically need autoit for this part, but further down the line I need to execute commands in a program like Ctrl + P which I think I need autoit for.

Share this post


Link to post
Share on other sites
TheDcoder

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
  • Like 1

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
nick2price

I actually got it working by compiling the script to an exe.  I imagine you normally convert scripts to exe when they are complete?

Share this post


Link to post
Share on other sites
TheDcoder

@nick2price Yep, That's what you do :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
nick2price

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")

 

Share this post


Link to post
Share on other sites
TheDcoder

@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
  • Like 1

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
nick2price

Thanks, looking at the docs now.  I understand how I can get the title and hWnd of a window.  What would the CLASS be?

Share this post


Link to post
Share on other sites
TheDcoder

@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
  • Like 1

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
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

×