AutoIt Snippets: Difference between revisions
Jump to navigation
Jump to search
m (+Snippets Category) |
m (Edited snippets to conform to new Snippet Header template.) |
||
Line 1: | Line 1: | ||
Welcome To The AutoIt Snippets Page - ( '''''Snippet - A short reusable piece of computer code''''' ) | Welcome To The AutoIt Snippets Page - ( '''''Snippet - A short reusable piece of computer code''''' ). | ||
Snippets are generally single functions or small pieces of AutoIt code that can be included into a script which give extra functionality. This will cover a wide variety of subjects and uses. Examples include anything from finding if an internet connection is working or possibly the date Windows was installed. This page is intended to give easy access to the functions. | |||
__TOC__ | |||
[[category:Snippets]] | [[category:Snippets]] | ||
{{Snippet Credit Header}} | {{Snippet Credit Header}} | ||
= Examples = | == Examples == | ||
=== _IsInternetConnected === | |||
{{Snippet Header | {{Snippet Header | ||
| AuthorURL=35302-guinness | |||
|AuthorURL=35302-guinness | | AuthorName=guinness | ||
|AuthorName=guinness | }} | ||
<syntaxhighlight lang="autoit"> | |||
ConsoleWrite("Internet Is Connected" & " = " & _IsInternetConnected() & @CRLF) ; ( Returns "True" Or "False" ) | ConsoleWrite("Internet Is Connected" & " = " & _IsInternetConnected() & @CRLF) ; ( Returns "True" Or "False" ) | ||
Line 26: | Line 28: | ||
Return $aReturn[0] = 0 | Return $aReturn[0] = 0 | ||
EndFunc ;==>_IsInternetConnected | EndFunc ;==>_IsInternetConnected | ||
</syntaxhighlight> | |||
[[#top | ReturnToContents]] | |||
=== _PasswordCrypt === | |||
{{Snippet Header | |||
| AuthorURL=4920-valuater | |||
| AuthorName=Valuater | |||
| ModifierURL=35302-guinness | |||
| ModifierName=guinness | |||
}} | }} | ||
<syntaxhighlight lang="autoit"> | |||
#include <Crypt.au3> | #include <Crypt.au3> | ||
Line 54: | Line 61: | ||
Return SetError(1, 0, '') | Return SetError(1, 0, '') | ||
EndFunc ;==>_PasswordCrypt | EndFunc ;==>_PasswordCrypt | ||
</syntaxhighlight> | |||
[[#top | ReturnToContents]] | |||
== Snippet Creation Help == | |||
* [[Snippets ( Creation )| Snippets Creation Examples ]] | * [[Snippets ( Creation )| Snippets Creation Examples ]] | ||
= AutoIt Snippets Collection = | == AutoIt Snippets Collection == | ||
== AutoIt <small>- AutoIt Examples.</small> == | === AutoIt <small>- AutoIt Examples.</small> === | ||
* [[Snippets ( AutoIt Audio )| Audio Related ]] ( Last Updated - 16:58, 21 May 2012 (BST) ) | * [[Snippets ( AutoIt Audio )| Audio Related ]] ( Last Updated - 16:58, 21 May 2012 (BST) ) | ||
Line 69: | Line 79: | ||
* [[Snippets ( AutoIt String )| AutoIt String Related ]] ( Last Updated - 12:45, 1 August 2012 (BST) ) | * [[Snippets ( AutoIt String )| AutoIt String Related ]] ( Last Updated - 12:45, 1 August 2012 (BST) ) | ||
== GUI <small>- Anything GUI related.</small> == | === GUI <small>- Anything GUI related.</small> === | ||
* [[Snippets ( Checkboxes )| Checkboxes & Radio ]] | * [[Snippets ( Checkboxes )| Checkboxes & Radio ]] | ||
Line 75: | Line 85: | ||
* [[Snippets ( Graphics )| Graphics And Images ]] ( Last Updated - 12:37, 1 August 2012 (BST) ) | * [[Snippets ( Graphics )| Graphics And Images ]] ( Last Updated - 12:37, 1 August 2012 (BST) ) | ||
== Hardware <small>- Hardware Examples.</small> == | === Hardware <small>- Hardware Examples.</small> === | ||
* [[Snippets ( Hardware Information )| Hardware Information ]] ( Last Updated - 11:02, 30 April 2012 (BST) ) | * [[Snippets ( Hardware Information )| Hardware Information ]] ( Last Updated - 11:02, 30 April 2012 (BST) ) | ||
== Numbers <small>- Math, Number & Time Examples.</small> == | === Numbers <small>- Math, Number & Time Examples.</small> === | ||
* [[Snippets ( Math & Numbers )| Math & Numbers ]] ( Last Updated - 12:07, 1 August 2012 (BST) ) | * [[Snippets ( Math & Numbers )| Math & Numbers ]] ( Last Updated - 12:07, 1 August 2012 (BST) ) | ||
* [[Snippets ( Time & Date )| Time & Date ]] ( Last Updated - 14:11, 21 May 2012 (BST) ) | * [[Snippets ( Time & Date )| Time & Date ]] ( Last Updated - 14:11, 21 May 2012 (BST) ) | ||
== Miscellaneous <small>- All Other Examples</small> == | === Miscellaneous <small>- All Other Examples.</small> === | ||
* [[Snippets ( Miscellaneous )| Miscellaneous ]] ( Last Updated - 12:35, 1 August 2012 (BST) ) | * [[Snippets ( Miscellaneous )| Miscellaneous ]] ( Last Updated - 12:35, 1 August 2012 (BST) ) | ||
== Networking <small>- Network, Wireless and Internet Examples.</small>== | === Networking <small>- Network, Wireless and Internet Examples.</small> === | ||
* [[Snippets ( Network )| Network ]] ( Last Updated - 12:33, 1 August 2012 (BST) ) | * [[Snippets ( Network )| Network ]] ( Last Updated - 12:33, 1 August 2012 (BST) ) | ||
* [[Snippets ( Internet )|Internet ]] ( Last Updated - 12:30, 1 August 2012 (BST) ) | * [[Snippets ( Internet )|Internet ]] ( Last Updated - 12:30, 1 August 2012 (BST) ) | ||
* [[Snippets ( Wireless )|Wireless ]] | * [[Snippets ( Wireless )|Wireless ]] | ||
== Windows <small>- Windows Examples.</small> == | === Windows <small>- Windows Examples.</small> === | ||
* [[Snippets ( CMD ) |CMD - Commandline ]] | * [[Snippets ( CMD ) |CMD - Commandline ]] | ||
* [[Snippets ( Files & Folders )| Files & Folders ]] ( Last Updated - 12:16, 1 August 2012 (BST) ) | * [[Snippets ( Files & Folders )| Files & Folders ]] ( Last Updated - 12:16, 1 August 2012 (BST) ) | ||
Line 100: | Line 114: | ||
* [[Snippets ( Windows Users )| Windows Account Management ]] ( Last Updated - 14:13, 21 May 2012 (BST) ) | * [[Snippets ( Windows Users )| Windows Account Management ]] ( Last Updated - 14:13, 21 May 2012 (BST) ) | ||
= Other Links = | == Other Links == | ||
[http://www.autoitscript.com/wiki/Free_Software Free Software Written in AutoIt] | [http://www.autoitscript.com/wiki/Free_Software Free Software Written in AutoIt] |
Revision as of 19:23, 13 November 2012
Welcome To The AutoIt Snippets Page - ( Snippet - A short reusable piece of computer code ).
Snippets are generally single functions or small pieces of AutoIt code that can be included into a script which give extra functionality. This will cover a wide variety of subjects and uses. Examples include anything from finding if an internet connection is working or possibly the date Windows was installed. This page is intended to give easy access to the functions.
Examples
_IsInternetConnected
Author: guinness
ConsoleWrite("Internet Is Connected" & " = " & _IsInternetConnected() & @CRLF) ; ( Returns "True" Or "False" )
Func _IsInternetConnected()
Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
If @error Then
Return SetError(1, 0, False)
EndIf
Return $aReturn[0] = 0
EndFunc ;==>_IsInternetConnected
_PasswordCrypt
Author: Valuater
Modified: guinness
#include <Crypt.au3>
Local $sGenericPassword_1 = 'Password@AutoIt', $sGenericPassword_2 = 'NewPassword@AutoIt', $sSavePath = @ScriptDir & '\License.dat'
ConsoleWrite('1. ' & _PasswordCrypt($sGenericPassword_1, $sSavePath) & @CRLF) ; Write the password to a file located in the @ScriptDir. The password we wrote is returned by the function.
ConsoleWrite('2. ' & _PasswordCrypt($sGenericPassword_1, $sSavePath) & @CRLF) ; Since the password has been written already, we now want to check if the user has entered the password correctly. Returns True or False.
ConsoleWrite('3. ' & _PasswordCrypt($sGenericPassword_2, $sSavePath, 1) & @CRLF) ; Overwrite the old password with a new one.
ConsoleWrite('4. ' & _PasswordCrypt($sGenericPassword_1, $sSavePath) & @CRLF) ; Check the password matches. This will fail as we're checking the old password against the new one.
FileDelete($sSavePath)
Func _PasswordCrypt($sPassword, $sFilePath, $iOverwrite = 0) ; By guinness, idea by Valuater.
If FileExists($sFilePath) And $iOverwrite = 0 Then
Return BinaryToString(_Crypt_DecryptData(IniRead($sFilePath, 'PasswordKey', 'Password', ''), @ComputerName, $CALG_AES_256)) == $sPassword
Else
If IniWrite($sFilePath, 'PasswordKey', 'Password', _Crypt_EncryptData($sPassword, @ComputerName, $CALG_AES_256)) Then
Return $sPassword
EndIf
EndIf
Return SetError(1, 0, '')
EndFunc ;==>_PasswordCrypt
Snippet Creation Help
AutoIt Snippets Collection
AutoIt - AutoIt Examples.
- Audio Related ( Last Updated - 16:58, 21 May 2012 (BST) )
- AutoIt Miscellaneous ( Last Updated - 12:22, 1 August 2012 (BST) )
- AutoIt Array Related ( Last Updated - 13:17, 21 May 2012 (BST) )
- AutoIt Mouse & Keyboard ( Last Updated - 07:52, 3 August 2012 (BST) )
- AutoIt String Related ( Last Updated - 12:45, 1 August 2012 (BST) )
- Checkboxes & Radio
- GUI ( Last Updated - 12:11, 1 August 2012 (BST) )
- Graphics And Images ( Last Updated - 12:37, 1 August 2012 (BST) )
Hardware - Hardware Examples.
- Hardware Information ( Last Updated - 11:02, 30 April 2012 (BST) )
Numbers - Math, Number & Time Examples.
- Math & Numbers ( Last Updated - 12:07, 1 August 2012 (BST) )
- Time & Date ( Last Updated - 14:11, 21 May 2012 (BST) )
Miscellaneous - All Other Examples.
- Miscellaneous ( Last Updated - 12:35, 1 August 2012 (BST) )
Networking - Network, Wireless and Internet Examples.
- Network ( Last Updated - 12:33, 1 August 2012 (BST) )
- Internet ( Last Updated - 12:30, 1 August 2012 (BST) )
- Wireless
Windows - Windows Examples.
- CMD - Commandline
- Files & Folders ( Last Updated - 12:16, 1 August 2012 (BST) )
- Registry
- Windows Information ( Last Updated - 11:27, 30 April 2012 (BST) )
- Windows OS ( Last Updated - 14:35, 21 May 2012 (BST) )
- Windows Settings ( Last Updated - 12:07, 1 August 2012 (BST) )
- Windows Account Management ( Last Updated - 14:13, 21 May 2012 (BST) )