Jump to content

Run compiled script with parameters


Recommended Posts

Hi,

Several months ago I asked how to use AutoIt to make a screenshot. Thanks @FireFox, I realized all of this.

#include <ScreenCapture.au3>

$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$out = FileSaveDialog('Save screenshot', '', '(*.bmp)',1+2,'screenshot.bmp')
_ScreenCapture_SaveImage($out, $scc)

Now I want to name the file that generates the AutoIt (screenshot.bmp) was random, such as "a1rld232tsdyzh2.bmp". How can this be done? I can do this of my program, but how then can send a variable containing the file name to the script? Is it possible to run script with parameters?

Most simply that comes to mind is to create a text file with the file name and read it by AutoIt and then record in the variable.

Edited by Volgar
Link to comment
Share on other sites

Thanks Yashied. I looked up an example from Help, this is what I want.

Only I do not understand how the variable $s_FileName send instead 'screenshot.bmp', and then how to write a text file with $s_FileName?

Link to comment
Share on other sites

Thanks Yashied. I looked up an example from Help, this is what I want.

Only I do not understand how the variable $s_FileName send instead 'screenshot.bmp', and then how to write a text file with $s_FileName?

$s_FileName = _TempFile(@TempDir, "~", ".bmp")
Link to comment
Share on other sites

#include <ScreenCapture.au3>
#Include <File.au3>

$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$s_FileName = _TempFile(@TempDir, "~", ".bmp")
$out = FileSaveDialog('Save screenshot', '', '(*.bmp)',1+2,'screenshot.bmp')
_ScreenCapture_SaveImage($out, $scc)
MsgBox(4096, "Info", "Names suitable for new temporary file : " & @LF & @LF & $s_FileName)

I apologize, but did not understand how the filename in the variable $s_FileName may be transmitted instead of 'screenshot.bmp'...... :)

Link to comment
Share on other sites

#include <ScreenCapture.au3>
#Include <File.au3>

$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$s_FileName = _TempFile(@TempDir, "~", ".bmp")
$out = FileSaveDialog('Save screenshot', '', '(*.bmp)',1+2,'screenshot.bmp')
_ScreenCapture_SaveImage($out, $scc)
MsgBox(4096, "Info", "Names suitable for new temporary file : " & @LF & @LF & $s_FileName)

I apologize, but did not understand how the filename in the variable $s_FileName may be transmitted instead of 'screenshot.bmp'...... :)

#include <ScreenCapture.au3>
#Include <File.au3>

$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$s_FileName = _TempFile(@TempDir, "~", ".bmp")
$out = FileSaveDialog('Save screenshot', '', '(*.bmp)',1+2,$s_FileName)
_ScreenCapture_SaveImage($out, $scc)
MsgBox(4096, "Info", "Names suitable for new temporary file : " & @LF & @LF & $s_FileName)
Link to comment
Share on other sites

Another small question. Yashied, I found that you are the author of the script FTP library.

Now, my challenge to upload a screenshot file to the server. I try to do so, but it did not send. What could be wrong? Thanks...

#include <ScreenCapture.au3>
#Include <File.au3>
#Include <FTP.au3>


$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$s_FileName = _TempFile(@TempDir, "www_", ".jpg")
$out = FileSaveDialog('Save screenshot', '', '(*.jpg)',1+2,$s_FileName)
_ScreenCapture_SaveImage($out, $scc)

$file = FileOpen("test.txt", 1)
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWrite($file, $s_FileName)
FileClose($file)

const $Host = 'ftp:/222.122.3.333/test/'
const $Login = 'sasasasa'
const $Password = 'asdasdsad'

local $hFtp, $hSession, $hFind, $tFind

_FTP_Startup()

$hFtp = _FTP_Open('MyFtp')
$hSession = _FTP_Connect($hFtp, $Host, $Login, $Password)

$tFind = DllStructCreate($tagWIN32_FIND_DATA)
$hFind = _FTP_FileFindFirst($hSession, '', $tFind)
while not @error
    ConsoleWrite(DllStructGetData($tFind, $s_FileName) & @CR)
    _FTP_FileFindNext($hFind, $tFind)
wend
_FTP_FileFindClose($hFind)
    
_FTP_Disconnect($hSession)
_FTP_Close($hFtp)

_FTP_Shutdown()
Link to comment
Share on other sites

Another small question. Yashied, I found that you are the author of the script FTP library.

Now, my challenge to upload a screenshot file to the server. I try to do so, but it did not send. What could be wrong? Thanks...

#include <ScreenCapture.au3>
#Include <File.au3>
#Include <FTP.au3>


$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$s_FileName = _TempFile(@TempDir, "www_", ".jpg")
$out = FileSaveDialog('Save screenshot', '', '(*.jpg)',1+2,$s_FileName)
_ScreenCapture_SaveImage($out, $scc)

$file = FileOpen("test.txt", 1)
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWrite($file, $s_FileName)
FileClose($file)

const $Host = 'ftp:/222.122.3.333/test/'
const $Login = 'sasasasa'
const $Password = 'asdasdsad'

local $hFtp, $hSession, $hFind, $tFind

_FTP_Startup()

$hFtp = _FTP_Open('MyFtp')
$hSession = _FTP_Connect($hFtp, $Host, $Login, $Password)

$tFind = DllStructCreate($tagWIN32_FIND_DATA)
$hFind = _FTP_FileFindFirst($hSession, '', $tFind)
while not @error
    ConsoleWrite(DllStructGetData($tFind, $s_FileName) & @CR)
    _FTP_FileFindNext($hFind, $tFind)
wend
_FTP_FileFindClose($hFind)
    
_FTP_Disconnect($hSession)
_FTP_Close($hFtp)

_FTP_Shutdown()
What are you doing? You just pasted my example in your code, not even knowing how it works and what does! Do you think I am stupid to not see this? I have no desire to write your program for you. Here's how my FTP.au3 to work, then think for yourself.

#include <ScreenCapture.au3>
#Include <File.au3>
#Include <FTP.au3>


$scc = _ScreenCapture_Capture('', 0, 0, -1, -1, True);Capture all screen
$out = FileSaveDialog('Save screenshot', '', '(*.jpg)', 1 + 2, _TempFile('', "www_", ".jpg"))
_ScreenCapture_SaveImage($out, $scc)

$file = FileOpen("test.txt", 1)
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWriteLine($file, $out)
FileClose($file)

const $Host = 'ftp:/222.122.3.333/test/'
const $Login = 'sasasasa'
const $Password = 'asdasdsad'

Local $hFtp, $hSession

_FTP_Startup()
$hFtp = _FTP_Open('MyFtp')
$hSession = _FTP_Connect($hFtp, $Host, $Login, $Password)
_FTP_PutFile($hSession, $out, StringRegExpReplace($out, "^.*\\", ""))
_FTP_Disconnect($hSession)
_FTP_Close($hFtp)
_FTP_Shutdown()
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...