Schlagwort-Archive: autoit

autoit Syntax Funktionstasten, Hot-Keys

Man kann das Betätigen von Tasten per Hot-Key-Funktion abfragen.

 

z.B.: die Hilfetaste F1

 

Parameter können bei diesem Funktionsaufruf nicht übergeben werden.

 

HotKeySet("{F1}", "HelpBox")

 

Func HelpBox()

  MsgBox(32, "- Hilfe -", "Hilfe:" & @CRLF &  "Dieses Programm dient zum Eingeben der Customfelder in die LANDesk LDMS Datenbank." & @CRLF _

  & "Die INI-Datei namens FLG_PC_Neu.ini muss im selben Verzeichnis liegen, wie dieses Programm." & @CRLF & @CRLF  _

  & "Im Register PC-Suche kann man nachsehen, ob der PC-Name schon in der DB vorhanden ist." & @CRLF _

  & "Dann werden die Daten im Register Eingabe aktualisiert und ergänzt." & @CRLF _

  & "Die neuen Daten werden in der Datenbank gespeichert."  & @CRLF & @CRLF  _

  & "Im Register Einstellungen kann man nach korrekter Passworteingabe die verschlüsselt gespeicherten Daten in der INI-Datei ansehen und ändern.." & @CRLF & @CRLF _

  & "—————————————————————————-" & @CRLF & @CRLF _

  & "Man kann dieses Programm mit folgenden Parametern starten:" & @CRLF _

  & "        diese Hilfe:        /h oder /? oder -h oder -? " & @CRLF _

  & "        DebugMode:        /d oder -d" & @CRLF & @CRLF _

  & "—————————————————————————-" & @CRLF & @CRLF _

  & "Bei Fragen oder Änderungswünschen wende man sich an " & IniRead($ProgIniFile,"FLG","ProgrammerName","George") & @CRLF _

  & "Phone: " & IniRead($ProgIniFile,"FLG","ProgrammerPhone","+49 2773 924 3915") & " · mailto: " & IniRead($ProgIniFile,"FLG","ProgrammerMail","quinting.g@loh-services.de"))

EndFunc        ; HelpBox

 

 

autoit Syntax FTP und DLL

FTP with AutoIT – API Programming

It is really easy to call Win32 API functions through AutoIT. All that one needs to know is how to use the “DllCall” function in AutoIT and the functions which are available in the particular dll that one intends to utilize. In order to create an FTP client, it is really easy if one uses AutoIT. We can make use of the “Wininet.dll” for the sake of creating FTP client software. The functions that are useful for us will be as follows:

InternetOpen

InternetConnect

FtpGetFile

FtpPutFile

FtpFindFirstFile

InternetFindNextFile

InternetCloseHandle

There are many more functions which are available with wininet.dll, but in order to make the Ftp client software, the above mentioned files are more than enough. Now, let me describe the step by step process which needs to be followed in order to do an Ftp get.

1.Open an Internet Connection – This is to initialize the wininet API. One can use any connection name for achieving this 

1.$InternetOpen = DllCall("wininet.dll", "long", "InternetOpen", "str", “My FTP Control”, "long", 1, "str", “”, "str", “”, "long", 0);We can keep the proxy name and proxy bypass as blank.

2.Connect to the server with the username and password – One need to have a username and password for the same, as well as the handle returned from the previous step

2.$InternetConnect = DllCall("wininet.dll", "long", "InternetConnect", "long", $InternetOpen, "str", $ServerName, "int", 0, "str", $Username, "str", $Password, "long", 1, "long", 0, "long", 0); Servername, Username, Password need to be provided.

3. Start the file transfer with FtpGetFile function – Filename and handle needs to be provided as the inputs

3.$FTPget = DllCall("wininet.dll", "int", "FtpGetFile", "long", $InternetConnect, "str", $RemoteFile, "str", $SaveLocalFile, "int", 0, "long", 0, "long", 0, "long", 0);This would save the file in the local computer with the name as provided in place of variable $SaveLocalFile.

4. Close both the handles

4.$CloseCC = DllCall("wininet.dll", "int", "InternetCloseHandle", "int", $InternetOpen)

4.$CloseCC = DllCall("wininet.dll", "int", "InternetCloseHandle", "int", $InternetConnect)

That’s all the one needs. The file would be saved in the local machine with the desired name. For more details on the functions in wininet.dll, one can visit http://msdn.microsoft.com/en-us/library/aa385473%28VS.85%29.aspx.

 

I have created Ftp client software with the same function, and you can download it freely by clicking here.

 

If you want to access the code, kindly post a request for it through the comments section. I will share the code with anyone who requires.

Posted by Kishore Krishnan at 9:30 PM

Labels: API Programming, FTP Client, Wininet.dll

 


 

wininet.dll

FtpCommand function

The FtpCommand function sends commands directly to an FTP server.

 

Syntax

C++

