Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/20/2015 in all areas

  1. Hello. I have designed and created a simple Clipboard manager in AutoIt. The project is open for any ideas, I hope you found it useful (and if you did please like my post so I can continue making software). Features [Done] Can store data in up to 5 slots. [Done] Options form. [Done] System Tray menu. [Done] Supports Hot-keys when pasting/copying data. [Done] Ability to copy and store text. [Done] Clipper theme. [Coming soon] Ability to copy and store files and folders. [Coming soon] Clipboard history form. ( currently logs history into a text file ) And Much Much More! Source Conclusion If you find any bugs or you have any ideas you are free to leave them here. Please give this script a try because it took time. If you enjoyed this script PLEASE smash the like button, Thanks! ALSO: Have any script ideas? Please share them with me because I will make them! Clipper.au3
    1 point
  2. This topic will contain simple and working client server communication example along with some basic info for understanding. Examples are based on multi client communication that is happening on one computer (localhost). Changing (if it's not already set correctly) the IP address parameter on server script to reflect your network device IP address will allow you to communicate with other clients on network or even to communicate on internet if your network settings (forwarded router port, ip address on that port is seen from others on internet, you're not trying to do client server from identical computer on identical internet connection) are configured correctly. Every client connecting will need to have server IP address for network (or server public IP address for internet) connection in his client script. So edit client script to correspond to server address TCPConnect('type server ip address in client', 1018). Sometimes firewall can be your problem, if something isn't working turn off firewall and see if it helps. Server will always listen on his Network Adapter IP Address and not on his public address. In some rare occasions server can be set to listen on 0.0.0.0, with that he will listen from any device that he have physically connected on his MB USB or something third (with localhost included for listening). But i would not know the end result of what will happen if some other program that you have installed need that port (or you started 2 servers that interpret one with another). First part will hold just plain code.Second part will hold identical code with comments below commands for more info and understanding hopefully to help new autoit users to understand what and why that something is there.Other parts will hold additional info.First part: Working Code (working in two way communication, with multiple and-or identical client)Server #include <Array.au3> TCPStartup() Dim $Socket_Data[1] $Socket_Data[0] = 0 $Listen = TCPListen(@IPAddress1, 1018, 500) If @error Then ConsoleWrite('!--> TCPListen error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPListen to get more info about this error.' & @CRLF) Exit EndIf While 1 For $x = $Socket_Data[0] To 1 Step -1 $Recv = TCPRecv($Socket_Data[$x], 1000000) If $Recv Then MsgBox(0, 'Client Number ' & $x & ' with connected socket identifier ' & $Socket_Data[$x], 'Recived msg from Client: ' & @CRLF & $Recv, 5) TCPSend($Socket_Data[$x], 'bye') TCPCloseSocket($Socket_Data[$x]) _ArrayDelete($Socket_Data, $x) $Socket_Data[0] -= 1 EndIf Next _Accept() WEnd Func _Accept() Local $Accept = TCPAccept($Listen) If $Accept <> -1 Then _ArrayAdd($Socket_Data, $Accept) $Socket_Data[0] += 1 EndIf EndFunc ;==>_AcceptClient TCPStartup() $Socket = TCPConnect(@IPAddress1, 1018) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.' & @CRLF) Exit EndIf TCPSend($Socket, 'Hi there. My computer name is' & ", " & @ComputerName & ", and its drive serial is " & DriveGetSerial(@HomeDrive)) Do $Recv = TCPRecv($Socket, 1000000) Until $Recv MsgBox(0, 'Recived from server:', $Recv)Second part: Explained Working Code (for upper communication) Third Part: Understanding for how is msg received with TCPRecv on server (or on client) Forth Part: Packets Fifth Part: How to get or check IP address of your device? Sixth Part: How to forward ports? (2 nice youtube tutorials) Seventh Part: Internet communication? If i wrote something incorrectly or wrong please tell me so that i can correct it. Edited: Local and Global, added aditional info about reciving msgs for maxlen buffer.
    1 point
  3. I would like to see one of your huge scripts made with this principles in mind. All we have seen until now are some small and simple scripts When trying to make good scripts/programs it is not about coding but planning. The design you make before you write the first line of code is what makes good code or in absence you get a pile of s..t sooner or later. Coding is less then 10% of the effort to write a good program. The rest is design, testing, documentation etc Just my 2 cents..
    1 point
  4. Also keep in mind that empty arrays take space too... Also develop a specific kind of programming pattern in your program if you are making a huge program, note that you don't have to plan your programming pattern first-hand, you will have to do it when you start coding your script, that ways its much easier. These are things which I follow when I code a big code hungry script. TD
    1 point
  5. Jos

    Filereadline - problem

    Likely your FileOpen() points to the wrong file, so test for success of FileOpen by testing @error. Jos
    1 point
  6. Jfish

    Filereadline - problem

    Try IniRead ( "filename", "section", "key", "default" ) instead ...
    1 point
  7. I think the best approach is to avoid memory leaks. Means: Release storage when it is no longer used. Set unused arrays to "" to release the memory, set unused objects to 0 to drop a connection, application or whatever.
    1 point
  8. I think that if some parts of your script you add sleep() it wont use so much memory, the inconvenience its that it will take more time to load... If you are planning to use another program here I have a script that will reduce the memory of the program you say (its same as yours but you can select the program) Func _ProcessReduceMemory($iPID) Local $iProcExists = ProcessExists($iPID) If Not $iProcExists Then Return SetError(1, 0, 0) If IsString($iPID) Then $iPID = $iProcExists Local $hOpenProc, $aResult $hOpenProc = DllCall("Kernel32.dll", "int", "OpenProcess", "int", 0x1F0FFF, "int", False, "int", $iPID) $aResult = DllCall("Kernel32.dll", "int", "SetProcessWorkingSetSize", "hwnd", $hOpenProc[0], "int", -1, "int", -1) DllCall("Kernel32.dll", "int", "CloseHandle", "int", $hOpenProc[0]) If Not IsArray($aResult) Or $aResult[0] = 0 Then Return SetError(2, 0, 0) Return $aResult[0] EndFunc ;==>_ProcessReduceMemory
    1 point
  9. Develop your application first, keeping in mind to use large variables wisely w.r.t. their lifetime. Use the power of SQLite internally instead of using AutoIt code to process large, raw output. The actual size of the .au3 code is almost irrelevant and you can always use stripping to remove unused parts from the runable code. Then only check if the result requires too much, search where the issue is and workout a way to decrease memory size for this part. The functions posted in the OP are not going to really help you, and possibly bite you someday.
    1 point
  10. The wiki has a section about good coding practices.
    1 point
  11. Here is a UDF that allows you to easily read and write to the registry keys that control User Account Control (UAC). I wrote this UDF while I was working on a project for Windows 7 that required reboots, and for the script to start on its own, with the full administrator rights, after the PC auto logged in without the issue of the UAC prompt. The functions I used the most was _UAC_GetConsentPromptBehaviorAdmin and _UAC_SetConsentPromptBehaviorAdmin, but I decided to go ahead and write a full UDF for the all the UAC values. For usage, please look a the function headers.I hope other finds this UDF useful. UAC.au3 #include-once ;~ #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ;~ #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y ;~ #Tidy_Parameters=/sf ; #INDEX# ======================================================================================================================= ; Title .........: User Account Control (UAC) UDF for Windows Vista and higher. ; AutoIt Version : 3.3.6++ ; UDF Version ...: 1.0 ; Language ......: English ; Description ...: Get or Set UAC registry settings in Windows Vista or higher. ; Dll ...........: ; Author(s) .....: Adam Lawrence (AdamUL) ; Email .........: ; Modified ......: ; Contributors ..: ; Resources .....: http://technet.microsoft.com/en-us/library/dd835564(v=ws.10).aspx#BKMK_RegistryKeys ; http://www.autoitscript.com/forum/topic/122050-useful-snippets-collection-thread/page__p__847186#entry847186 (Post #1, item 8.) ; Remarks .......: #RequireAdmin and/or #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator is needed for "Set" functions to work in this UDF. ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_UAC_GetConsentPromptBehaviorAdmin ;_UAC_GetConsentPromptBehaviorUser ;_UAC_GetEnableInstallerDetection ;_UAC_GetEnableLUA ;_UAC_GetEnableSecureUIAPaths ;_UAC_GetEnableUIADesktopToggle ;_UAC_GetEnableVirtualization ;_UAC_GetFilterAdministratorToken ;_UAC_GetPromptOnSecureDesktop ;_UAC_GetValidateAdminCodeSignatures ;_UAC_SetConsentPromptBehaviorAdmin ;_UAC_SetConsentPromptBehaviorUser ;_UAC_SetEnableInstallerDetection ;_UAC_SetEnableLUA ;_UAC_SetEnableSecureUIAPaths ;_UAC_SetEnableUIADesktopToggle ;_UAC_SetEnableVirtualization ;_UAC_SetFilterAdministratorToken ;_UAC_SetPromptOnSecureDesktop ;_UAC_SetValidateAdminCodeSignatures ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== Global Const $UAC_ELEVATE_WITHOUT_PROMPTING = 0 Global Const $UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP = 1 Global Const $UAC_PROMPT_FOR_CONSENT_SECURE_DESKTOP = 2 Global Const $UAC_PROMPT_FOR_CREDENTIALS = 3 Global Const $UAC_PROMPT_FOR_CONSENT = 4 Global Const $UAC_PROMPT_FOR_CONSENT_NONWINDOWS_BINARIES = 5 Global Const $UAC_AUTOMATICALLY_DENY_ELEVATION_REQUESTS = 0 Global Const $UAC_DISABLED = 0 Global Const $UAC_ENABLED = 1 ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetConsentPromptBehaviorAdmin ; Description ...: Gets UAC Registry Key for ConsentPromptBehaviorAdmin. Behavior of the elevation prompt for administrators in Admin Approval Mode. ; Syntax ........: _UAC_GetConsentPromptBehaviorAdmin() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_ELEVATE_WITHOUT_PROMPTING (0) - Elevate without prompting (Use this option only in the most constrained environments). ; |$UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP (1) - Prompt for credentials on the secure desktop. ; |$UAC_PROMPT_FOR_CONSENT_SECURE_DESKTOP (2) - Prompt for consent on the secure desktop. ; |$UAC_PROMPT_FOR_CREDENTIALS (3) - Prompt for credentials. ; |$UAC_PROMPT_FOR_CONSENT (4) - Prompt for consent. ; |$UAC_PROMPT_FOR_CONSENT_NONWINDOWS_BINARIES (5) - Prompt for consent for non-Windows binaries (default). ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetConsentPromptBehaviorAdmin() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "ConsentPromptBehaviorAdmin") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetConsentPromptBehaviorAdmin ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetConsentPromptBehaviorUser ; Description ...: Gets UAC Registry Key for ConsentPromptBehaviorUser. Behavior of the elevation prompt for standard users. ; Syntax ........: _UAC_GetConsentPromptBehaviorUser() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_AUTOMATICALLY_DENY_ELEVATION_REQUESTS (0) - Automatically deny elevation requests. ; |$UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP (1) - Prompt for credentials on the secure desktop (default). ; |$UAC_PROMPT_FOR_CREDENTIALS (3) - Prompt for credentials. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetConsentPromptBehaviorUser() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "ConsentPromptBehaviorUser") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetConsentPromptBehaviorUser ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetEnableInstallerDetection ; Description ...: Gets UAC Registry Key for EnableInstallerDetection. Detect application installations and prompt for elevation. ; Syntax ........: _UAC_GetEnableInstallerDetection() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled (default for enterprise). ; |$UAC_ENABLED (1) - Enabled (default for home). ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetEnableInstallerDetection() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableInstallerDetection") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetEnableInstallerDetection ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetEnableLUA ; Description ...: Gets UAC Registry Key for EnableLUA. Run all administrators in Admin Approval Mode. ; Syntax ........: _UAC_GetEnableLUA() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - UAC (formally known as LUA) is disabled. ; |$UAC_ENABLED (1) - UAC (formally known as LUA) is enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetEnableLUA() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetEnableLUA ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetEnableSecureUIAPaths ; Description ...: Gets UAC Registry Key for EnableSecureUIAPaths. Only elevate UIAccess applications that are installed in secure locations. ; Syntax ........: _UAC_GetEnableSecureUIAPaths() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetEnableSecureUIAPaths() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableSecureUIAPaths") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetEnableSecureUIAPaths ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetEnableUIADesktopToggle ; Description ...: Gets UAC Registry Key for EnableUIADesktopToggle. Allow UIAccess applications to prompt for elevation without using the secure desktop. ; Syntax ........: _UAC_GetEnableUIADesktopToggle() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetEnableUIADesktopToggle() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableUIADesktopToggle") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetEnableUIADesktopToggle ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetEnableVirtualization ; Description ...: Gets UAC Registry Key for EnableVirtualization. Virtualize file and registry write failures to per-user locations. ; Syntax ........: _UAC_GetEnableVirtualization() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetEnableVirtualization() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableVirtualization") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetEnableVirtualization ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetFilterAdministratorToken ; Description ...: Gets UAC Registry Key for FilterAdministratorToken. Admin Approval Mode for the Built-in Administrator account. ; Syntax ........: _UAC_GetFilterAdministratorToken() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetFilterAdministratorToken() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "FilterAdministratorToken") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetFilterAdministratorToken ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetPromptOnSecureDesktop ; Description ...: Gets UAC Registry Key for PromptOnSecureDesktop. Switch to the secure desktop when prompting for elevation. ; Syntax ........: _UAC_GetPromptOnSecureDesktop() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetPromptOnSecureDesktop() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "PromptOnSecureDesktop") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetPromptOnSecureDesktop ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_GetValidateAdminCodeSignatures ; Description ...: Gets UAC Registry Key for ValidateAdminCodeSignatures. Only elevate executables that are signed and validated. ; Syntax ........: _UAC_GetValidateAdminCodeSignatures() ; Parameters ....: None. ; Return values .: Success - Registry Value ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Invalid key on OS. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: TheXman ; Remarks .......: Admin rights not required to read the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_GetValidateAdminCodeSignatures() If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-3, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegRead("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "ValidateAdminCodeSignatures") If $iReturn == "" Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_GetValidateAdminCodeSignatures ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetConsentPromptBehaviorAdmin ; Description ...: Sets UAC Registry Key for ConsentPromptBehaviorAdmin. Behavior of the elevation prompt for administrators in Admin Approval Mode. ; Syntax ........: _UAC_SetConsentPromptBehaviorAdmin([$iValue = $UAC_PROMPT_FOR_CONSENT_NONWINDOWS_BINARIES (5)]) ; Parameters ....: $iValue - [optional] An integer value 0 to 5. Default is 5. ; |$UAC_ELEVATE_WITHOUT_PROMPTING(0) - Elevate without prompting (Use this option only in the most constrained environments). ; |$UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP (1) - Prompt for credentials on the secure desktop. ; |$UAC_PROMPT_FOR_CONSENT_SECURE_DESKTOP (2) - Prompt for consent on the secure desktop. ; |$UAC_PROMPT_FOR_CREDENTIALS (3) - Prompt for credentials. ; |$UAC_PROMPT_FOR_CONSENT (4) - Prompt for consent. ; |$UAC_PROMPT_FOR_CONSENT_NONWINDOWS_BINARIES (5) - Prompt for consent for non-Windows binaries (default). ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetConsentPromptBehaviorAdmin($iValue = $UAC_PROMPT_FOR_CONSENT_NONWINDOWS_BINARIES) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" If $iValue < 0 Or $iValue > 5 Then Return SetError(-5, 0, -1) Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "ConsentPromptBehaviorAdmin", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetConsentPromptBehaviorAdmin ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetConsentPromptBehaviorUser ; Description ...: Sets UAC Registry Key for ConsentPromptBehaviorUser. Behavior of the elevation prompt for standard users. ; Syntax ........: _UAC_SetConsentPromptBehaviorUser([$iValue = $UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP (1)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_AUTOMATICALLY_DENY_ELEVATION_REQUESTS (0) - Automatically deny elevation requests. ; |$UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP (1) - Prompt for credentials on the secure desktop (default). ; |$UAC_PROMPT_FOR_CREDENTIALS (3) - Prompt for credentials. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetConsentPromptBehaviorUser($iValue = $UAC_PROMPT_FOR_CREDENTIALS_SECURE_DESKTOP) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue = 2 Or $iValue > 3 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "ConsentPromptBehaviorUser", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetConsentPromptBehaviorUser ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetEnableInstallerDetection ; Description ...: Sets UAC Registry Key for EnableInstallerDetection. Detect application installations and prompt for elevation. ; Syntax ........: _UAC_SetEnableInstallerDetection([$iValue = $UAC_DISABLED (0)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 0. ; |$UAC_DISABLED (0) - Disabled (default for enterprise). ; |$UAC_ENABLED (1) - Enabled (default for home). ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetEnableInstallerDetection($iValue = $UAC_DISABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableInstallerDetection", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetEnableInstallerDetection ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetEnableLUA ; Description ...: Sets UAC Registry Key for EnableLUA. Run all administrators in Admin Approval Mode. ; Syntax ........: _UAC_SetEnableLUA([$iValue = $UAC_ENABLED (1)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - UAC (formally known as LUA) is disabled. ; |$UAC_ENABLED (1) - UAC (formally known as LUA) is enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetEnableLUA($iValue = $UAC_ENABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetEnableLUA ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetEnableSecureUIAPaths ; Description ...: Sets UAC Registry Key for EnableSecureUIAPaths. Only elevate UIAccess applications that are installed in secure locations. ; Syntax ........: _UAC_SetEnableSecureUIAPaths([$iValue = $UAC_ENABLED (1)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetEnableSecureUIAPaths($iValue = $UAC_ENABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableSecureUIAPaths", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetEnableSecureUIAPaths ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetEnableUIADesktopToggle ; Description ...: Sets UAC Registry Key for EnableUIADesktopToggle. Allow UIAccess applications to prompt for elevation without using the secure desktop. ; Syntax ........: _UAC_SetEnableUIADesktopToggle([$iValue = $UAC_DISABLED (0)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetEnableUIADesktopToggle($iValue = $UAC_DISABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableUIADesktopToggle", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetEnableUIADesktopToggle ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetEnableVirtualization ; Description ...: Sets UAC Registry Key for EnableVirtualization. Virtualize file and registry write failures to per-user locations. ; Syntax ........: _UAC_SetEnableVirtualization([$iValue = $UAC_ENABLED (1)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetEnableVirtualization($iValue = $UAC_ENABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "EnableVirtualization", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetEnableVirtualization ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetFilterAdministratorToken ; Description ...: Sets UAC Registry Key for FilterAdministratorToken. Admin Approval Mode for the Built-in Administrator account. ; Syntax ........: _UAC_SetFilterAdministratorToken([$iValue = $UAC_DISABLED (0)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetFilterAdministratorToken($iValue = $UAC_DISABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "FilterAdministratorToken", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetFilterAdministratorToken ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetPromptOnSecureDesktop ; Description ...: Sets UAC Registry Key for PromptOnSecureDesktop. Switch to the secure desktop when prompting for elevation. ; Syntax ........: _UAC_SetPromptOnSecureDesktop([$iValue = $UAC_ENABLED (1)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetPromptOnSecureDesktop($iValue = $UAC_ENABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "PromptOnSecureDesktop", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetPromptOnSecureDesktop ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UAC_SetValidateAdminCodeSignatures ; Description ...: Sets UAC Registry Key for ValidateAdminCodeSignatures. Only elevate executables that are signed and validated. ; Syntax ........: _UAC_SetValidateAdminCodeSignatures([$iValue = $UAC_DISABLED (0)]) ; Parameters ....: $iValue - [optional] An integer value. Default is 1. ; |$UAC_DISABLED (0) - Disabled. ; |$UAC_ENABLED (1) - Enabled. ; Return values .: Success - 1 ; Failure - -1, sets @error to: ; |1 - if unable to open requested key ; |2 - if unable to open requested main key ; |3 - if unable to remote connect to the registry ; |-1 - if unable to open requested value ; |-2 - if value type not supported ; |-3 - Current user is not Admin. ; |-4 - Invalid key on OS. ; |-5 - An invaild value. ; Author ........: Adam Lawrence (AdamUL) ; Modified ......: ; Remarks .......: Admin rights required to set the value. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _UAC_SetValidateAdminCodeSignatures($iValue = $UAC_DISABLED) If Not IsAdmin() Then Return SetError(-3, 0, -1) If StringRegExp(@OSVersion, "_(XP|200(0|3))") Then Return SetError(-4, 0, -1) If $iValue < 0 Or $iValue > 1 Then Return SetError(-5, 0, -1) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" Local $iReturn = RegWrite("HKEY_LOCAL_MACHINE" & $s64Bit & "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "ValidateAdminCodeSignatures", "REG_DWORD", $iValue) If $iReturn = 0 Then $iReturn = -1 Return SetError(@error, 0, $iReturn) EndFunc ;==>_UAC_SetValidateAdminCodeSignatures Updated: Thanks to @TheXman for catching a bug in the script. Adam
    1 point
  12. Hi all, This script will help you to auto complete "Then / EndIf / () / EndFunc / Next / WEnd / EndSwitch / Until / EndSelect" when you press enter followed by appropriate keyword. I want to say thanks for Yashied for making this script true. Without his _HoteKey_Assign function, i can't even think about this tool. I have tested it in my 32 bit Win8 and 64 bit Win8.1. Here is the code . AutoFiller version2. At last i have re-invented the wheel. Last week, to be precisely, from April 1, i have no broadband connection. So decided to complete this script. Check this script and please tell me if you find any bugs. ; Necessary includes #include <HotKey_21b.au3> #include <Array.au3> ; A littile delay for smooth working Opt("SendKeyDownDelay",20 ) ; Declare enter key as a const Global Const $VK_RETURN = 0x0D ; Start SciTE editor Local $Process = Run(@ProgramFilesDir &"\AutoIt3\SciTE\SciTE.exe") ; Wait for SciTE to active WinWait("[CLASS:SciTEWindow]") ; Get the handle of SciTE window Local $Handle = WinGetHandle("[CLASS:SciTEWindow]") ; Here is our hotkey assignment. Thanks for Yashied. _HotKey_Assign($VK_RETURN, "EnterPress", 0, $Handle) ; Looping while SciTE closes While 1 Sleep(10) If Not ProcessExists($Process) Then Exit EndIf WEnd ; Main Function starts here ; #FUNCTION# ==================================================================================================================== ; Name ..........: EnterPress ; Description ...: This is the main function ; Syntax ........: EnterPress() ; Parameters ....: No parametes ; Return values .: None ; Author ........: kcvinu ; Modified ......: 04-04-2015 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func EnterPress() ;------------------------------------------------------------------------------------------------------------------ Global $SciTE_Title ; Title of SciTE window Global $SciTE_Text ; Total text in SciTE code editor Global $CurrentLineNumber ; Line number where cursor rests Global $LineCount ; Total line numbers Global $CurrentColNumber ; Col number where cursor rests Global $CurrentLine_Text ; Text of current line number Global $CLT_Length ; Length of current line Global $IsSymbol ; Boolean variable for checking any "#, ; , _" symbols in the beginning Global $SpaceStriped_CLT ; Space stripped from both side of current line text Global $FirstWord ; First word of the current line Global $LastThen ; If a "Then" key word is in the last are a current line Global $FW_col ; Col number of first word Global $EW_col ; Col number of end keywords like"EndIf/WEnd" etc Global $CLT_Array ; An array to split whole text with @LF, Means each line will be splitted Global $NxtLineTxt ; Text of next line from cursor Global $NWC_Status = True ; Boolean, if an end keyword is in next line, it is false Global $EndWord ; End keywords like "EndIf/WEnd" etc. Global $NoNeedToPaste = False ; Boolean, if first word is not a keywork like "If/While", then it is false ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Global $KeyWordList[7][7] = [['If', 'EndIf'], ['While', 'WEnd'], ['For', 'Next'], ['Do', 'Until'], ['Select', 'EndSelect'], ['Func', 'EndFunc'], ['Switch', 'EndSwitch']] ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; Getting total line number from SciTE code window $LineCount = ControlCommand($Handle, "S", 350, "GetLineCount", " ") ; Getting text from SciTE code window $SciTE_Text = ControlGetText($Handle, "S", 350) ; Getting current line number from SciTE code window $CurrentLineNumber = ControlCommand($Handle, "S", 350, "GetCurrentLine", " ") ; Getting current col number from SciTE code window $CurrentColNumber = ControlCommand($Handle, "S", 350, "GetCurrentCol", " ") ;----------------------------------------------------------------------------------------------- ; Split the text into lines and put each line text in this array $CLT_Array = StringSplit($SciTE_Text, @LF) ; Getting the current line text from the array $CurrentLine_Text = $CLT_Array[$CurrentLineNumber] ;------------------------------------------------------------------------------------------------------------ ; If any errors are there, then current line text is empty If @error Then $CurrentLine_Text = "" ; getting the length of current line text $CLT_Length = StringLen($CurrentLine_Text) ; Stripping the left side space from current line text $SpaceStriped_CLT = StringStripWS($CurrentLine_Text, 1) ; Stripping the right side space from current line text $SpaceStriped_CLT = StringStripWS($SpaceStriped_CLT, 2) ; Checking if there is any symbols in the beginning $IsSymbol = StringRegExp($SpaceStriped_CLT, "^#|^_|^;") ; Getting the first word,only if it is a 'if' or 'func' etc.. (StringMatchAndGet is my function) $FirstWord = StringMatchAndGet($SpaceStriped_CLT, "^[iI]f|^[fF]unc|^[fF]or|^[wW]hile|^[sS]witch|^[dD]o|^[sS]elect") ; Check if there is a "Then" is present $LastThen = StringMatchAndGet($SpaceStriped_CLT, "Then$") ; Getting col number of first word $FW_col = StringInStr($CurrentLine_Text, $FirstWord) ;----------------------------------------------------------------------------------------------------------------------------- ; If first word is a keyword like "If/While" If $FirstWord <> "" Then For $j = 0 To 6 ; Find the appropriate end keyword If $KeyWordList[$j][0] = $FirstWord Then $EndWord = $KeyWordList[$j][1] EndIf Next ; If the first word is not a keyword ElseIf $FirstWord = "" Then ; Then no need to paste any end key words $NoNeedToPaste = True EndIf ;------------------------------------------------------------------------------------------------------------------- ; Calling the ColFinder function ColFinder() ;------------------------------------------------------------------------------------------------------------------- ; If cursor is in the middile area of the line If $CLT_Length > $CurrentColNumber Then ; Just act like a normal enter key press ControlSend($Handle, "S", 350, "{ENTER}") ; If there is no text in SciTE ElseIf $SciTE_Text = "" Then ; Just act like a normal enter key press ControlSend($Handle, "S", 350, "{ENTER}") ; If no need to paste any keywords, That means first word is empty ElseIf $NoNeedToPaste = True Then ; Just act like a normal enter key press ControlSend($Handle, "S", 350, "{ENTER}") ; If the beginning of the line is a symbol like "#, ; , _" ElseIf $IsSymbol = 1 Then ; Just act like a normal enter key press ControlSend($Handle, "S", 350, "{ENTER}") ; If there is no text in current line ElseIf $CurrentLine_Text = "" Then ; Just act like a normal enter key press ControlSend($Handle, "S", 350, "{ENTER}") ; If first word is 'If' and no 'EndIf' in next line ElseIf $FirstWord = "If" And $NWC_Status = True Then ; Check for the presence of a 'Then' If $LastThen = "" Then ; If there is not a 'Then', then paste it ControlSend($Handle, "S", 350, " Then{SPACE}{ENTER 2}{BS}EndIf{SPACE}{UP}") ElseIf $LastThen = "Then" Then ; Else do paste the 'EndIf' ControlSend($Handle, "S", 350, "{ENTER 2}{BS}EndIf{SPACE}{UP}") EndIf ; If first word is 'func' and no 'Endfunc' in next line ElseIf $FirstWord = "Func" Or $FirstWord = "func" And $NWC_Status = True Then ; Check for the presence of a '()' If StringRight($SpaceStriped_CLT,2) = "()" Then ; If so, just paste the 'EndFunc' ControlSend($Handle, "S", 350, "{ENTER 2}{BS}EndFunc{SPACE}{UP}") Else ; Paste the Endfunc followed by '()' ControlSend($Handle, "S", 350, "(){SPACE}{ENTER 2}{BS}EndFunc{SPACE}{UP}") EndIf ; If first word is 'For' And no 'Next' In Next line ElseIf $FirstWord = "For" Or $FirstWord = "for" And $NWC_Status = True Then ; Paste a 'Next' ControlSend($Handle, "S", 350, "{ENTER 2}{BS}Next{SPACE}{UP}") ; If first word is 'While' And no 'WEnd' In Next line ElseIf $FirstWord = "While" Or $FirstWord = "while" And $NWC_Status = True Then ; Paste a 'WEnd' ControlSend($Handle, "S", 350, "{ENTER 2}{BS}WEnd{SPACE}{UP}") ; If first word is 'Do' And no 'Until' In Next line ElseIf $FirstWord = "Do" Or $FirstWord = "do" And $NWC_Status = True Then ; Paste an 'Until' ControlSend($Handle, "S", 350, "{ENTER 2}{BS}Until{SPACE}{UP}") ; If first word is 'Switch' And no 'EndSwitch' In Next line ElseIf $FirstWord = "Switch" Or $FirstWord = "switch" And $NWC_Status = True Then ; Paste a 'Case' and 'EndSwitch' ControlSend($Handle, "S", 350, "{ENTER}Case{SPACE}{ENTER}{BS 2}EndSwitch{SPACE}{UP}{SPACE}") ; If first word is 'Select' And no 'EndSelect' In Next line ElseIf $FirstWord = "Select" Or $FirstWord = "select" And $NWC_Status = True Then ; Paste an 'EndSelect' ControlSend($Handle, "S", 350, "{ENTER 2}{BS}EndSelect{SPACE}{UP}") Else ; Else, Just act like a normal enter key press ControlSend($Handle, "S", 350, "{ENTER}") EndIf EndFunc ;==>EnterPress ;================================================================================================================================ ; #FUNCTION# ==================================================================================================================== ; Name ..........: StringMatchAndGet ; Description ...: A simple function for finding words with regular expression ; Syntax ........: StringMatchAndGet($String, $Pattern) ; Parameters ....: $String - A string to use ; $Pattern - A pattern to find any word. ; Return values .: None ; Author ........: kcvinu ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func StringMatchAndGet($String, $Pattern) Local $Result Local $MatchArray = StringRegExp($String, $Pattern, 1) If @error Then $MatchArray = " " Else $Result = $MatchArray[0] EndIf Return $Result EndFunc ;==>StringMatchAndGet ; #FUNCTION# ==================================================================================================================== ; Name ..........: ColFinder ; Description ...: A function to find the col number of an end keyword like "EndIf" or "WEnd" ; Syntax ........: ColFinder() ; Parameters ....: None ; Return values .: None ; Author ........: kcvinu ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func ColFinder() ; This is the col number of the first word $FW_col = StringInStr($CurrentLine_Text, $FirstWord) If $SciTE_Text = "" Then $NWC_Status = False ElseIf $CLT_Array[0] = 1 Then $NWC_Status = True ; If there is more lines under the current line ElseIf $LineCount > $CurrentLineNumber Then ; Loop through each line For $i = $CurrentLineNumber + 1 To $CLT_Array[0] ; Getting next line $NxtLineTxt = $CLT_Array[$i] ; If there is an appropriate end keyword there If StringInStr($NxtLineTxt, $EndWord) = $FW_col Then ; No need to paste an end keyword $NWC_Status = False ExitLoop EndIf Next EndIf EndFunc ;==>ColFinder You can get HotKey_21b.au3 from this link. Change the SciTE.exe path and run this script. It will work as normally as SciTE is. And it will add all end keywords automatically. Here is the au3 file. And here is the include file "HotKey_21b.au3" AutoFiller Version2.au3 HotKey_21b.au3
    1 point
  13. Hi all, This script is working. But i don't know how to limit it only for SciTE window. Here is the code. I think it will be useful for somebody. And if somebody helps to limit this function only for SciTE, this will useful for me. That's sure. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=D:\AotoIt Works\EXEs\AutoFiller32.Exe #AutoIt3Wrapper_Outfile_x64=D:\AotoIt Works\EXEs\AutoFiller64.Exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: kcvinu Script Function: This program will paste EndIf / EndFunc / WEnd / Next / EndSwitch / Until / EndSelect automaticlly right after you hit enter #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <String.au3> #include <StringConstants.au3> #include <WinAPISys.au3> HotKeySet("{ENTER}", "AutoFiller") HotKeySet("{ESC}", "Exiter") While 1 Sleep(5) WEnd Func AutoFiller() Global $Words_array Global $FW_array Global $LW_array Global $First_word Global $Index Global $Last_word Global $Parenthesis Global $title = WinGetTitle("[CLASS:SciTEWindow]") If WinGetState($title) = 47 Or WinGetState($title) = 15 Then Global $Current_line = ControlCommand($title, "S", 350, "GetCurrentLine", "") Global $Text = ControlGetText($title, "S", 350) Global $Text_Array = StringSplit($Text, @LF) Global $Current_lineRaw = $Text_Array[$Current_line] Global $Current_lineText = StringStripWS($Current_lineRaw, 2) $Current_lineText = StringStripWS($Current_lineText, 1) $Last_word = StringRight($Current_lineText, 4) $Parenthesis = StringRight($Current_lineText, 2) If StringInStr($Current_lineText, " ") Then $FW_array = StringRegExp($Current_lineText, "(^\w+)", 1) $First_word = $FW_array[0] If @error Then ControlSend($title, "S", 350, "{ENTER}") EndIf If $First_word == "If" And Not ($Last_word == "Then") Then ControlSend($title, "S", 350, " Then {ENTER}{HOME}{ENTER}EndIf {UP}{TAB}", 0) ElseIf $First_word == "If" And $Last_word == "Then" Then ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}EndIf {UP}{TAB}", 0) ElseIf $First_word == "Func" And Not ($Parenthesis = "()") Then ControlSend($title, "S", 350, "(){ENTER}{HOME}{ENTER}EndFunc {UP}{TAB}", 0) ElseIf $First_word == "Func" And $Parenthesis = "()" Then ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}EndFunc {UP}{TAB}", 0) ElseIf $First_word == "For" Then ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}Next {UP}{TAB}", 0) ElseIf $First_word == "While" Then ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}WEnd {UP}{TAB}", 0) ElseIf $First_word == "Do" Then ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}Until {UP}{TAB}", 0) ElseIf $First_word == "Switch" Then ControlSend($title, "S", 350, "{ENTER}Case {ENTER} {HOME}EndSwitch {UP}{SPACE}", 0) ElseIf $First_word == "Select" Then ControlSend($title, "S", 350, "{ENTER}{HOME}{ENTER}EndSelect {UP}{TAB}", 0) Else ControlSend($title, "S", 350, "{ENTER}") EndIf Else ControlSend($title, "S", 350, "{ENTER}") EndIf Else Local $hnd = _WinAPI_GetActiveWindow() WinActivate($hnd) Send("{ENTER}") EndIf EndFunc ;==>AutoFiller Func Exiter() Exit EndFunc ;==>Exiter ;~ AF() ;~ _ArrayDisplay($Words_array) I know lines 103 to 105 are not working.
    1 point
  14. Why use a loop at all? #include <Constants.au3> Global $DOS, $Message = '' ;; added "= ''" for show only. $DOS = Run(@ComSpec & " /c Ping www.google.com", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS) MsgBox(0, "Stdout Read:", $Message)
    1 point
  15. therms

    Evernote UDF

    This a function for adding new notes to your Evernote database. Example usage: _CreateNote("Test note text", "", "tag one, tag two, tag three", "This is a test note title") _CreateNote($file, "", "", "This is a test note composed of a file")oÝ÷ Ø[§rب«­¢+Øì´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´(íÍè%̹½ÑѼѡ±½°Ùɹ½ÑÑÍ(ì(íÉÌè$ÀÌØíÑáÐ$$´%A±¥¸ÑáÐѼѼ½ä½¹½Ñ(ì$$ÀÌØí¥±$$´%¥±Ñ¼Ñ¼½ä½¹½Ñ(ì$$ÀÌØíÑ$$´% ½µµÍÁÉѱ¥ÍнÑÌѼѼ¹½Ñ°¥Ñ¡Ì¤¼¹½Ðá¥ÍÐÝ¥±°±éäÉѸ(ì$$ÀÌØíѥѱ$$´%MÁ¥¥Ì¹½Ñѥѱ¸%½µ¥ÑÑ°¹½Ñѥѱݥ±°¹ÉÑÕѽµÑ¥±±ä(ì$$ÀÌØí¹½Ñ½½¬$´%9½Ñ½½¬Ñ¼ÉÑÑ¡¹½Ñ¥¸¸%½Ì¹½Ðá¥Íа±éäÉѸ(ì$$$$$%%½µ¥ÑÑ°ÕÍձй½Ñ½½¬¸(ì$$ÀÌØíÑÑ´$$´%¹½ÑÉÑ¥½¸Ñ¸ìeeed½54½¡ éµ´éÍÍð¥±Ñ¥µô¸(íIÑÕɸè$À½ÈMÕÍÌ(ì$$$Ľȥ±ÕÉ(ì$$%ÉɽÈôĽȹ¼ÁɵÑÉÌÁÍÍ(ì$$%ÉɽÈôÈ½È½Ñ ÀÌØíÑáйÀÌØí¥±ÍÁ¥¥(ì$$%ÉɽÈô̽ȹ½¸µá¥ÍѹХ±(ì$$%ÉɽÈôнÈѽѥµ½ÉµÐÉɽÈ(ì(í9½ÑÌè$ÀÌØíÑáйÀÌØí¥±ÉµÕÑÕ±±äá±ÕÍ¥Ù¸e½ÔµÕÍÐÕͽ¹½ÈÑ¡½Ñ¡È¸(ì$%1ÍÐÕͱ½¥¸¹µ½ÁÍÌÉÕÍѼÕÑ Ý¥Ñ Ùɹ½Ñ¸(ì$%±Í¼°¹½ÑÑ¡ÐÕ¥¸9MÉ¥Áн͸Ìäíб±½ÜÑÌ¥¹¹¥¹Ý¥Ñ ÅÕ½ÐíÅÕ½Ðì(ì´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´)Õ¹} ÉÑ9½Ñ ÀÌØíÑáÐôÅÕ½ÐìÅÕ½Ðì°ÀÌØí¥±ôÅÕ½ÐìÅÕ½Ðì°ÀÌØíÑôÅÕ½ÐìÅÕ½Ðì°ÀÌØíѥѱôÅÕ½ÐìÅÕ½Ðì°ÀÌØí¹½Ñ½½¬ôÅÕ½ÐìÅÕ½Ðì°ÀÌØíÑÑ´ôÅÕ½ÐìÅÕ½Ðì¤(% ½¹ÍÐÀÌØí9áôÌäìÅÕ½ÐíèÀäÈíAɽɴ¥±Ì¡ààؤÀäÈíÙɹ½ÑÀäÈíÙɹ½ÑÌÀäÈí9MÉ¥ÁйáÅÕ½ÐìÌäì($($ì ¡¬½È¡¹¥à¥Á½ÍÍ¥±¤ÁɵÑÈÉɽÉÌ(%%9ÕµAɵÌôÀQ¡¸IÑÕɸMÑÉÉ½È Ä°À°Ä¤(%%ÀÌØíÑáбÐìÐìÅÕ½ÐìÅÕ½Ðì¹ÀÌØí¥±±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸IÑÕɸMÑÉÉ½È È°À°Ä¤(%%ÀÌØí¥±±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸($$ÀÌØí¥±ô¥±Ñ1½¹9µ ÀÌØí¥±°Ä¤($%%9½Ð¥±á¥ÍÑÌ ÀÌØí¥±¤Q¡¸IÑÕɸMÑÉÉ½È Ì°À°Ä¤(%¹%($(%%ÀÌØí¥±±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸ÀÌØí¥±ôMÑÉ¥¹½ÉµÐ Ìäì½ÌÅÕ½ÐìÌÅÕ½ÐìÌäì°ÀÌØí¥±¤$$(%%ÀÌØíѥѱ±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸ÀÌØíѥѱôMÑÉ¥¹½ÉµÐ Ìä콤ÅÕ½ÐìÌÅÕ½ÐìÌäì°ÀÌØíѥѱ¤$(%%ÀÌØí¹½Ñ½½¬±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸ÀÌØí¹½Ñ½½¬ôMÑÉ¥¹½ÉµÐ Ìä콸ÅÕ½ÐìÌÅÕ½ÐìÌäì°ÀÌØí¹½Ñ½½¬¤(%%ÀÌØíÑÑ´±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸($%%9½ÐMÑÉ¥¹IáÀ ÀÌØíÑÑ´°ÅÕ½ÐìÀäÈíÀäÈíÀäÈíÀäÈí½lÀÅtÀäÈí½lÀ´ÍtÀäÈílÀ´ÉulÀ´ÙtélÀ´ÙtÀäÈíélÀ´ÙtÀäÈíÅÕ½Ðì¤Q¡¸IÑÕɸMÑÉÉ½È Ð°À°Ä¤($$ÀÌØíÑÑ´ôMÑÉ¥¹½ÉµÐ Ìäì½ÅÕ½ÐìÌÅÕ½ÐìÌäì°ÀÌØíÑÑ´¤(%¹%(%%ÀÌØíѱÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸($$ÀÌØíÍÁ±¥ÑÑôMÑÉ¥¹MÁ±¥Ð ÀÌØíÑ°ÅÕ½Ðì°ÅÕ½Ðì¤($$ÀÌØíÑôÅÕ½ÐìÅÕ½Ðì($%½ÈÀÌØí¤ôÄQ¼ÀÌØíÍÁ±¥ÑÑlÁt($$$ÀÌØíÍÁ±¥ÑÑlÀÌØí¥tôMÑÉ¥¹MÑÉ¥Á]L ÀÌØíÍÁ±¥ÑÑlÀÌØí¥t°Ì¤($$$ÀÌØíѵÀìôMÑÉ¥¹½ÉµÐ Ìäì½ÐÅÕ½ÐìÌÅÕ½ÐìÌäì°ÀÌØíÍÁ±¥ÑÑlÀÌØí¥t¤($%9áÐ$(%¹%($$($íIÕ¸½µµ¹Ì(%%ÀÌØíÑáÐôÅÕ½ÐìÅÕ½ÐìQ¡¸($$ÀÌØíµôÀÌØí9áµÀìÅÕ½ÐìÉѹ½ÑÅÕ½ÐìµÀìÀÌØí¥±µÀìÀÌØíѵÀìÀÌØíѥѱµÀìÀÌØí¹½Ñ½½¬µÀìÀÌØíÑÑ´($% ½¹Í½±]É¥Ñ ÀÌØíµµÀì1¤($$ÀÌØíÁ¥}8ôIÕ¸ ÀÌØíµ°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤($%IÑÕɸÀ(%±Í($$ÀÌØíµôÀÌØí9áµÀìÅÕ½ÐìÉѹ½ÑÅÕ½ÐìµÀìÀÌØíѵÀìÀÌØíѥѱµÀìÀÌØí¹½Ñ½½¬µÀìÀÌØíÑÑ´($$ÀÌØíÍÑ¥¹}8ôIÕ¸ ÀÌØíµ°ÅÕ½ÐìÅÕ½Ðì°M]}!%°Ä¤($$ÀÌØí¡ÉÍ}ÝÉ¥ÑѸôÀ($%]¡¥±Ä($$%%ÀÌØí¡ÉÍ}ÝÉ¥ÑѸ±ÐìMÑÉ¥¹1¸ ÀÌØíÑáФQ¡¸($$$$ÀÌØí¡ÉÍ}ÝÉ¥ÑѸôMÑ¥¹]É¥Ñ ÀÌØíÍÑ¥¹}8°ÀÌØíÑáФ($$%±Í($$$%á¥Ñ1½½À($$%¹%($%]¹($%IÑÕɸÀ(%¹%)¹Õ¹ìôôÐí}9} ÉÑ9½Ñ
    1 point
×
×
  • Create New...