Jump to content

PHP - AutoIT


Buklerx
 Share

Recommended Posts

Hi everybody, I' d like to send an e-mail using an auto-it program and using the php script.

This is my PHP code:

<?php
$header = "From: $email\r\nReply-to: $email\r\n";
$mymail = "MYEMAIL";
$sub = "Oggetto";
mail($mymail,$sub,"Mittente: $email\r\nText: $text",$header);
?>

And I' ve done the AutoIt GUI with KODA:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Send Text", 250, 162, 192, 124)
$Button1 = GUICtrlCreateButton("Send", 80, 128, 97, 25)
$Input1 = GUICtrlCreateInput("", 48, 32, 161, 21)
$Input2 = GUICtrlCreateInput("", 48, 88, 161, 21)
$Label1 = GUICtrlCreateLabel("Mail", 112, 8, 23, 17)
$Label2 = GUICtrlCreateLabel("Text", 104, 64, 50, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

How can I connect them?

Edited by Buklerx
Link to comment
Share on other sites

This might work (without ANY error checking)...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Send Text", 250, 162, 192, 124)
$Button1 = GUICtrlCreateButton("Send", 80, 128, 97, 25)
$Input1 = GUICtrlCreateInput("", 48, 32, 161, 21)
$Input2 = GUICtrlCreateInput("", 48, 88, 161, 21)
$Label1 = GUICtrlCreateLabel("Mail", 112, 8, 23, 17)
$Label2 = GUICtrlCreateLabel("Text", 104, 64, 50, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
 
 
Global $email, $text
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUISetState(@SW_HIDE)
            ProgressOn("Email", "Sending Email...")
            $email = GUICtrlRead($Input1)
            $text = GUICtrlRead($Input2)
            $oIE = _IECreate("www.yourdomain.com/email_script.php?email=" & $email & "&text=" & $text, 0, 0, 1)
            Switch @error
                Case 0
                    ProgressOn("Email", "Email sent successfully...")
                Case Else
                    ProgressOn("Email", "Email NOT sent successfully...")
            EndSwitch
            Sleep(500)
            ProgressOff()
            GUISetState(@SW_SHOW)
            _IEQuit($oIE)
    EndSwitch
WEnd

Maybe the php script sould return a status to check against...

Edited by KaFu
Link to comment
Share on other sites

Something like this: (untested)

email.php:

<?php
$header = "From: $email\r\nReply-to: $email\r\n";
$mymail = "MYEMAIL";
$sub = "Oggetto";
if (mail($mymail,$sub,"Mittente: ".$_GET['email']."\r\nText: ".$_GET['text'],$header)){
    echo 1;
}
else{
    echo 0;
}
?>

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Send Text", 250, 162, 192, 124)
$Button1 = GUICtrlCreateButton("Send", 80, 128, 97, 25)
$Input1 = GUICtrlCreateInput("", 48, 32, 161, 21)
$Input2 = GUICtrlCreateInput("", 48, 88, 161, 21)
$Label1 = GUICtrlCreateLabel("Mail", 112, 8, 23, 17)
$Label2 = GUICtrlCreateLabel("Text", 104, 64, 50, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
 
 
Global $email, $text
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUISetState(@SW_HIDE)
            ProgressOn("Email", "Sending Email...")
            $email = GUICtrlRead($Input1)
            $text = GUICtrlRead($Input2)
            If BinaryToString(InetRead("http://www.yousite.com/email.php?email=" & $email & "&text=" & $text)) Then
                ProgressOn("Email", "Email sent successfully...")
            Else
                ProgressOn("Email", "Email NOT sent successfully...")
            EndIf
            Sleep(500)
            ProgressOff()
            GUISetState(@SW_SHOW)
    EndSwitch
WEnd

edit: forgot to remove _IEQuit()

Edited by Tvern
Link to comment
Share on other sites

It works rlly nice thanks for the help! Have 2 questions:

Question 1:

I have $Form1 that is the GUI of the main program but I want an other form $Form2 to show the info of the program, what' s the code? I wrote something like this:

Case $fileitem4
        $Form2 = GUICreate("Info", 242, 74, 192, 124)
        $Label1 = GUICtrlCreateLabel("Program v 1.0", 67, 16, 104, 17)
        $Label2 = GUICtrlCreateLabel("Created by Buklerx", 64, 48, 114, 17)
        GUISetState(@SW_SHOW)

But when i close the Info form it closes all the program.

Question 2:

If I put an image in a program, when I sed it to my friend they don't see it, what was the code to include the picture in the exe?

Link to comment
Share on other sites

Q1:

You can set GuiGetmsg() to advanced. That way you can check what GUI window send the $GUI_EVENT_CLOSE message. See the helpfile for details.

You could also disable the standard x button on the info GUI and add a close button. Experiment with window styles to find a style that you like.

Q2

The easiest way to include an image is to fileinstall the image to the temp folder.

It is possible to use images directly when included in the exe, but it get's a little more tricky. If you want to do so, I believe the recource UDF you can find in the examples forum has some usefull functions.

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