BOOL FtpCommand(

 _In_   HINTERNET hConnect,

 _In_   BOOL fExpectResponse,

 _In_   DWORD dwFlags,

 _In_   LPCTSTR lpszCommand,

 _In_   DWORD_PTR dwContext,

 _Out_  HINTERNET *phFtpCommand

);

 

Parameters

hConnect [in]
A handle returned from a call to InternetConnect.

fExpectResponse [in]
A Boolean value that indicates whether the application expects a data connection to be established by the FTP server. This must be set to TRUE if a data connection is expected, or FALSE otherwise.

dwFlags [in]
A parameter that can be set to one of the following values.

Value

Meaning

FTP_TRANSFER_TYPE_ASCII

Transfers the file using the FTP ASCII (Type A) transfer method. Control and formatting data is converted to local equivalents.

FTP_TRANSFER_TYPE_BINARY

Transfers the file using the FTP Image (Type I) transfer method. The file is transferred exactly with no changes. This is the default transfer method.

 

lpszCommand [in]
A pointer to a string that contains the command to send to the FTP server.

dwContext [in]
A pointer to a variable that contains an application-defined value used to identify the application context in callback operations.

phFtpCommand [out]
A pointer to a handle that is created if a valid data socket is opened. The fExpectResponse parameter must be set to TRUE for phFtpCommand to be filled.

 

Return value

Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError.

 

Remarks

GetLastError can return ERROR_INTERNET_NO_DIRECT_ACCESS if the client application is offline. If one or more of the parameters are invalid, GetLastError will return ERROR_INVALID_PARAMETER.

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

Note  WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).

 

 

autoit Syntax ERROR-Function

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

 

; ===================================================

 

Func MyErrFunc() ; ————————————————————————-

 

$hexnum=hex($objErr.number,8)

 

Msgbox(0,"","We intercepted a COM Error!!"      & @CRLF                & @CRLF & _

            "err.description is: " & $objErr.description   & @CRLF & _

            "err.windescription is: " & $objErr.windescription & @CRLF & _

            "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _

            "err.scriptline is: "   & $objErr.scriptline    & @CRLF & _

            "err.number is: "       & $hexnum               & @CRLF & _

            "err.source is: "       & $objErr.source        & @CRLF & _

            "err.helpfile is: "       & $objErr.helpfile      & @CRLF & _

            "err.helpcontext is: " & $objErr.helpcontext _

           )

exit

 

EndFunc ;  MyErrFunc()  ————————————————————————-

 

 

 

autoit Syntax Encrypt, Verschlüsseln

die Funktion _StringEncrypt(), die in älteren Versionen von autoit in string.au3 enthalten war,

gibt es ab autoit 3.3.12.0 nicht mehr.

 

Die Funktion _StringEncrypt() ist nun in crypt_GQ.au3  enthalten.

 

In diesem Script:

       D:\DATA\_INFO\_SoftWare\_LANdesk_\_SW-Verteilung\Quinting\_TEST_\Encryption\_Test_Encrypt_2.au3

wird sowohl die alte als auch die neue Verschlüsselung exemplarisch genutzt.

 


 

alte Funktion (vor 3.3.12.0)

 

#include <crypt_GQ.au3>

 

$Debug = 1                ; default: 0

$Text = "Hallo"

$CryptPass = "Passwort"

$Methode = "alt"        ; (eine von "alt|3DES|AES128|AES192|DES|RC2|RC4")

$KeyDepth = 2                ; default: 2

$verschluesselt =_Verschluesseln($Text,$CryptPass,[$Methode,[$KeyDepth;[$Debug]]])

 

$Debug = 0                ; default: 0

$Text = "0229813FB7566E6E499C20994E4FE048745E2BBC"

$CryptPass = "Passwort"

$Methode = "alt"        ; (eine von "alt|3DES|AES128|AES192|DES|RC2|RC4")

$KeyDepth = 2                ; default: 2

$entschluesselt =_Entschluesseln($Text,$CryptPass,[$Methode,[$KeyDepth;[$Debug]]])

 


 

Login mit autoit und PHP:

 

PHP-Datei: check.php

<?php

$host = 'yourhost';

$user = 'dbusername';

$pass = 'dbpassword';

$dbase = 'yourdatabase';

 

mysql_connect($host, $user, $pass);

mysql_select_db($dbase);

 

