Jump to content
Sign in to follow this  
Volgar

Run compiled script with parameters

Recommended Posts

Volgar

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

Share this post


Link to post
Share on other sites
Yashied
Volgar

TempFile()?

Maybe. I am totally new to AutoIt. Where i can read about this feature, please? Edited by Volgar

Share this post


Link to post
Share on other sites
Yashied
Volgar

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?

Share this post


Link to post
Share on other sites
Yashied

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

Share this post


Link to post
Share on other sites
Volgar

#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'...... :)

Share this post


Link to post
Share on other sites
Yashied

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

Share this post


Link to post
Share on other sites
Volgar

Sorry, Yashied,

it is so simple that I had not even thought

Thank you!

:)

Share this post


Link to post
Share on other sites
Volgar

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

Share this post


Link to post
Share on other sites
Yashied

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

Share this post


Link to post
Share on other sites
Volgar

I am very hurry. Now I have all clear. Thank you.

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
Sign in to follow this  

×