Leaderboard
Popular Content
Showing content with the highest reputation on 11/16/2021 in all areas
-
Please give the current beta version of AutoIt3Wrapper.au3 v21.316.1639.7, which should fix this issue.1 point
-
Wohoo. I found a bug ... 🙂 <pat's self on back>1 point
-
_Excel_BookOpenText Leading 0's
SkysLastChance reacted to water for a topic
This works for me: #include <Excel.au3> #include <MsgBoxConstants.au3> ; Create application object Local $oExcel = _Excel_Open() ; Open a text file as delimited, separator = |, pass fieldinfo and set ; DecimalSeparator and ThousandsSeparator. Local $sTextFile = @ScriptDir & "\Import.txt" Local $aField1[2] = [1, $xlTextFormat] Local $aField2[2] = [2, $xlTextFormat] Local $aField3[2] = [3, $xlTextFormat] Local $aField4[2] = [4, $xlTextFormat] Local $aField5[2] = [5, $xlTextFormat] Local $aField6[2] = [6, $xlTextFormat] Local $aField7[2] = [7, $xlTextFormat] Local $aField8[2] = [8, $xlTextFormat] Local $aFieldInfo[] = [$aField1, $aField2, $aField3, $aField4, $aField5, $aField6, $aField7, $aField8] _Excel_BookOpenText($oExcel, $sTextFile, Default, $xlDelimited, Default, True, "|", $aFieldInfo, ",", ".") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF", "Error opening '" & $sTextFile & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 1", "Workbook '" & $sTextFile & "' has been opened successfully.")1 point -
_Excel_BookOpenText Leading 0's
SkysLastChance reacted to water for a topic
If it is a number with a leading 0 and can be 7 to 10 digits long then - in my opinion - this is a text. So you need to specify the correct format for the column when importing. See the example in your post #11 point -
It's as simple as this: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) $aData = FileReadToArray("C:\Local\Test\Test.txt") _Excel_RangeWrite($oWorkbook, 1, $aData) Replace _Excel_BookNew with _Excel_BookOpen to open your existing workbook. In _ExcelRangeWrite you can specify where to write the data to.1 point
-
Version 1.7.0.0 of the UDF has been released. Now you get a help file that looks like the AutoIt help. Please test before using in production! For download please see my signature.1 point
-
Active Directory UDF - Help & Support (III)
DonChunior reacted to water for a topic
Version 1.6.0.0 of the UDF has been released. Now you get a help file that looks like the AutoIt help. Please test before using in production! For download please see my signature.1 point -
Send Message in Microsoft Teams
SkysLastChance reacted to Danyfirex for a topic
Probably the easier way is to use PowerShell Module because to write it from raw AutoIt you will probably need HTTP request knowledge. Saludos1 point -
I created this after I developed >_ShellFolder() because I was interested in the entry displaying when an associated file was right clicked on. I was also intrigued to see how easy it would be to register a file type with my program, quite easy it appears. The UDF is a little different to what I've seen on the forum as this works with the Current User and/or All Users and an icon is created in the ContextMenu too. The entry will pass the file name to your program via a commandline argument, so you'll have to use $CmdLine/$CmdLineRaw to access the file that was selected. Any problems or suggestions then please post below. Thanks. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _ShellFile ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the shell contextmenu when selecting an assigned filetype, includes the program icon as well. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== #include <Constants.au3> ; #GLOBAL VARIABLES# ============================================================================================================ ; None ; #CURRENT# ===================================================================================================================== ; _ShellFile_Install: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting an assigned filetype to the program. ; _ShellFile_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; None ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFile_Install ; Description ...: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting an assigned filetype to the program. ; Syntax ........: _ShellFile_Install($sText, $sFileType[, $sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sIconPath = @ScriptFullPath[, ; $iIcon = 0[, $fAllUsers = False[, $fExtended = False]]]]]]) ; Parameters ....: $sText - Text to be shown in the contextmenu. ; $sFileType - Filetype to be associated with the application e.g. .autoit or autoit. ; $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $sIconPath - [optional] Location of the icon e.g. program executable or dll file. Default is @ScriptFullPath. ; $iIcon - [optional] Index of icon to be used. Default is 0. ; $fAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; $fExtended - [optional] Show in the Extended contextmenu using Shift + Right click. Default is False. ; Return values .: Success - Returns True ; Failure - Returns False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellFile_Install($sText, $sFileType, $sName = @ScriptName, $sFilePath = @ScriptFullPath, $sIconPath = @ScriptFullPath, $iIcon = 0, $fAllUsers = False, $fExtended = False) Local $i64Bit = '', $sRegistryKey = '' If $iIcon = Default Then $iIcon = 0 EndIf If $sFilePath = Default Then $sFilePath = @ScriptFullPath EndIf If $sIconPath = Default Then $sIconPath = @ScriptFullPath EndIf If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & '\SOFTWARE\Classes\' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & '\SOFTWARE\Classes\' EndIf $sFileType = StringRegExpReplace($sFileType, '^\.+', '') $sName = StringLower(StringRegExpReplace($sName, '\.[^.\\/]*$', '')) If StringStripWS($sName, $STR_STRIPALL) = '' Or FileExists($sFilePath) = 0 Or StringStripWS($sFileType, $STR_STRIPALL) = '' Then Return SetError(1, 0, False) EndIf _ShellFile_Uninstall($sFileType, $fAllUsers) Local $iReturn = 0 $iReturn += RegWrite($sRegistryKey & '.' & $sFileType, '', 'REG_SZ', $sName) $iReturn += RegWrite($sRegistryKey & $sName & '\DefaultIcon\', '', 'REG_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & '\shell\open', '', 'REG_SZ', $sText) $iReturn += RegWrite($sRegistryKey & $sName & '\shell\open', 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & '\shell\open\command\', '', 'REG_SZ', '"' & $sFilePath & '" "%1"') $iReturn += RegWrite($sRegistryKey & $sName, '', 'REG_SZ', $sText) $iReturn += RegWrite($sRegistryKey & $sName, 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & '\command', '', 'REG_SZ', '"' & $sFilePath & '" "%1"') If $fExtended Then $iReturn += RegWrite($sRegistryKey & $sName, 'Extended', 'REG_SZ', '') EndIf Return $iReturn > 0 EndFunc ;==>_ShellFile_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFile_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; Syntax ........: _ShellFile_Uninstall($sFileType[, $fAllUsers = False]) ; Parameters ....: $sFileType - Filetype to be associated with the application e.g. .autoit or autoit. ; $fAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - Returns True ; Failure - Returns False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellFile_Uninstall($sFileType, $fAllUsers = False) Local $i64Bit = '', $sRegistryKey = '' If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & '\SOFTWARE\Classes\' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & '\SOFTWARE\Classes\' EndIf $sFileType = StringRegExpReplace($sFileType, '^\.+', '') If StringStripWS($sFileType, $STR_STRIPALL) = '' Then Return SetError(1, 0, False) EndIf Local $iReturn = 0, $sName = RegRead($sRegistryKey & '.' & $sFileType, '') If @error Then Return SetError(2, 0, False) EndIf $iReturn += RegDelete($sRegistryKey & '.' & $sFileType) $iReturn += RegDelete($sRegistryKey & $sName) Return $iReturn > 0 EndFunc ;==>_ShellFile_UninstallExample 1: #include <GUIConstantsEx.au3> #include '_ShellFile.au3' If @Compiled = 0 Then Exit MsgBox($MB_SYSTEMMODAL, '@Compiled Returned 0.', 'Please compile the program before testing. Thanks.') EndIf _Main() Func _Main() Local $sFilePath = '' If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] EndIf Local $hGUI = GUICreate('_ShellFile() Example', 370, 110) GUICtrlCreateEdit(_GetFile($sFilePath), 10, 5, 350, 65) ; If a file was passed via commandline then random text will appear in the GUICtrlCreateEdit(). Local $iAdd = GUICtrlCreateButton('Add FileType', 10, 80, 75, 25) Local $iRemove = GUICtrlCreateButton('Remove FileType', 90, 80, 95, 25) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iAdd _ShellFile_Install('Open with _ShellFile()', 'autoit') ; Add the running EXE to the Shell ContextMenu. If @error Then MsgBox($MB_SYSTEMMODAL, 'Association NOT Created.', '".autoit" was not associated due to an error occurring.') Else MsgBox($MB_SYSTEMMODAL, 'Association Created.', '"RandomFile.autoit" file was created to show that the filetype ".autoit" has been associtated with ' & @ScriptName & '.' & _ @CRLF & @CRLF & 'If you restart the computer you''ll see the icon of "RandomFile.autoit" is the same as the program icon.' & _ @CRLF & @CRLF & 'Now close the program and double/right click on "RandomFile.autoit" to display the random text in the edit box.') EndIf _SetFile(_RandomText(5000), @ScriptDir & '\RandomFile.autoit', 1) ; Create a file with Random text. Case $iRemove _ShellFile_Uninstall('autoit') ; Remove the running EXE from the Shell ContextMenu. If @error Then MsgBox($MB_SYSTEMMODAL, 'Association NOT Deleted.', '".autoit" was not deleted from the Registry due to an error occurring.') Else MsgBox($MB_SYSTEMMODAL, 'Association Deleted.', '".autoit" was successfully deleted from the Registry and is no longer associated with ' & @ScriptName & '.') EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_Main Func _GetFile($sFilePath, $sFormat = 0) Local $hFileOpen = FileOpen($sFilePath, $sFormat) If $hFileOpen = -1 Then Return SetError(1, 0, 'No File Was Passed Via Commandline.') EndIf Local $sData = FileRead($hFileOpen) FileClose($hFileOpen) Return $sData EndFunc ;==>_GetFile Func _RandomText($iLength = 7) Local $iCount = 0, $iCRLF, $sData = '', $sRandom For $i = 1 To $iLength $sRandom = Random(55, 116, 1) If $iCount = 100 Then $iCRLF = @CRLF $iCount = 0 EndIf $sData &= Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) & $iCRLF $iCount += 1 $iCRLF = '' Next Return $sData EndFunc ;==>_RandomText Func _SetFile($sString, $sFilePath, $iOverwrite = 0) Local $hFileOpen = FileOpen($sFilePath, $iOverwrite + 1) FileWrite($hFileOpen, $sString) FileClose($hFileOpen) If @error Then Return SetError(1, 0, $sString) EndIf Return $sString EndFunc ;==>_SetFileAll of the above has been included in a ZIP file. ShellFile.zip1 point