$sUsername = mysql_real_escape_string($_GET[‚username‘];

$sPassword = md5(mysql_real_escape_string($_GET[‚password‘]));

 

$result = mysql_query("SELECT id FROM TABLE WHERE username = '" . $sUsername . "' AND password = '" . $sPassword . "'"); // Your SQL Statement

$row = mysql_fetch_row($result);

 

if ($row) {

  echo 1;

} else {

  echo 0;

}

?>

 

autoit Script:

#include <INet.au3>

$user = InputBox("Login", "Please enter your username", "", "")

$pass = InputBox("Login", "Please enter your password", "", "")

$iRValue = _INetGetSource("http://yourdomain.de/check.php?username=" & $user & "&password=" & $pass)

if $iRValue = 1 Then

  ; Login Successfully

ElseIf $iRValue = 2 Then

  ; Login Failed

EndIf

 


 

MD5 Check mit autoit und PHP:

 

PHP-Datei: check.php

<?php

$sPassword = 'password';

$md5 = md5($sPassword);

echo $md5

?>

 

autoit Script:

#include <INet.au3>

$pass = InputBox("Login", "Please enter your password", "", "")

$iRValue = _INetGetSource("http://DE19HAI827004NB.de.flg.int/vplaner/check.php?password=" & $pass)

msgbox(64,"Info", "Passwort: " & $pass & @crlf & "MD5-Hash: " & $iRValue)

 

autoit Syntax Datum und Zeit

Makro Description Example
@YEAR Current four-digit year 2016
@MON Current month.  Range is 01 to 12 11
@MDAY Current day of month.  Range is 01 to 31 25
@HOUR Hours value of clock in 24-hour format.  Range is 00 to 23 08
@MIN Minutes value of clock.  Range is 00 to 59 48
@SEC Seconds value of clock.  Range is 00 to 59 59

 

Beispiel für Datum mit 2-stelliger Jahreszahl und Zeit: 131025-0848

       StringRight(@YEAR,2) & @MON & @MDAY & "-" & @HOUR & @MIN

 

Beispiel für Datum mit 4-stelliger Jahreszahl und Zeit: 20.01.2014 09:23

       @MDAY & "." & @MON & "." & @YEAR & " " & @HOUR & ":" & @MIN

 

Beispiel kopiert Filename.ext zu Filename_ext_131025-0848.bck

       wobei $File den Dateinamen enthält.

$aFilename = StringSplit($File,".")

FileCopy ( $File, $aFilename[1] & „_“ & $aFilename[2] & StringRight(@YEAR,2) & @MON & @MDAY & "-" & @HOUR & @MIN & ".bck" [, flag])        

 

Flag:    0        default, no overwrite existing files
1        overwrite existing files
8        Create destination directory structure if it doesn't exist
9        1 + 8

 


 

Datum und Uhrzeit der aktuellen ProgrammDatei:

$ScriptDate = FileGetTime(@ScriptFullPath)

$ScriptDateTime = $ScriptDate[2] & „.“ & $ScriptDate[1] & „.“ & $ScriptDate[0] & “ – “ & $ScriptDate[3] & „:“ & $ScriptDate[4]

$ScriptDateTime = 18.02.2014 – 14:36

 


 

—————————

DEBUG Date Info

—————————

$GetLastLoginDate: 20150629140524

 

LastPwChanged: 2015/06/01 07:17:06

 

PwExpires: 2015/07/13 07:17:06

 

jetzt: 2015/06/29 14:44:14

—————————

 

_DateDiff ( $sType, $sStartDate, $sEndDate )
 

 

 

 

autoit Syntax Copyright

So kann man einen Copyright-Vermerk in einem Fenster ausgeben:

 Global $Autor        = "Georg Quinting"

Global $Version        = "v1.0"

Global $Date        = "14.07.2014"

Global $TimeNow        = @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN

Global $Copyright        =  StringTrimRight(@ScriptName,4) & " – " & Chr(169) & " – " & $Autor & " – " & $TimeNow

 

MsgBox(0, $Copyright, "Anzeigetext:") 

 

MsgBox(0, $Copyright, StringTrimRight(@ScriptName,4) & " wird von " & $Autor & " zur Verfügung gestellt." _

       & @CRLF & "Version: "        & @TAB & $Version _

       & @CRLF & "vom: "        & @TAB & $Date _

 

autoit Syntax aktuelles Verzeichnis

aktueller Pfad:

       Local $sCurrentPath        = @ScriptDir

 

1. Methode:

while StringInStr($sCurrentPath,"\",0,1)

       $sCurrentPath = StringTrimLeft($sCurrentPath,StringInStr($sCurrentPath,"\",0,1))

WEnd

MsgBox(0,"DEBUG -1-","@ScriptDir: " & @ScriptDir & @CRLF & "current Dir: " & $sCurrentPath, 10)

 

 

2. Methode:

#include <Array.au3>

$aDirectory = StringSplit(@ScriptDir,"\")

; _ArrayDisplay($aDirectory, "aktuelles Verzeichnis")

$sDir = $aDirectory[$aDirectory[0]]

MsgBox(0,"DEBUG -2-","@ScriptDir: " & @ScriptDir & @CRLF & "current Dir: " & $sDir, 10)

 

 

Language IDs

Language IDs

ID Language
1025 Arabic
1041 Japanese
1028 Chinese – Traditional
1042 Korean
1029 Czech
1043 Dutch
1030 Danish
1044 Norwegian
1031 German
1045 Polish
1032 Greek
1046 Portuguese – Brazilian
1033 English
1049 Russian
1034 Spanish
1053 Swedish
1035 Finnish
1054 Thai
1036 French
1055 Turkish
1037 Hebrew
2052 Chinese – Simplified
1038 Hungarian
2070 Portuguese
1040 Italian
3076 Chinese – Hong Kong SAR