Leaderboard
Popular Content
Showing content with the highest reputation on 04/18/2018 in all areas
-
Hi guys, I just finished a Connect 4 game by using MiniMax with Alpha Beta Pruning. I haven't written a program for a long time, but writing an AI program is always funny! I have to learn how the algorithm works and try to optimize the code to run faster. Let's play and have fun! Oops, I lost the game ... Thanks guys! Download: Connect 4.zip2 points
-
1 point
-
Hi. I've been working on this for a while. I think now it's good enough to post it here. Functions to do most everything with the DACL and ownership on all types of objects: Files or folders, Registry keys, services, Kernel and WMI objects, etc. Here's a good example to test: #include 'Permissions.au3' _InitiatePermissionResources() FileWrite(@ScriptDir&'test.txt','Test') Local $TI = TimerInit() Local $ret = _DenyAllAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@UserName) Local $TD = TimerDiff($TI) MsgBox(0,'','Deny all access to test.txt and take ownership:'&@CRLF&@CRLF& _ '_DenyAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantReadAccess(@ScriptDir&'test.txt',$SE_FILE_OBJECT,'Administrators') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone read access, all access to admins and system, and set the owner: Admins group'&@CRLF&@CRLF& _ '_GrantReadAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _GrantAllAccess(@ScriptDir&'test.txt') $TD = TimerDiff($TI) MsgBox(0,'','Grant everyone access'&@CRLF&@CRLF& _ '_GrantAllAccesss return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() $ret = _CopyFullDacl(@ScriptDir&'test.txt',$SE_FILE_OBJECT,@ScriptDir) $TD = TimerDiff($TI) MsgBox(0,'','Restore all inherited permissions'&@CRLF&@CRLF& _ '_CopyFullDacl return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $aPerm[2][3] = [['Restricted',1,$GENERIC_ALL],['Users',1,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Add two granted access aces: Restricted and Users'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',1,$GENERIC_READ],['Users',1,$GENERIC_READ]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Give only read access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Dim $aPerm[2][3] = [['Restricted',0,$GENERIC_ALL],['Users',0,$GENERIC_ALL]] $ret = _EditObjectPermissions(@ScriptDir&'test.txt',$aPerm) $TD = TimerDiff($TI) MsgBox(0,'','Deny access to the Restricted and Users groups'&@CRLF&@CRLF& _ '_EditObjectPermissions return value: '&$ret&' Time: '&Round($TD,2)&' miliseconds.'&@CRLF& _ 'Check the file permissons before closing the message box.') $TI = TimerInit() Local $Hndl = _Permissions_OpenProcess(@AutoItPID) Local $SDBefore = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) Local $CODRet = _ClearObjectDacl($Hndl,$SE_KERNEL_OBJECT) Local $DARet = _DenyAllAccess($Hndl,$SE_KERNEL_OBJECT) Local $SDAfter = _GetObjectStringSecurityDescriptor($Hndl,$SE_KERNEL_OBJECT) $TD = Round(TimerDiff($TI),2) MsgBox(0,'', 'Deny everyone access to the current process:'&@CRLF&@CRLF& _ '@AutoItPID original security descriptor: '&@CRLF&$SDBefore&@CRLF&@CRLF& _ '_ClearObjectDacl return value: '&$CODRet&@CRLF&@CRLF& _ '_DenyAllAccess_ return value: '&$DARet&@CRLF&@CRLF& _ 'New @AutoItPID security descriptor: '&@CRLF& _ $SDAfter&@CRLF&@CRLF& 'Time taken: '&$TD&' miliseconds.') _Permissions_CloseHandle($Hndl) FileDelete(@ScriptDir&'test.txt') _ClosePermissionResources()I'm planning to add functions to deal with the Sacl in the future, even though I don't think it's very important. Edit: Let me know if you need an example for the registry. Updated: Fixed a bug in the _ClearObjectDacl function. I thought that adding a null DACL would work fine, but it causes problems later when adding a new DACL. Those who have downloaded, please update. Shoot! Now it wasn't clearing the DACL at all. Updated again. I think it's fixed now. Updated 9/11/2011 - Added the security descriptor functions and removed unnecessary constants. Updated 10/11/2011 - There were some functions missing in the index, and some parameters in the comments. Also removed the "MustDeclareVars" option. (About 50 total downloads before) Update 12/12/2011 - Added more functions: New Update 12/12/2011 - Missing declaration keywords in 3 constants. Sorry Update 16/12/2011 - Added support for all object types, including window and process handles. Added more functions, modified most of them, and removed one. Here's the new function list: Updated 22/2/2012.. This time I'm including SecurityConstants.au3 and FileConstants.au3 to prevent constants conflicts. Added a few more functions and fixed a few bugs. Also added the ability to include the inherited aces in the _EditObjectPermissions function. Now the permissions array can have four elements (optional). It will still work with three elements arrays though. The fourth element is intended to have the inheritance flag for the corresponding ace. Here's the new list of functions: 400 previous downloads Permissions.au31 point
-
Version 1.15.4
864 downloads
cDebug.au3 includes four main debugging UDFs: _GuiDebug(), _ConsDebug(), _ClipDebug() and _FormatValsForDebug(). They all dump the values of all AutoIt subtypes and expressions, in a structured manner, including nested arrays (up to 3 dimensions) and slices of them, and even DLL structs and maps. It is an alternative to a graphical debugger, offering GUI output. The format for calling the UDFs has been designed to make coding a call as convenient and fast as possible, minimizing coding effort and the chances of errors: the $name argument is often the same as the variables arguments, enclosed in quote marks. For DLL structures, if you specify a tag, cDebug checks for differences between it and what it detects. If you only specify a structure variable, it can report the structure it detects, with the values of elements. It does much more than MsgBox(), ConsoleWrite() and _ArrayDisplay(), in a definitely user-friendly manner, and does its best to avoid hiding your code in SciTE. #include cDebug no maps.au3 or cDebug.au3 at the top of your script. If you #include cDebug.au3 (the version with maps) #include #AutoIt3Wrapper_Version=B before #include cDebug.au3 It is fully documented in . During debugging and development of new features, the current version is used to debug the upcoming version, so there is much testing, even so bugs are always possible, particularly in new features, such as reporting elements of maps whose keys match a regular expression. Bug reports and suggestions are welcome. These UDFs have been in regular use for some years. Because when cDebug was developed, maps were a use at your own risk feature, there are two streams of cDebug: cDebug.au3 reports maps, so to use it you must be running a version of AutoIt that supports maps, e.g. 3.3.15.0, and #include cDebug.au3 cDebug no maps.au3 does not report maps, so you can be running any recent version of AutoIt, e.g. 3.3.14.5, and #include cDebug no maps.au3 The only difference between the two streams is that map-reporting code is commented out in cDebug no maps.au3 . These functions are documented in cDebug.pdf A teaser This script: #AutoIt3Wrapper_Version=B ; beta 3.3.15.0 or greater is mandatory for cDebug.au3 #include "cDebug.au3" Local $seasons[] $seasons.summer = 'May to September' $seasons.spring = 'April' $seasons.fall = 'October to November' $seasons.winter = 'December to March' Local $aCats[3][3] = [['jack','black',3],['suki','grey',4],[$seasons,'','']] Local $i = 1 Local $tStruct = DllStructCreate('uint') DllStructSetData($tStruct,1,2018) _GuiDebug('At line '&@ScriptLineNumber,'$cats,jack is,$cats[..][$i],$i,hex,structure{uint}', _ $aCats,$aCats[0][2],$aCats,$i,Hex(-$i),$tstruct) produces: Acknowledgements Melba23, Kafu, ProgAndy, jchd1 point -
Fast Array Management Functions UDF
kurtykurtyboy reacted to LarsJ for a topic
With the functions in Accessing AutoIt Arrays it's possible to create some fast array management functions where all the hard work is done by compiled code or by accessing array memory directly. This is the main UDF for a number of sub-UDFs. The sub-UDFs divided by topics (general functions, sorting functions, etc.) implements the actual array functions and will be published as new examples. The main UDF contains functions to access arrays, functions and utilities common to several sub-UDFs, and functions to display arrays. The display functions are copied from Data display functions based on virtual listviews. Large arrays Arrays of interest are large arrays with 100,000 - 1,000,000 elements. The numbers are very round numbers. Depending on the specific array and situation, it may be 10,000 or 200,000 instead of 100,000 elements. And it may be 500,000 or 10,000,000 instead of 1,000,000 elements. Data types Array data types are primarily simple data types such as integers, floats and strings. Array elements containing arrays (arrays of arrays), functions, objects, structures (DllStructs) or maps (in the beta version) are not supported. The techniques to access AutoIt arrays from compiled code and to access array memory directly are both based on passing arrays as parameters to methods of COM objects. The arrays are passed by value. What happens if a special data type eg. a DllStruct contained in an array element is passed to compiled VB code? Is it still the same DllStruct when the array gets back to AutoIt? Such issues have not been taken into account in this first version. As far as arrays of arrays are concerned and the embedded arrays also contains simple data types there are no problems. This allows for new versions of some of the functions with support for embedded arrays. Maybe also support for other data types. Structure The project is structured this way: FAMproj\ - Top folder Display\ - Data display functions FAMudf\ - Fast Array Management Functions UDF FASudf\ - Fast Array Sorting and Management Functions UDF FGAudf\ - Fast General Array Management Functions UDF FXXudf\ - More fast array management functions UDFs The name of the top folder, FAMproj, is only used in 7z-files. It's not used in any UDFs or scripts. You can rename FAMproj as you want. But the other folders cannot be renamed. These names are used in UDFs and scripts. Main UDF The main UDF, FAMudf, and FAMudf.7z below is organized this way: FAMproj\ - Top folder Display\ - Data display functions FAMudf\ - Fast Array Management Functions UDF AccArrays\ - Access AutoIt arrays from compiled code Utilities\ - Contains utility functions common to all UDFs Readme.txt - Folder list (this list) and usage instructions Sub-UDFs Sub-UDFs, FXXudf's, and corresponding FXXudf.7z files are organized this way: FAMproj\ - Top folder FXXudf\ - Fast Array Management Functions sub-UDF DLLFiles\ - C++ DLL-files and VB.NET assembly DLL-files Examples\ - Example scripts to demonstrate the functions HelpFiles\ - Detailed information about some of the functions Functions.txt - Function list and headers (the main help file) Use_of_UDF.txt - Explains how to use the UDF in your own project Includes\ - Files that you include in your own AutoIt scripts Resources\ - Resources used in examples and runtime measuring Runtimes\ - Compare runtimes for AutoIt code and optimized code Sources\ - Contains C++ source files and VB.NET source files Utilities\ - Utility functions to generate VB.NET DLL-files Readme.txt - Folder list (this list) and usage instructions Not all sub-folders are used in all sub-UDFs. Note that the top folder FAMproj\ is the same folder for all UDFs. If you unzip the 7z-files in <My folder>, FAMproj will be an immediate subfolder: <My folder>\FAMproj. The structure of FAMproj\ should look as described in the Structure-section above. The name FAMproj is only used in 7z-files. You can rename it as you want. C++ code is delivered both as source files and as 32 and 64 bit dll-files. VB code is only delivered as source files which can be compiled and loaded on the fly. If you want to compile VB code into .NET assembly dll-files you have to do it yourself with the functions (usually only one) in Utilities\. All dll-files are stored in DLLFiles\. So far, the following sub-UDFs are available: Fast Array Sorting and Management Functions UDF Fast General Array Management Functions UDF Fast SQLite Management Functions UDF Information This thread will be used for general information for the entire project. Along the way more posts will be added below. Code optimization especially in relation to array transfer End of first version. Next version? FAMudf.7z FAMudf is delivered in FAMudf.7z and is the main UDF that's used by all the sub-UDFs. It contains functions to access arrays from compiled code and to access array memory directly. It also contains the display functions. FAMudf is a set of helper functions, but it does not contain any array management functions. The sub-UDFs contains the array management functions. To use the array management functions you have to download one or more of the sub-UDFs. You need AutoIt 3.3.10 or later. Tested on Windows 10 and Windows 7. Comments are welcome. Let me know if there are any issues. FAMudf.7z1 point -
You want to interact with sensors presumably part of a microcontroller ... I referred you to posts about how others have done that. Have you searched the term? If you do you will see examples of people using AutoIt with the Arduino microcontroller that can interact with a wide array of sensors and devices.1 point
-
I would search the forum for "Arduino".1 point
-
You couldn't be less vague if you tried.1 point
-
How to click on this button
RABANY1 reacted to JLogan3o13 for a topic
@RABANY1 please pay attention to where you post in the future. The DEV forum very clearly states: We even bolded it for you Edit: I also notice you have an account under @rabany, which I have deleted as multiple accounts are not allowed on this forum.1 point -
Problem with Excel_RangeWrite
YouriKamperman reacted to Subz for a topic
Delete the count in the Array _ArrayDelete($aFileList, 0)1 point -
1 point
-
[Solved] Create borders around excel range
kawumm3000 reacted to water for a topic
The needed enumerations to create this variables can be found here: https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlbordersindex-enumeration-excel and here https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlborderweight-enumeration-excel1 point -
Please explain the DllStructCreate(Struct, Pointer) syntax!
pixelsearch reacted to AndyG for a topic
Hi, the "struct" reserves some memory, and the "pointer" points to the first adress of this memory. Here an (not season related^^) example which demonstrates the usage of the so called "memory" (which belongs to NOTHING! (meaning the datatypes) ) ;create struct $struct =dllstructcreate("int;float[4];dword") ;fill struct with data dllstructsetdata($struct,1,123456);int dllstructsetdata($struct,2,4.80114160043301e+030,1);float dllstructsetdata($struct,2,3.68584191575527e+024,2);float dllstructsetdata($struct,2,7.71403089381636e+031,3);float dllstructsetdata($struct,2,8.24605444209785e-019,4);float dllstructsetdata($struct,3,0xDEADBEEF);dword ;read some data from struct at offset 4 $struct2=dllstructcreate("char[16]",dllstructgetptr($struct)+4) msgbox(0,":o)",dllstructgetdata($struct2,1))1 point -
Please explain the DllStructCreate(Struct, Pointer) syntax!
pixelsearch reacted to Bilgus for a topic
basically you are giving a reference to an already created data structure you are just defining what it contains to AutoIt below is an entirely contrived example but it gives you the idea, typically the pointer would be returned from an API function $tInit = DllStructCreate("BYTE[8]") DllStructSetData($tInit, 1, 0xFF, 1) DllStructSetData($tInit, 1, 0xEE, 2) DllStructSetData($tInit, 1, 0xDD, 3) DllStructSetData($tInit, 1, 0xCC, 4) DllStructSetData($tInit, 1, 0x11, 5) DllStructSetData($tInit, 1, 0x22, 6) DllStructSetData($tInit, 1, 0x33, 7) DllStructSetData($tInit, 1, 0x44, 8) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit)) ; Using a pointer $tInit For $i = 1 To 4 ; Show Contents ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ; Setting the data here affects the original data DllStructSetData($tInitPtr, 1, 0xBB, 1) DllStructSetData($tInitPtr, 1, 0xAA, 2) DllStructSetData($tInitPtr, 1, 0x99, 3) DllStructSetData($tInitPtr, 1, 0x88, 4) ConsoleWrite(@CRLF) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInit, 1, $i)) & @CRLF) Next ;lets start at second element (DllStructGetPtr($tInit) + 0 ) is initial (first) element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 1) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ;lets start at third element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 2) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ;lets start at fourth element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 3) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next1 point -
Nul bytes in a string are treated as string termination in a certain number of cases and DllStructGetData is one of them. You might expect that overlaying a ushort[8] DllStrucct above $tsData would solve the problem by allowing you to retrieve the whole ushort array with DllStructGetData. Unfortunately this doesn't work and you only fetch the first ushort of the array if you don't specify an element index. You can still fetch all the elements in a For loop. So yes copying the memory is likely to will work better.1 point
-
1 point
-
Capture screen and display in gui
California reacted to UEZ for a topic
@Allow2010 your GDI+ code produces memory leaks! Try this instead: #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGraphics = 0 $hBitmap = 0 $hBitmaplast = 0 $hHBmp = 0 $hHBmplast = 0 _GDIPlus_Startup() Local $hGUI = GUICreate("TestGUI", 500, 500, @DesktopWidth - 550, -1, -1, $WS_EX_TOPMOST) GUISetState() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hHBmp = _ScreenCapture_Capture("", 0, 0, 499, 499) $hBitmaplast = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) _WinAPI_DeleteObject($hHBmp) RefreshImage() AdlibRegister(RefreshImage, 250) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;cleanup resources _WinAPI_DeleteObject($hHBmp) _WinAPI_DeleteObject($hHBmplast) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmaplast) _GDIPlus_Shutdown() GUIDelete($hGUI) Func RefreshImage() If $hHBmp Then _WinAPI_DeleteObject($hHBmp) $hHBmp = _ScreenCapture_Capture("", 0, 0, 499, 499) If $hBitmap Then _GDIPlus_ImageDispose($hBitmap) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $iCompare = _ASM_BitCompareBitmapsMMX($hBitmap, $hBitmaplast) Switch $iCompare Case 0 If $hBitmaplast Then _GDIPlus_ImageDispose($hBitmaplast) $hBitmaplast = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, 500, 500, $GDIP_PXF24RGB) ConsoleWrite("change" & @CRLF) Case 1 ConsoleWrite("no change" & @CRLF) EndSwitch EndFunc ;==>RefreshImage Func _ASM_BitCompareBitmapsMMX($hBitmap1, $hBitmap2) Local $aDim1 = _GDIPlus_ImageGetDimension($hBitmap1) If @error Then Return SetError(1, 0, -1) Local $aDim2 = _GDIPlus_ImageGetDimension($hBitmap2) If @error Then Return SetError(2, 0, -1) If BitOR($aDim1[0] <> $aDim2[0], $aDim1[1] <> $aDim2[1]) Then Return 1 Local $tBitmapData1 = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $aDim1[0], $aDim1[1], $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $pScan1 = $tBitmapData1.Scan0 Local $iStride1 = $tBitmapData1.Stride * 4 Local $tPixelData1 = DllStructCreate("dword[" & Abs($iStride1 * $aDim1[1]) & "]", $pScan1) Local $tBitmapData2 = _GDIPlus_BitmapLockBits($hBitmap2, 0, 0, $aDim2[0], $aDim2[1], $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $pScan2 = $tBitmapData2.Scan0 Local $tPixelData2 = DllStructCreate("dword[" & Abs($iStride1 * $aDim1[1]) & "]", $pScan2) Local $tCodeBuffer = DllStructCreate("byte ASM[55]") ;reserve memory for ASM opcodes $tCodeBuffer.ASM = "0x8B7424048B7C24088B4C240CB801000000F30F6F0EF30F6F17660FEFCA660F3817C9750D83C61083C71083E90477E2EB05B800000000C3" ;write opcodes into memory (struct) / length: 55 Local $aRet = DllCall("user32.dll", "boolean", "CallWindowProcW", "ptr", DllStructGetPtr($tCodeBuffer), _ "struct*", $tPixelData1, _ "struct*", $tPixelData2, _ "uint", $aDim1[0] * $aDim1[1], _ "int", Null) _GDIPlus_BitmapUnlockBits($hBitmap1, $tBitmapData1) _GDIPlus_BitmapUnlockBits($hBitmap2, $tBitmapData2) Return $aRet[0] EndFunc ;==>_ASM_BitCompareBitmapsMMX1 point -
Capture screen and display in gui
California reacted to Melba23 for a topic
JLogan3o13, And who shamelessly stole it from someone else (probably Malkey or UEZ)! M231 point -
Capture screen and display in gui
California reacted to JLogan3o13 for a topic
You could do something like this with GDI+ (code shamelessly stolen from Melba): #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() Local $hHBmp = _ScreenCapture_Capture("", 0, 0, 500, 500) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) _WinAPI_DeleteObject($hHBmp) Local $hGUI = GUICreate("GDI+ test", 800, 800, -1, -1) GUISetState() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI)1 point -
Activate Excel - Not activating
AnonymousX reacted to water for a topic
Something like this? #include <Excel.au3> $oExcel = _Excel_Open() $sCaption = $oExcel.Caption WinSetState($sCaption, "", @SW_MAXIMIZE)1 point -
Here is a small UDF and example for using Microsoft's Text-to-Speech interface. Please leave some feedback. Let me know if you have any problems or don't understand something. Also the example uses all three microsoft voices. If Mike and Mary are not installed they can be downloaded here UDF: ; #FUNCTION# ==================================================================================================================== ; Name...........: _StartTTS ; Description ...: Creates a object to be used with Text-to-Speak Functions. ; Syntax.........: _StartTTS() ; Parameters ....: ; Return values .: Success - Returns a object ; Author ........: bchris01 ; Example .......: Yes ; =============================================================================================================================== Func _StartTTS() Return ObjCreate("SAPI.SpVoice") EndFunc ;==>_StartTTS ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetRate ; Description ...: Sets the rendering rate of the voice. (How fast the voice talks.) ; Syntax.........: _SetRate(ByRef $Object, $iRate) ; Parameters ....: $Object - Object returned from _StartTTS(). ; $iRate - Value specifying the speaking rate of the voice. Supported values range from -10 to 10 ; Return values .: None ; Author ........: bchris01 ; Example .......: Yes ; =============================================================================================================================== Func _SetRate(ByRef $Object, $iRate); Rates can be from -10 to 10 $Object.Rate = $iRate EndFunc ;==>_SetRate ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetVolume ; Description ...: Sets the volume of the voice. ; Syntax.........: _SetVolume(ByRef $Object, $iVolume) ; Parameters ....: $Object - Object returned from _StartTTS(). ; $iVolume - Value specifying the volume of the voice. Supported values range from 0-100. Default = 100 ; Return values .: None ; Author ........: bchris01 ; Example .......: Yes ; =============================================================================================================================== Func _SetVolume(ByRef $Object, $iVolume);Volume $Object.Volume = $iVolume EndFunc ;==>_SetVolume ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetVoice ; Description ...: Sets the identity of the voice used for text synthesis. ; Syntax.........: _SetVoice(ByRef $Object, $sVoiceName) ; Parameters ....: $Object - Object returned from _StartTTS(). ; $sVoiceName - String matching one of the voices installed. ; Return values .: Success - Sets object to voice. ; Failure - Sets @error to 1 ; Author ........: bchris01 ; Example .......: Yes ; =============================================================================================================================== Func _SetVoice(ByRef $Object, $sVoiceName) Local $VoiceNames, $VoiceGroup = $Object.GetVoices For $VoiceNames In $VoiceGroup If $VoiceNames.GetDescription() = $sVoiceName Then $Object.Voice = $VoiceNames Return EndIf Next Return SetError(1) EndFunc ;==>_SetVoice ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetVoices ; Description ...: Retrives the currently installed voice identitys. ; Syntax.........: _GetVoices(ByRef $Object[, $Return = True]) ; Parameters ....: $Object - Object returned from _StartTTS(). ; $bReturn - String of text you want spoken. ; |If $bReturn = True then a 0-based array is returned. ; |If $bReturn = False then a string seperated by delimiter "|" is returned. ; Return values .: Success - Returns an array or string containing installed voice identitys. ; Author ........: bchris01 ; Example .......: Yes ; =============================================================================================================================== Func _GetVoices(ByRef $Object, $bReturn = True) Local $sVoices, $VoiceGroup = $Object.GetVoices For $Voices In $VoiceGroup $sVoices &= $Voices.GetDescription() & '|' Next If $bReturn Then Return StringSplit(StringTrimRight($sVoices, 1), '|', 2) Return StringTrimRight($sVoices, 1) EndFunc ;==>_GetVoices ; #FUNCTION# ==================================================================================================================== ; Name...........: _Speak ; Description ...: Speaks the contents of the text string. ; Syntax.........: _Speak(ByRef $Object, $sText) ; Parameters ....: $Object - Object returned from _StartTTS(). ; $sText - String of text you want spoken. ; Return values .: Success - Speaks the text. ; Author ........: bchris01 ; Example .......: Yes ; =============================================================================================================================== Func _Speak(ByRef $Object, $sText) $Object.Speak($sText) EndFunc ;==>_SpeakTTS.au3 Example: #include <TTS.au3> $Default = _StartTTS() If Not IsObj($Default) Then MsgBox(0, 'Error', 'Failed create object') Exit EndIf _Speak($Default, 'Hello my name is Sam. I am the default voice. Here are the other voices you have to choose from.') MsgBox(0, 'Voices installed', StringReplace(_GetVoices($Default, False), '|', @CRLF)) $aVoiceSelection = _GetVoices($Default) $Mike = _StartTTS() _SetVoice($Mike, 'Microsoft Mike') If @error Then _Speak($Default, 'Mike is Not installed.') $Mike = False EndIf $Mary = _StartTTS() _SetVoice($Mary, $aVoiceSelection[1]) If @error Then _Speak($Default, 'Mary is Not installed.') $Mary = False EndIf If IsObj($Mike) Then _Speak($Mike, 'Hello my name is Mike.') If IsObj($Mary) Then _Speak($Mary, 'Hello my name is Mary.') _SetRate($Default, 5) _Speak($Default, 'This is Sam talking really really fast.') _SetRate($Default, -5) _Speak($Default, 'This is Sam talking slow.')1 point
-
_Excel: Color modification to a cell
AnonymousX reacted to rameshkumar for a topic
1 point -
_Excel: Color modification to a cell
AnonymousX reacted to picaxe for a topic
$oExcel = ObjCreate("Excel.Application") With $oExcel ; open new workbook .Visible = True .WorkBooks.Add .ActiveWorkbook.Sheets(1).Select() EndWith $sRange ="A1:G8" $k = 1 For $i = 1 To 7 For $j = 1 To 8 $oExcel.ActiveSheet.Range(Chr(64 + $i) & $j).Value = "ColorIndex: " & $k With $oExcel.ActiveSheet.Range(Chr(64 + $i) & $j).Font If Mod($j, 2) Then .Name = "Courier New" .FontStyle = "Italic" ;.Underline = 2 Else .Name = "Comic Sans MS" .FontStyle = "Regular" .Underline = -4119 ; double underline ;.Underline = 4 ; accounting single underline ;.Underline = 5 ; accounting double underline EndIf .Bold = True .ColorIndex = $k .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False EndWith $k += 1 Next Next ; format cells With $oExcel.ActiveSheet.Range($sRange) .Select .HorizontalAlignment = -4108 ; center .ColumnWidth = 18 ;.EntireColumn.AutoFit EndWith ; color columns For $i = 1 To 7 $sCol = Chr(64 + $i) If Mod($i, 2) Then $oExcel.ActiveSheet.Range($sCol & "1:" & $sCol & "8").Interior.ColorIndex = 3 Else $oExcel.ActiveSheet.Range($sCol & "1:" & $sCol & "8").Interior.ColorIndex = 20 EndIf Next1 point -
Close gui window immediately when you click on "X"-button
AnonymousX reacted to KaFu for a topic
Solution above will not exit immediately, if currently an onevent mode function is being processed, but will close after the function return... #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") GUICtrlCreateButton("Trigger long running function...",10,10,200) GUICtrlSetOnEvent(-1,"_sleep") GUISetState(@SW_SHOW) ; will display an empty dialog box While 1 Sleep(20) WEnd func _sleep() sleep(5000) EndFunc Func _Close() GUIDelete() Exit EndFunc This one will... http://www.autoitscript.com/forum/index.php?showtopic=96829&view=findpost&p=6986051 point -
excel: autosize column width?
SkysLastChance reacted to WideBoyDixon for a topic
You're using the first five columns. Try: $oExcel.ActiveSheet.Columns("A:E").AutoFit1 point