Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/11/2024 in all areas

  1. InnI

    ControlClick does not work

    Try adding to the beginning of the script #RequireAdmin
    2 points
  2. SmOke_N

    Problem with SELECT

    That makes me giggle... Whatever the case, I know other mods are already fed up with his ignorantly posturized requests. No matter what people suggest, if they don't write the code for them specifically, this OP is never satisfied to do the work or research. I know others are (including mods) are already at their limit. To the OP, start posting really worked on problems, start researching the suggestions given to you with examples on how those suggestions are not working for you, starting reading some manuals, manuals not only on coding, but maybe how to request help. I'm locking this topic, I know his last topic was locked as well. Hopefully the OP gets the hint.
    2 points
  3. MattyD

    SNMP UDF rewrite

    I've recently been looking at the old SNMP UDP, and although it has served well over a long period of time it did look in need of a freshen up. So from the ground up, reintroducing SNMPv2. The UDF is still only community string stuff, so just SNMPv1 and SNMPv2c for now. V3 support is probably a ways off I'm affraid - the projects only about a week old, and theres a ton of work to be done before attacking that. The basic workflow is: Call the startup func Register a function to recieve incoming messages. (basically to recieve decoded OID/Value pairs.) or if you cant be bothered, an internal one will just write to the console! Open a device start querying devices and stuff The zip file attached has a bunch of demos scripts etc. to get you going. But here's an example script for post #1 anyhow. #include "SNMPv2.au3" ;-------------------------------------------------- Local $sIPAddress = "10.0.0.5" ;Device $__g_bRetTicksAsStr = True ;Return TimeTicks as human readable string (instead of int) ;There are few global params for now that you can set. - Check the demo scripts for details. ;-------------------------------------------------- Global Const $sOID_sysDescr = "1.3.6.1.2.1.1.1.0" Global Const $sOID_sysName = "1.3.6.1.2.1.1.5.0" Global Const $sOID_sysLocation = "1.3.6.1.2.1.1.6.0" Global Const $sOID_sysUpTime = "1.3.6.1.2.1.1.3.0" Global $mOIDLabMap[] $mOIDLabMap[$sOID_sysDescr] = "sysDescr" $mOIDLabMap[$sOID_sysName] = "sysName" $mOIDLabMap[$sOID_sysLocation] = "sysLocation" $mOIDLabMap[$sOID_sysUpTime] = "sysUpTime" ; Startup and register a handler for incoming messages. ; The function must accept 4 parameters - more on this futher down _SNMP_Startup("_CustomMsgHandler") ;Open device Local $iDevice = _SNMP_OpenDevice($sIPAddress) ;Get one specfic property. ;The community param is optional. (defaults to "public") _SNMP_GetRequest($iDevice, $sOID_sysDescr, "public") ;Or get multiple properties in one request. Local $aOids[3] $aOids[0] = $sOID_sysName $aOids[1] = $sOID_sysLocation $aOids[2] = $sOID_sysUpTime _SNMP_GetRequest($iDevice, $aOids) ;Temporarily keep the script alive! Sleep(500) ;Cleanup _SNMP_CloseDevice($iDevice) _SNMP_Shutdown() ; Handler Params: ; $iDevice - device that responded ; $dPacket - rawData ; $avHeader - metadata pulled from the response. Format: $array[6][2] (field, data) ; $avVarBinds - list of OID's and their associated data. Format: $array[n][6] (OID, Type, Value, RawType, RawValue) ; header feilds - "SNMP Version", "Community", "Request Index", "Error Message", "Error Code", "Error Index" Func _CustomMsgHandler($iDevice, $dRawPacket, $avHeaders, $avVarBinds) Local $sFeild, $vData For $i = 0 To UBound($avVarBinds) - 1 ; $avVarBinds[index][OID, Type, Value, RawType, RawValue] $sFeild = $mOIDLabMap[$avVarBinds[$i][0]] $vData = $avVarBinds[$i][2] ConsoleWrite(StringFormat("%15s: %s\r\n", $sFeild, $vData)) Next EndFunc SNMPv2c_1.0.zip
    2 points
  4. New version - 17 Jun 23 ======================= Added: Added 24hr unpadded H mask. New UDF in zip below. Changelog: Changelog.txt Here is my version of a UDF to transform date/time formats. It is entirely self-contained and although it defaults to English for the month/day names, you can set any other language very simply, even having different ones for the input and output. You need to provide a date/time string, a mask to tell the UDF what is in the string, and a second mask to format the output - the masks use the standard "yMdhmsT" characters. This is an example script showing some of the features: #include <Constants.au3> ; Only required for MsgBox constants #include "DTC.au3" Global $sIn_Date, $sOut_Date ; Basic format $sIn_Date = "13/08/02 18:30:15" $sOut_Date = _Date_Time_Convert($sIn_Date, "yy/MM/dd HH:mm:ss", "dddd, d MMMM yyyy at h:mm TT") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note how day name is corrected $sIn_Date = "2013082 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "dddd, dd MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note use of $i19_20 parameter to change century $sIn_Date = "13/08/02 18:30:15" $sOut_Date = _Date_Time_Convert($sIn_Date, "yy/MM/dd HH:mm:ss", "dddd, d MMMM yyyy at h:mm TT", 10) MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) $sIn_Date = "18:30:15 13/08/02" $sOut_Date = _Date_Time_Convert($sIn_Date, "HH:mm:ss yy/MM/dd", "h:mm TT on ddd d MMM yyyy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Just to show it works both ways $sIn_Date = "Friday, 2 August 2013 at 6:30 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "dddd, d MMMM yyyy at h:mm TT", "dd/MM/yy HH:mm") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) $sIn_Date = $sOut_Date $sOut_Date = _Date_Time_Convert($sIn_Date, "dd/MM/yy HH:mm", "dddd, d MMMM yyyy at h:mm TT") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note false returns for non-specified elements $sIn_Date = "6:15 P" $sOut_Date = _Date_Time_Convert($sIn_Date, "h:m T", "yy/MM/dd HH:mm:ss") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note use of "x" in place of actual spacing/punctuation $sIn_Date = "Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "dddxhhxmmxssxTT", "dddd HH:mm") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Output month/day strings changed to French _Date_Time_Convert_Set("smo", "jan,fév,mar,avr,mai,juin,juil,août,sept,oct,nov,déc") _Date_Time_Convert_Set("ldo", "dimanche,lundi,mardi,mercredi,jeudi,vendredi,samedi") _Date_Time_Convert_Set("SDO", 3) ; Each short name is first 3 chars of equivalent long name ; Note as only the short day names are required, they could have been set directly: ; _Date_Time_Convert_Set("sdo", "dim,lun,mar,mer,jeu,ven,sam") $sIn_Date = "20130716 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "ddd, d MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Output month/day strings changed to German _Date_Time_Convert_Set("smo", "Jan.,Feb.,März,Apr.,Mai,Juni,Juli,Aug.,Sept.,Okt.,Nov.,Dez.") _Date_Time_Convert_Set("ldo", "Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag") $sIn_Date = "20130716 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "dddd, d MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; All strings reconverted to default English _Date_Time_Convert_Set() ; As shown here $sIn_Date = "20130716 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "ddd, d MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) And here is the UDF and example in zip format: DTC.zip As always, happy for any comments. M23
    1 point
  5. Totally fine and understandable for me @Newb 🤝 , thanks. Don't worry about it. Post if you want to and no hurry on this. Best regards Sven
    1 point
  6. I can share the code, no problem dude, it's just a bunch of methods and clicks. BIG WARNING: I put up the fastest and ugliest code to make the thing work because I needed to upload a lot of stuff. Even if it's horrible code, it still saved me a TON of time and I uploaded in an afternoon what would have took me 2 weeks. So I'm happy for the result anyway. That said, I also need to tell you that it needs a lot of polishing and testing. If you wish I can post more as I progress into developing it, but I do it in my free time and it will take some time to add missing features and refactor the code in a more ordered and organized way. It's far from perfect and completed and I plan to add a ton of stuff, but here you go: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> ;TODO ;F-01 Filtro lista file? ;F-02 Gestione cartelle ;DONE - F-03 Flag resetta numero file dopo caricamento cartella ;F-04 Btn selezione deseleziona tutte le opzioni ;F-05 Flag scrivi lista dei file ;F-06 Eventuale index per corsi caricati a topic singolo ;BUGS ;B-01: Alcune immagini sono renderizzate nel popup di upload diversamente (vedi corso L1 Calimove) e questo fa saltare l'upload, andrebbe considerato un detect ;grafico del bottone save visto che la UI non si riesce a catturare? ;B-02 BIG FIX: I made a lot of mess for finding "Send" button in upload screen. Instead ;it's just sufficient to send {ENTER} and no detection at all is needed. Damn :D Opt('GUIOnEventMode', '1') HotKeySet('!p', '_Exit') #Region ### START Koda GUI section ### Form= ;CREATE FORM $TgUpperForm = GUICreate("TGUpper", 713, 677, 192, 124) ;CREATE LISTVIEW $ListView1 = GUICtrlCreateListView("", 208, 32, 490, 574) _GUICtrlListView_InsertColumn($ListView1, 0, "File", 380) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 400) ;CREATE TOP BUTTONS $btnSelectFolder = GUICtrlCreateButton("Select Folder", 8, 8, 195, 25) $btnSelectFile = GUICtrlCreateButton("Select File", 8, 40, 195, 25) $btnCreateTopic = GUICtrlCreateButton("Create Topic", 8, 72, 195, 25) $btnSelectAll = GUICtrlCreateButton("Select All", 8, 104, 195, 25) ;CREATE GRUP FOLDER PROGRESSIVE $grpFolderProgressive = GUICtrlCreateGroup("Folder Progressive", 8, 136, 193, 209) $txtPrefixFolderProgressive = GUICtrlCreateInput("", 16, 272, 49, 21) $btnIncreaseFolderProgressiveCounter = GUICtrlCreateButton("+", 16, 176, 43, 25) $txtPostfixFolderProgressive = GUICtrlCreateInput("", 144, 272, 49, 21) $btnDecreaseFolderProgressiveCounter = GUICtrlCreateButton("-", 64, 176, 43, 25) $txtCounterFolderProgressive = GUICtrlCreateInput("0", 80, 272, 49, 21) $btnResetFolderProgressiveCounter = GUICtrlCreateButton("Reset", 112, 176, 75, 25) $chkEnableFolderProgressive = GUICtrlCreateCheckbox("Enable Folder Progressive", 16, 152, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAutoIncrementFolderProgressiveCounter = GUICtrlCreateCheckbox("Autoincrement", 16, 208, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) $lblPrefixFolderProgressive = GUICtrlCreateLabel("Prefix", 16, 248, 30, 17) $lblCounterFolderProgressive = GUICtrlCreateLabel("Counter", 80, 248, 41, 17) $lblPostfixCounterprogressive = GUICtrlCreateLabel("Postfix", 144, 248, 35, 17) $lblFolderProgressiveSeparator = GUICtrlCreateLabel("Separator", 128, 208, 50, 17) $txtFolderProgressiveSeparator = GUICtrlCreateInput(" ", 128, 224, 57, 21) $txtReplaceTextInTopicName = GUICtrlCreateInput("", 16, 312, 177, 21) $lblReplaceTextInTopicName = GUICtrlCreateLabel("Text to replace in topic name", 16, 296, 141, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) ;CREATE GROUP FILE PROGRESSIVE $grpFileProgressive = GUICtrlCreateGroup("File Progressive", 8, 352, 193, 193) $txtPrefixFileProgressive = GUICtrlCreateInput("", 16, 488, 49, 21) $btnIncreaseFileProgressiveCounter = GUICtrlCreateButton("+", 16, 392, 43, 25) $txtPostfixFileProgressive = GUICtrlCreateInput("", 144, 488, 49, 21) $btnDecreaseFileProgressiveCounter = GUICtrlCreateButton("-", 64, 392, 43, 25) $txtCounterFileProgressive = GUICtrlCreateInput("1", 80, 488, 49, 21) $btnResetFileProgressiveCounter = GUICtrlCreateButton("Reset", 112, 392, 75, 25) $chkEnableFileProgressive = GUICtrlCreateCheckbox("Enable File Progressive", 16, 368, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAutoIncrementFileProgressiveCounter = GUICtrlCreateCheckbox("Autoincrement", 16, 424, 169, 17) GUICtrlSetState(-1, $GUI_CHECKED) $lblPrefixFileProgressive = GUICtrlCreateLabel("Prefix", 16, 464, 30, 17) $lblCounterFileProgressive = GUICtrlCreateLabel("Counter", 80, 464, 41, 17) $lblPostfixFileProgressive = GUICtrlCreateLabel("Postfix", 144, 464, 35, 17) $txtFileProgressiveSeparator = GUICtrlCreateInput(" ", 128, 440, 57, 21) $lblFileProgressiveSeparator = GUICtrlCreateLabel("Separator", 128, 424, 50, 17) $chkResetFileProgressiveCounterOnReopenFolderOrdFile = GUICtrlCreateCheckbox("Reset count after file/folder open", 16, 520, 177, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;CREATE BOTTOM BUTTONS $chkRefocusFormAfterTopicCreation = GUICtrlCreateCheckbox("Refocus form after creating topic", 16, 555, 177, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAutoLoadFilesAfterTopic = GUICtrlCreateCheckbox("Autoload files after topic creation", 16, 577, 185, 17) GUICtrlSetState(-1, $GUI_CHECKED) $chkAskEveryFile = GUICtrlCreateCheckbox("Ask confirmation for every file", 16, 619, 185, 17) $chkElaborateAllFolders = GUICtrlCreateCheckbox("Elaborate all folders automatically", 16, 598, 177, 17) $btnProcessFiles = GUICtrlCreateButton("Process selected files", 8, 640, 195, 25) GUICtrlSetState($btnProcessFiles, $GUI_DISABLE) ;CREATE UPPER LISTVIEW LABELS $lblCurrentFolderDesc = GUICtrlCreateLabel("Current folder", 208, 8, 67, 17) $lblNextFolderDesc = GUICtrlCreateLabel("Next folder", 456, 8, 55, 17) $txtCurrentFolder = GUICtrlCreateInput("-", 280, 5, 169, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $txtNextFolder = GUICtrlCreateInput("-", 512, 5, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;CREATE LOWER LISTVIEW BUTTONS/LABELS $chkNextFolderAutoSwap = GUICtrlCreateCheckbox("Auto swap next folder", 224, 616, 121, 17) $btnOpenFolder = GUICtrlCreateButton("Open Folder", 352, 612, 139, 25) $btnSwapNextFolder = GUICtrlCreateButton("Next Folder", 504, 612, 195, 25) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $actionsdelay = 2200 Global $actionsdelay_short = 700 Global $actionsdelay_very_short = 400 Global $lastButtonClicked = "" Global $folder = "" Global $nextFolder = "" GUICtrlSetOnEvent($btnSelectFolder, "SelectFolder") GUICtrlSetOnEvent($btnSelectFile, "SelectFile") GUICtrlSetOnEvent($btnCreateTopic, "CreateTopic") GUICtrlSetOnEvent($btnIncreaseFolderProgressiveCounter, "IncreaseFolderProgressiveCounter") GUICtrlSetOnEvent($btnDecreaseFolderProgressiveCounter, "DecreaseFolderProgressiveCounter") GUICtrlSetOnEvent($btnResetFolderProgressiveCounter, "ResetFolderProgressiveCounter") GUICtrlSetOnEvent($btnIncreaseFileProgressiveCounter, "IncreaseFileProgressiveCounter") GUICtrlSetOnEvent($btnDecreaseFileProgressiveCounter, "DecreaseFileProgressiveCounter") GUICtrlSetOnEvent($btnResetFileProgressiveCounter, "ResetFileProgressiveCounter") GUICtrlSetOnEvent($btnProcessFiles, "ProcessFiles") GUICtrlSetOnEvent($btnSelectAll, "SelectAll") GUICtrlSetOnEvent($btnSwapNextFolder, "SwapNextFolder") GUICtrlSetOnEvent($chkNextFolderAutoSwap, "_chkNextFolderAutoSwap") GUICtrlSetOnEvent($chkAutoLoadFilesAfterTopic, "_chkAutoLoadFilesAfterTopic") While 1 Sleep(100) WEnd Func SelectFolder() $folder = FileSelectFolder("Select a folder", "") If @error Then MsgBox($MB_OK, "Error", "No folder selected.") Return EndIf $files = _FileListToArray($folder, "*", 1) If @error Then MsgBox($MB_OK, "Error", "No files found in the selected folder.") Return EndIf UpdateFileList($files) $lastButtonClicked = "SelectFolder" If GUICtrlRead($chkResetFileProgressiveCounterOnReopenFolderOrdFile) = $GUI_CHECKED Then ResetFileProgressiveCounter() EndIf UpdateCurrentFolderDisplay() UpdateNextFolderDisplay() UpdateSwapNextFolderButton() UpdateProcessFilesButton() SelectAll() EndFunc Func SelectFile() $selectedFile = FileOpenDialog("Select a file", @WorkingDir, "All files (.)", 1) If @error Then MsgBox($MB_OK, "Error", "No file selected.") Return EndIf $files = StringSplit($selectedFile, "|", 1) UpdateFileList($files) $lastButtonClicked = "SelectFile" If GUICtrlRead($chkResetFileProgressiveCounterOnReopenFolderOrdFile) = $GUI_CHECKED Then ResetFileProgressiveCounter() EndIf UpdateCurrentFolderDisplay() UpdateNextFolderDisplay() UpdateSwapNextFolderButton() UpdateProcessFilesButton() EndFunc Func UpdateFileList($files) _GUICtrlListView_DeleteAllItems($ListView1) For $i = 1 To UBound($files) - 1 If Not StringIsDigit($files[$i]) Then _GUICtrlListView_AddItem($ListView1, $files[$i]) EndIf Next EndFunc Func IncreaseFolderProgressiveCounter() $folderCounter = Int(GUICtrlRead($txtCounterFolderProgressive)) + 1 GUICtrlSetData($txtCounterFolderProgressive, $folderCounter) EndFunc Func DecreaseFolderProgressiveCounter() $folderCounter = Int(GUICtrlRead($txtCounterFolderProgressive)) If $folderCounter > 0 Then $folderCounter -= 1 GUICtrlSetData($txtCounterFolderProgressive, $folderCounter) EndIf EndFunc Func ResetFolderProgressiveCounter() GUICtrlSetData($txtCounterFolderProgressive, 0) EndFunc Func IncreaseFileProgressiveCounter() $fileCounter = Int(GUICtrlRead($txtCounterFileProgressive)) + 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndFunc Func DecreaseFileProgressiveCounter() $fileCounter = Int(GUICtrlRead($txtCounterFileProgressive)) If $fileCounter > 0 Then $fileCounter -= 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndIf EndFunc Func ResetFileProgressiveCounter() GUICtrlSetData($txtCounterFileProgressive, 1) EndFunc Func ProcessFiles() Local $selectedFiles[0] For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1 If _GUICtrlListView_GetItemChecked($ListView1, $i) Then _ArrayAdd($selectedFiles, _GUICtrlListView_GetItemText($ListView1, $i)) EndIf Next If UBound($selectedFiles) = 0 Then MsgBox($MB_OK, "Error", "No files selected.") Return EndIf $askConfirmation = (GUICtrlRead($chkAskEveryFile) = $GUI_CHECKED) For $i = 0 To UBound($selectedFiles) - 1 $filePath = $selectedFiles[$i] If $askConfirmation Then $confirmResult = MsgBox($MB_OKCANCEL, "Confirmation", "Process file:" & @CRLF & $filePath) If $confirmResult = $IDCANCEL Then Return ; Abort the whole process EndIf EndIf If $lastButtonClicked = "SelectFolder" Then ProcessFolderFile($filePath) ElseIf $lastButtonClicked = "SelectFile" Then ProcessSingleFile($filePath) EndIf Next If GUICtrlRead($chkNextFolderAutoSwap) = $GUI_CHECKED Then SwapNextFolder() WinActivate($TgUpperForm) EndIf EndFunc Func ProcessFolderFile($filePath) $folderName = GetFolderName($folder) $fileName = GetFileName($filePath) $fileFullPath = $folder & "\" & $filePath $filePrefix = GUICtrlRead($txtPrefixFileProgressive) $fileCounter = GUICtrlRead($txtCounterFileProgressive) $filePostfix = GUICtrlRead($txtPostfixFileProgressive) $fileSeparator = GuiCtrlRead($txtFileProgressiveSeparator) If GUICtrlRead($chkEnableFileProgressive) = $GUI_CHECKED Then $finalFileName = $filePrefix & $fileCounter & $filePostfix & $fileSeparator & $fileName Else $finalFileName = $fileName EndIf If GUICtrlRead($chkAutoIncrementFileProgressiveCounter) = $GUI_CHECKED Then $fileCounter = Int($fileCounter) + 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndIf UploadFile($fileFullPath, $finalFileName) EndFunc Func ProcessSingleFile($filePath) $folderName = GetFolderName($folder) $fileName = GetFileName($filePath) $fileFullPath = $folder & "" & $filePath $filePrefix = GUICtrlRead($txtPrefixFileProgressive) $fileCounter = GUICtrlRead($txtCounterFileProgressive) $filePostfix = GUICtrlRead($txtPostfixFileProgressive) If GUICtrlRead($chkEnableFileProgressive) = $GUI_CHECKED Then $finalFileName = $filePrefix & $fileCounter & $filePostfix & " - " & $fileName Else $finalFileName = $fileName EndIf $folderPrefix = GUICtrlRead($txtPrefixFolderProgressive) $folderCounter = GUICtrlRead($txtCounterFolderProgressive) $folderPostfix = GUICtrlRead($txtPostfixFolderProgressive) If GUICtrlRead($chkEnableFolderProgressive) = $GUI_CHECKED Then $finalFolderName = $folderPrefix & $folderCounter & $folderPostfix & " - " & $folderName Else $finalFolderName = $folderName EndIf MsgBox($MB_OK, "Processing Single File", "Folder Name: " & $finalFolderName & @CRLF & "File Full Path: " & $fileFullPath & @CRLF & "File Name: " & $finalFileName) If GUICtrlRead($chkAutoIncrementFileProgressiveCounter) = $GUI_CHECKED Then $fileCounter = Int($fileCounter) + 1 GUICtrlSetData($txtCounterFileProgressive, $fileCounter) EndIf EndFunc Func GetFolderNameFromPath($path) Return StringRegExpReplace($path, "^.*\\", "") EndFunc Func GetFolderName($folderPath) Local $folderName = StringRegExpReplace($folderPath, "^.*\", "") Return $folderName EndFunc Func GetFileName($filePath) Local $fileName = StringRegExpReplace($filePath, "^.*\", "") Return $fileName EndFunc Func SelectAll() For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1 _GUICtrlListView_SetItemChecked($ListView1, $i) Next EndFunc Func _Exit() Exit EndFunc Func CreateTopic() If _GUICtrlListView_GetItemCount($ListView1) < 1 Then MsgBox($MB_OK, "Error", "No files selected.") Return EndIf $TopicName = GetFolderName($folder) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($folder, $sDrive, $sDir, $sFileName, $sExtension) $folderPrefix = GUICtrlRead($txtPrefixFolderProgressive) $folderCounter = GUICtrlRead($txtCounterFolderProgressive) $folderPostfix = GUICtrlRead($txtPostfixFolderProgressive) $folderSeparator = GuiCtrlRead($txtFolderProgressiveSeparator) $folderName = $aPathSplit[3] If GUICtrlRead($chkEnableFolderProgressive) = $GUI_CHECKED Then $topicName = $folderPrefix & $folderCounter & $folderPostfix & $folderSeparator & $folderName Else $topicName = $folderName EndIf If GUICtrlRead($chkAutoIncrementFolderProgressiveCounter) = $GUI_CHECKED Then $folderCounter = Int($folderCounter) + 1 GUICtrlSetData($txtCounterFolderProgressive, $folderCounter) EndIf $replaceText = GUICtrlRead($txtReplaceTextInTopicName) If $replaceText <> "" Then $topicName = StringReplace($topicName, $replaceText, "") $topicName = StringStripWS($topicName, 3) EndIf ;click on 3 dots MouseClick("left", 310, 50, 1, $actionsdelay) ;click on Create Topic MouseClick("left", 230, 85, 1, $actionsdelay) ;click on Create Topic MouseClick("left", 890, 360, 1, $actionsdelay) Send($TopicName, 1) ;click on Create Topic MouseClick("left", 1080, 755, 1, $actionsdelay) $filesList = _FileListToArray($folder, "*", 1) $fileListMessage = $topicName & @LF & "Files: " & _ArrayToString($filesList, @LF) WriteMessage($fileListMessage) If GUICtrlRead($chkRefocusFormAfterTopicCreation) = $GUI_CHECKED Then Sleep($actionsdelay_very_short) WinActivate($TgUpperForm) EndIf If GUICtrlRead($chkAutoLoadFilesAfterTopic) = $GUI_CHECKED Then ProcessFiles() EndIf ElaborateAllFolders() ; Call the new function EndFunc Func UploadFile($Path, $Filename) $chooseFilesWindowTitle = "Choose Files" ;click on clip icon to open file upload MouseClick("left", 355, 1010, 1, $actionsdelay_short) WinWait($chooseFilesWindowTitle) Sleep($actionsdelay) ;click on path textbox of upload file window ControlClick($chooseFilesWindowTitle, "", 1148) Sleep($actionsdelay_short) ;Inputs file path on the textbox Send($Path, 1) Sleep($actionsdelay_short) ;Click open to start uploading file on telegram ControlClick($chooseFilesWindowTitle, "", 1) ;Longer wait for telegram file upload window Sleep($actionsdelay) ;click on textbox for telegram file ;if Mp4 preview moves buttons down $extension = StringUpper(StringRight($Filename, 4)) If $extension = ".MP4" Then MouseClick("left", 865, 630, 1) ElseIf $extension = ".JPG" Or $extension = ".PNG" Or StringUpper(StringRight($Filename, 5)) = ".JPEG" Or StringUpper(StringRight($Filename, 5)) = ".JFIF" Then MouseClick("left", 865, 700, 1) Else MouseClick("left", 865, 560, 1) EndIf Sleep($actionsdelay_short) ;Write file name Send($Filename, 1) Sleep($actionsdelay_short) ;Clicks Send If $extension = ".mp4" Then MouseClick("left", 1100, 675, 1) ElseIf $extension = ".JPG" Or $extension = ".PNG" Or StringUpper(StringRight($Filename, 5)) = ".JPEG" Or StringUpper(StringRight($Filename, 5)) = ".JFIF" Then MouseClick("left", 1100, 745, 1) Sleep($actionsdelay_short) ;temp fix for smaller/different resolution images that move up the Send button ;Will be solved with pixelchecksum method While PixelGetColor(785,320) = 16777215 Sleep($actionsdelay_short) MouseClick("left",1100,720,1) WEnd Else MouseClick("left", 1100, 610, 1) EndIf EndFunc Func UpdateCurrentFolderDisplay() GUICtrlSetData($txtCurrentFolder, GetFolderName($folder)) EndFunc Func UpdateNextFolderDisplay() $nextFolder = GetNextFolderInAlphabeticalOrder($folder) GUICtrlSetData($txtNextFolder, GetFolderName($nextFolder)) EndFunc Func GetNextFolderInAlphabeticalOrder($currentFolder) Local $folderList = _FileListToArray($currentFolder & "\..", "*", 2) If @error Then Return "" EndIf Local $currentFolderName = GetFolderNameFromPath($currentFolder) Local $currentFolderIndex = _ArraySearch($folderList, $currentFolderName, 1) ; If folder is the last one then no next folder If $currentFolderIndex = UBound($folderList) - 1 Then Return "END-FOLDERS" EndIf Return _PathFull($currentFolder & "\..") & "\" & $folderList[$currentFolderIndex + 1] EndFunc Func SwapNextFolder() If $nextFolder = "" Or $nextFolder = "END-FOLDERS" Then MsgBox($MB_OK, "Info", "This was the last folder to process. No more folders to open.") Return EndIf $folder = $nextFolder $files = _FileListToArray($folder, "*", 1) If @error Then MsgBox($MB_OK, "Error", "No files found in the selected folder.") Return EndIf UpdateFileList($files) $lastButtonClicked = "SelectFolder" If GUICtrlRead($chkResetFileProgressiveCounterOnReopenFolderOrdFile) = $GUI_CHECKED Then ResetFileProgressiveCounter() EndIf UpdateCurrentFolderDisplay() UpdateNextFolderDisplay() UpdateSwapNextFolderButton() UpdateProcessFilesButton() SelectAll() EndFunc Func _chkNextFolderAutoSwap() If GUICtrlRead($chkNextFolderAutoSwap) = $GUI_CHECKED Then GUICtrlSetState($btnSwapNextFolder, $GUI_DISABLE) Else GUICtrlSetState($btnSwapNextFolder, $GUI_ENABLE) EndIf EndFunc Func _chkAutoLoadFilesAfterTopic() If GUICtrlRead($chkAutoLoadFilesAfterTopic) = $GUI_CHECKED Then GUICtrlSetState($btnProcessFiles, $GUI_DISABLE) Else GUICtrlSetState($btnProcessFiles, $GUI_ENABLE) EndIf EndFunc Func UpdateSwapNextFolderButton() If GUICtrlRead($chkNextFolderAutoSwap) = $GUI_CHECKED Then GUICtrlSetState($btnSwapNextFolder, $GUI_DISABLE) Else GUICtrlSetState($btnSwapNextFolder, $GUI_ENABLE) EndIf EndFunc Func UpdateProcessFilesButton() If GUICtrlRead($chkAutoLoadFilesAfterTopic) = $GUI_CHECKED Then GUICtrlSetState($btnProcessFiles, $GUI_DISABLE) Else GUICtrlSetState($btnProcessFiles, $GUI_ENABLE) EndIf EndFunc ;NOTE: @CRLF will result in telegram sending the message ;To write multiline message you got to use @LF and then manually send {ENTER} Func WriteMessage($message) Sleep($actionsdelay_short) MouseClick("left", 400, 1010, 1) Send($message, 1) Send("{ENTER}") EndFunc Func ElaborateAllFolders() If GUICtrlRead($chkElaborateAllFolders) = $GUI_CHECKED Then While True CreateTopic() ProcessFiles() If GUICtrlRead($txtNextFolder) = "END-FOLDERS" Then ExitLoop EndIf SwapNextFolder() WinActivate($TgUpperForm) WEnd EndIf EndFunc
    1 point
  7. Just check a little further if UIAutomation out of the box can help you more. see faq 31 for example but just to see if uiautomation can help test with simplespy or a more mature advanced one. UIASpy (or try inspect.exe from Microsoft) I just tried to install telegram desktop for windows and its "seeing" some controls (but definitely not all)
    1 point
  8. Great... and all of this was worth waiting for those 13 years! 🫤
    1 point
  9. So just for the heck of it: the full SciTE4AutoIt3 comes with a PersonalTools.lua in the %localappdata%\AutoIt v3\SciTE, so this is an example LUA function how you could update the version on each save, when it is found in the source file: -- Update version of line with this format: -- ;Version: 1.001 -- on each save function PersonalTools:OnBeforeSave(path) if editor.Lexer == SCLEX_AU3 and path ~= "" then local spos, epos = editor:findtext('^\\s*;Version:\\s*[\\d\\.]*', SCFIND_REGEXP, 0) if spos then local dline = editor:textrange(spos, epos) local curversion = dline:match('Version:%s*([%d%.]*)') newversion = curversion + 0.001 editor:SetSel(spos, epos) editor:ReplaceSel(";Version: " .. string.format("%.3f", newversion)) end end end Over to you to modify it to your wishes.
    1 point
  10. Wow, I was going to answer but I ended up learning some new stuff. Always useful to monitor help request posts
    1 point
  11. I found issue with calltips. Please try this snippet: _ArrayDisplay($aTest, "TITLE") _ArrayDisplay($aTest, "TITLE (v2)") place the cursor on v2 inside this bracket, try to bring caltips with CTRL+SHIFT+SPACE
    1 point
  12. Hi. I wanted to share an algorithm I found online that I thought was neat, so I have ported it over from Python to Autoit. (If I am not quite sure If I can link to external sites on this forum, so if you're interested in the website I have got this math from, feel free to PM me.) The code makes a cursor move realistically by simulating gravity pulling the cursor to a point and wind making it move unpredictably. The cursor speeds up from far away, slows down as it gets closer, and stops when it's close enough. Here is what human mouse movement recorded in Gimp looks like : And here are some random examples of what the code can produce on default parameters : The following is the mouse movement function, use it however you will, but please do not discuss game automation in this thread or contact me about anything having to do with such. (this is against forum rules) Hope someone finds some good use for this. Happy new years. #include <Math.au3> #include <Array.au3> MoveMouse(297, 551,1305,341) Func MoveMouse($start_x, $start_y, $dest_x, $dest_y, $G_0 = 9, $W_0 = 3, $M_0 = 15, $D_0 = 12) Local $current_x = $start_x, $current_y = $start_y Local $v_x = 0, $v_y = 0, $W_x = 0, $W_y = 0 While _Dist($dest_x, $dest_y, $start_x, $start_y) >= 1 Local $dist = _Dist($dest_x, $dest_y, $start_x, $start_y) Local $W_mag = Min($W_0, $dist) If $dist >= $D_0 Then $W_x = $W_x / Sqrt(3) + (2 * Random() - 1) * $W_mag / Sqrt(5) $W_y = $W_y / Sqrt(3) + (2 * Random() - 1) * $W_mag / Sqrt(5) Else $W_x /= Sqrt(3) $W_y /= Sqrt(3) If $M_0 < 3 Then $M_0 = Random() * 3 + 3 Else $M_0 /= Sqrt(5) EndIf EndIf $v_x += $W_x + $G_0 * ($dest_x - $start_x) / $dist $v_y += $W_y + $G_0 * ($dest_y - $start_y) / $dist Local $v_mag = _Dist(0, 0, $v_x, $v_y) If $v_mag > $M_0 Then Local $v_clip = $M_0 / 2 + Random() * $M_0 / 2 $v_x = ($v_x / $v_mag) * $v_clip $v_y = ($v_y / $v_mag) * $v_clip EndIf $start_x += $v_x $start_y += $v_y Local $move_x = Round($start_x) Local $move_y = Round($start_y) If $current_x <> $move_x Or $current_y <> $move_y Then MouseMove($move_x,$move_y,1) ConsoleWrite("Move Mouse to: " & $move_x & ", " & $move_y & @CRLF) $current_x = $move_x $current_y = $move_y EndIf WEnd Return $current_x & "," & $current_y EndFunc ; Calculate distance between two points Func _Dist($x1, $y1, $x2, $y2) Return Sqrt(($x2 - $x1) ^ 2 + ($y2 - $y1) ^ 2) EndFunc Func Min($a, $b) If $a < $b Then Return $a Else Return $b EndIf EndFunc
    1 point
  13. Hi all, I am happy to introduce my latest AutoIt hobby project. Glance. It is a gui library created with windows api functions. Back end of this library is a dll file created in Nim programming language. So you have to place the dll near to your exe. Here is a screenshot. Please see the image. And here is the sample code for the window in the image. #AutoIt3Wrapper_UseX64=y #include "glance.au3" Local $frm = glf_NewForm("My Autoit window in Nim", 1100, 500) ; Create new Form aka Window glf_FormCreateHwnd($frm) ; Create the form's handle Local $mbar = glf_FormAddMenuBar($frm, "File|Edit|Help") ; Create a menubar for this form glf_FormAddMenuItems($frm, "File", "New Job|Remove Job|Exit") ; Add some sub menus for 'File' & 'Edit' menus glf_FormAddMenuItems($frm, "Edit", "Format|Font") glf_FormAddMenuItems($frm, "New Job", "Basic Job|Intermediate Job|Review Job") ; Add some submenus to 'New Job' glf_MainMenuAddHandler($frm, "Basic Job", $gMenuEvents.onClick, "menuClick"); Add an event handler for 'Basic Job' Local $btn1 = glf_NewButton($frm, "Normal", 15) ; Now create some buttons Local $btn2 = glf_NewButton($frm, "Flat", 127) Local $btn3 = glf_NewButton($frm, "Gradient", 240) glf_ControlSetProperty($btn2, $gControlProps.backColor, 0x90be6d) ; Set back color property glf_ButtonSetGradient($btn3, 0xf9c74f, 0xf3722c) ; make this button gradient glf_ControlAddHandler($btn1, $gControlEvents.onClick, "onBtnClick") ; Add an event handler for btn1 Local $cal = glf_NewCalendar($frm, 15, 70) ; A simple calendar control. Local $cb1 = glf_NewCheckBox($frm, "Compress", 40, 280) ; Create two checkboxes Local $cb2 = glf_NewCheckBox($frm, "Extract", 40, 310) glf_ControlSetProperty($cb2, $gControlProps.foreColor, 0xad2831) ; Set the checked property to True Local $cmb = glf_NewComboBox($frm, 350, 25) ; Create new ComboBox glf_ComboAddRange($cmb, "Windows|Linux|Mac|ReactOS") ; Add some items. You can use an array also glf_ControlSetProperty($cmb, $gControlProps.backColor, 0x68d8d6) ; Set the back color Local $dtp = glf_NewDateTimePicker($frm, 350, 72) ; Create new DateTimePicker aka DTP Local $gb = glf_NewGroupBox($frm, "My Groupbox", 25, 245, 150, 100) ; Create new GroupBox glf_ControlSetProperty($gb, $gControlProps.foreColor, 0x1a659e) ; Set the fore color Local $lbl = glf_NewLabel($frm, "Static Label", 260, 370) ; Create a Label glf_ControlSetProperty($lbl, $gControlProps.foreColor, 0x008000) ; Set the fore color Local $lbx = glf_NewListBox($frm, 500, 25) ; Create a ListBox glf_ListBoxAddRange($lbx, "Windows|Linux|Mac OS|ReactOS") ; Add some items glf_ControlSetProperty($lbx, $gControlProps.backColor, 0xffc2d4); Set the back color Local $lv = glf_NewListView($frm, 270, 161, 330, 150) ; Create a ListView glf_ListViewSetHeaderFont($lv, "Gabriola", 18) ; Set header font glf_ControlSetProperty($lv, $gListViewProps.headerHeight, 32) ; Set header height glf_ControlSetProperty($lv, $gListViewProps.headerBackColor, 0x2ec4b6) ; Set header back color glf_ControlSetProperty($lv, $gControlProps.backColor, 0xadb5bd) ; Set list view back color glf_ListViewAddColumns($lv, "Windows|Linux|Mac OS", "0") ; Add three columns glf_ListViewAddRow($lv, "Win 8|Mint|OSx Cheetah") ; Add few rows glf_ListViewAddRow($lv, "Win 10|Ubuntu|OSx Catalina") glf_ListViewAddRow($lv, "Win 11|Kali|OSx Ventura") Local $cmenu = glf_ControlSetContextMenu($lv, "Forums|General|GUI Help|Dev Help") ; Add a context menu to list view Local $np1 = glf_NewNumberPicker($frm, 385, 114) ; Create two new NumberPicker aka Updown control Local $np2 = glf_NewNumberPicker($frm, 300, 114) glf_ControlSetProperty($np2, $gNumberPickerProps.buttonLeft, True) ; Set the buttons position to left. Default is right glf_ControlSetProperty($np2, $gControlProps.backColor, 0xeeef20) ; Set back color glf_ControlSetProperty($np2, $gNumberPickerProps.decimalDigits, 2) ; Set the decimal precision to two glf_ControlSetProperty($np2, $gNumberPickerProps.stepp, 0.25) ; Set the step value to 0.25 Local $pgb = glf_NewProgressBar($frm, 25, 363) ; Create a progressbar glf_ControlCreateHwnd($pgb) glf_ControlSetProperty($pgb, $gProgressBarProps.value, 30) ; Set the value to 30% glf_ControlSetProperty($pgb, $gProgressBarProps.showPercentage, True) ; We can show the percentage in digits Local $rb1 = glf_NewRadioButton($frm, "Compiled", 655, 25) ; Create new RadioButtons Local $rb2 = glf_NewRadioButton($frm, "Interpreted", 655, 55) glf_ControlSetProperty($rb1, $gRadioButtonProps.checked, True) ; Set one of them checked Local $tb = glf_NewTextBox($frm, "Some text", 270, 326, 150) ; Create a new TextBox glf_ControlSetProperty($tb, $gControlProps.foreColor, 0xd80032) ; Set the foreColor Local $tkb1 = glf_NewTrackBar($frm, 760, 351) ; Create new TrackBars Local $tkb2 = glf_NewTrackBar($frm, 540, 351) glf_ControlSetProperty($tkb1, $gTrackBarProps.customDraw, True) ; If set to True, we can change lot of aesthetic effects glf_ControlSetProperty($tkb2, $gTrackBarProps.customDraw, True) glf_ControlSetProperty($tkb1, $gTrackBarProps.showSelRange, True) ; We can see the selection are in different color. glf_ControlSetProperty($tkb2, $gTrackBarProps.ticColor, 0xff1654) ; Set tic color ; glf_ControlSetProperty($tkb2, $gTrackBarProps.channelColor, 0x006d77) ; Set channel color. Local $tv = glf_NewTreeView($frm, 760, 25, 0, 300) ; Create new TreeView glf_ControlSetProperty($tv, $gControlProps.backColor, 0xa3b18a) ; Set back color glf_ControlCreateHwnd($tv) glf_TreeViewAddNodes($tv, "Windows|Linux1|MacOS|ReactOS" ) ; Add some nodes glf_TreeViewAddChildNodes($tv, 0, "Win 7|Win 8|Win 10|Win 11") ; Add some child nodes glf_TreeViewAddChildNodes($tv, 1, "Mint|Ubuntu|Red Hat|Kali") glf_TreeViewAddChildNodes($tv, 2, "OSx Cheetah|OSx Leopard|OSx Catalina|OSx Ventura") func onBtnClick($c, $e) ; $c = sender of this event aka, the button itself. $e = EventArgs, like in .NET print("Calendar view mode", glf_ControlGetProperty($cb1, $gControlProps.width)) EndFunc func menuClick($m, $e) ; Here $m is menu itself. $e is MenuEventArgs print("Menu clicked", $m) EndFunc glf_FormShow($frm.ptr) ; All set, just show the form You can get the files from my git repo. Here is the link https://github.com/kcvinker/Glance.git
    1 point
  14. As I understand you are trying to use this API: https://www.whatsapp.com/business/api/?lang=en If so the best would be if you use winhttp.au3 UDF.
    1 point
×
×
  • Create New...