Jump to content

Newb

Active Members
  • Posts

    241
  • Joined

  • Last visited

Profile Information

  • Location
    Italy

Recent Profile Visitors

452 profile views

Newb's Achievements

Polymath

Polymath (5/7)

9

Reputation

  1. Moreover, after further trying and thinking, this makes even less sense. Calling the _DelayedRecordCoordAndChecksum works (as expected since it calls the function separately and not from a hotkey) Calling it from HotKeySet('!q', '_RecordCoordAndChecksum') calls _RecordCoordAndChecksum($delay = 10) and $delay is already defined, I don't get why it says "Variable used without being declared" since it has a default value and it's exactly there in the Func signature. Though, removing the default value says it gets called without enough params. This means the function is called by HotkeySet without params but the function should run anyway since it has a default value!!!! This doesn't make any sense as calling from HotkeySet should be the same as calling a function with default parameters without passing the parameter, thus letting the function use the default param value
  2. Thanks, no need, it's just the nth stupid utility script, no need to build a workaround over it, i'ìll just do the autoit standard way, adding the nth global var on top of the script, lmao
  3. I think this should be on the first line of the remarks and not the last lol. Beside this, the real problem is that the error message returned is sneaky, unclear and misleading to use an euphemism.
  4. Maybe i'm getting old maybe i'm getting picky maybe i'm used to high level language but, After years and years of sporadically returning to autoit and building experience as senior dev I find that autoit has some huge gaps that crook it and make it frustrating and unusable. As for what made me do this post, here you go: I needed to do some quick tool to capture pixel coords, pixel checksum and stuff for automation activities and Au3Info basically sucks (and also does not help capturing advanced windows in various programs). So the source, since it always gets asked is: #include <MsgBoxConstants.au3> Opt("PixelCoordMode", 1) Opt("MouseCoordMode", 1) Global $coordinates[2][2] = [[0, 0], [0, 0]] ; Store 2 points (x, y) Global $count = 0 Global $keepRunning = True HotKeySet('!q', '_RecordCoordAndChecksum') HotKeySet('!d', '_DelayedRecordCoordAndChecksum') HotKeySet('!a', '_CopyCoord') HotKeySet('!p', '_Exit') While $keepRunning Sleep(100) WEnd #for web areas with Hover pseudoclasses so you can move mouse out Func _DelayedRecordCoordAndChecksum() _RecordCoordAndChecksum(3000) EndFunc Func _RecordCoordAndChecksum($delay = 10) If $count < 2 Then Local $pos = MouseGetPosition() $coordinates[$count][0] = $pos[0] $coordinates[$count][1] = $pos[1] $count += 1 EndIf If $count == 2 Then Sleep($delay) Local $checksum = PixelChecksum($coordinates[0][0], $coordinates[0][1], $coordinates[1][0], $coordinates[1][1]) Local $finalResult = $coordinates[0][0] & "," & $coordinates[0][1] & "," & $coordinates[1][0] & "," & $coordinates[1][1] & "," & $checksum MsgBox($MB_SYSTEMMODAL, "Checksum Generated", "Coordinates and Checksum: " & $finalResult) ClipPut($finalResult) $count = 0 _ResetArray() EndIf EndFunc Func _Exit() $keepRunning = False EndFunc Func _ResetArray() For $i = 0 To 1 $coordinates[$i][0] = 0 $coordinates[$i][1] = 0 Next EndFunc Func MouseGetPosition() Return MouseGetPos() EndFunc Func _CopyCoord() $finalResult = MouseGetPos() MsgBox($MB_SYSTEMMODAL, "Coords" , $finalResult[0] & "," & $finalResult[1]) ClipPut($finalResult[0] & "," & $finalResult[1]) EndFunc Beside the fact that you usually have to move half of the stuff in Global vars else you get a shit ton of errors and all becomes much more complicated, this particular script says when you double press ALT+Q Well, it doesn't make any F... sense I have Func _RecordCoordAndChecksum($delay = 10) so it's absolutely defined and initialized. Also when calling: _DelayedRecordCoordAndChecksum I get the same stuff even though i pass: _RecordCoordAndChecksum(3000) Not even GPT is able to identify any issue (I always avoid to pester the help forum if possible) That said the whole language is unreliable and randomly fails repeating the same task because of.... reasons? who the hell knows, it just skips a beat doing what it's programmed to do Also tried to automate something on chrome and it doesn't send the hotkeys Also whenever you handle files any file with a dot (.) in the name makes AutoIT go apeshit Also any resolution change makes autoit useless And so on, I could keep going. The more I use it as an advanced user the more I lose faith in it even though I was a big fan of it
  5. As title says, I'm forced to rename all folders as 01,02,03,04 else I get that dumbass ordering 1,10,11,2,20,21 and so on. Any way to fix this dumb ordering?
  6. Well, as far as it may interest you, I ended up thinking "Heck, they're the same thing how this is possible", I then proceeded to install the full autoit+scite and running from scite works without changing a single bit of code. For what it concerns me, I'm quite ok like this as I got my result. But it's quite concerning for who have to distribute their program out there, since this could lead to software non working on other systems.
  7. Dang, I suspected that. Well, looks like I'll have to recapture all the windows handles and make a switch for win 10/11. Does in any case UIAutomation helps in whatever way of standardizing these controls so I don't have to do differentiate for each OS version?
  8. Hello, I made a tool for automating some stuff, you know, just click some windows, input some file paths in the choose files windows and stuff like that. Now, I developed it in a windows 11 sandbox (More info, someone might find this useful), and i tried to run it on a Win 10 machine. Mouse moves, but is unable to select text areas to input file paths and so on. Basically some functions don't work. Is it that windows handles are different or something like that? Do I have to recapture every window handle and adapt it?
  9. 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
  10. Wow, I was going to answer but I ended up learning some new stuff. Always useful to monitor help request posts
  11. Thanks a lot, but for now just going with the old MouseClick is working far better and it's far faster and easier. The final idea is to make a program with configurable actions and the coords of the controls stored in a config so that it can adapt to other resolutions. Too clunky and works poor. Not considering this solution anytime soon for any application. Sorry Hello, your solution is basically what I am already doing: controlling the UI with the classic mouse/keyboard controls that autoit gives. Thanks for the hint, the problem is I need a far more complex solution that create groups and organizes files with complex naming and like a catalogue. I ended up writing my own solution with the old method of controlling mouse and keyboard with autoit and a few of UI checks here and there: I need to manage trees of deep folders and carefully categorize them so I had to work on a fully complex solution that recognizes and categorize media carefully, often listing files or providing meaningful descriptions and other stuff. Lot of them are courses I bought and that I watch when I'm travelling or gym courses that I use to do follow-along workouts or courses that I watch when I have time. But there are also lot of documents that require careful categorization. I will add necessary pieces in my free time and planning to add OpenAI API integration for some more advanced AI planners/agent if needed, probably through a .NET minimal API using Semantic Kernel. But time will tell what my needs will actually be and what I need to implement. For now I'm quite satisfied like this. The whole point on being so obsessed to actually be able to get handles on telegram controls was because being able to directly interact with controls gives you a much more precise way of doing stuff without having to do shenaningans with PixelGetColor, PixelChecksum and stuff like that, which are a much more clunky way of detecting stuff onscreen. Thanks for the help. For now I think I've found my solution and I won't move to any other, unless we find a direct way to interact with telegram desktop controls in a precise way. Farewell, Newb But heck, just being able to automate all that I've already automated saved me tons of HOURS of manually categorizing stuff and uploading it
  12. Ok, I forgot to mention, but I have already evaluated these kind of solutions and I don't like them simply because they're in that kind of grey area of their TOS that could get your account banned. Since I uploaded literally terabytes of stuff and my account is like 10 years old, I don't feel like risking. They boast unlimited cloud storage and actively encourage you to use telegram as such and it worked quite weil for that purpose (beside being a wonderful messaging app that all my friends have) without never having a trouble with the telegram community/staff. To be honest, they seem like pretty random in taking actions against who uses these kind of bot stuff, but I don't want to lose my account. Whatever automates a real number profile (profile that should belong to a user and be used manually and instead you're using the telegram API to make it what they call a "userbot") gets a bit too much attention from them. They don't care instead, if actions looks like are taken from a user (so autoit clicking the UI is a good thing because it simulates a user behind the screen) That's why I didn't use any of these solutions. Hello, No, telegram isn't actually a necessity. It was more because in the years I automated a number of things with it and I was more aquainted to it than any other solution. I will try to get a look in automating electron apps just for the sake of knowledge, because, still, proceeding with autoit and writing just a few stupid pixel checking functions seems a much quicker way to proceed than setting up a whole electron testing battery. Thanks for the clue though. I will let you know if I get any advance with electron testing What actually bothers me more is that there isn't a clear way to get handles on these kind of controls because they're wrapped into an electron app, which is kinda bad. On the other side, telegram has, like whatsapp a web version of the app. I clearly remember automating various websites through the IE.au3, embedding the browser directly into the Autoit application and automating stuff in there. Of course IE is not an option anymore, but I guess other libs for chrome and FF came out (I saw some chrome webdriver libs for autoit here in the forum) could be a valid solution too, with a much more predictable control detection
  13. So, I took a look at the guy's work. It's a bit of a hot mess described in broken english actually. I work as a senior dev so I'm familiar with the concepts he marks as prerequisites (unit testing, testing frameworks and so on). Basically he build a Windows UI automation wrapper for autoit. The whole thing is quite confiusing expecially in the part of having "logic names" (I found difficult to even do some notepad automation with his examples in front of me) for controls detected and looks like a whole overhead effort to click a few buttons. Moreover, I tried his "simplespy" tool on telegram desktop and doesn't seems, at least at first sight, to do a much better work than Au3Info. It's kinda of a bet trying to learn how to actually use this and getting nowhere with the final goal I have, when a bit of old pixel color and pixel checksum work could get the job done. Guy seems a genuine high level technical person but this thing he did just rubs me in the wrong way. As a dev it gives the feeling that learning this will give me far more trouble than benefits. Thanks anyway
  14. Oh well.... that post looks... dense. Lot of infos there. I will check it in the morning. I already tought to use the AutoIT browser automation libs with chrome or FF with webdriver udfs or such, but the whole "just make a windows GUI and click buttons on the desktop app was much more straightforward and just took like 150 lines of code to do a good part of the automation I needed ahahahah, I guess I'm lazy that's why I automate with less code possible, Thanks for the help I will let you know
  15. As I asked a few months ago, but never got a response, i will try again in case someone had an idea this time: Hello, I was trying to use autoit to interact with telegram desktop because I need to automate file uploading, expecially for folders with a lot of files. I saw there are various UDF libs for Telegram already (to my pleasure, I must say), but looks like they're for direct interaction with telegram API, so kinda to use them with a bot. Unfortunately bot file management is severely limited in size of files (20mb compared to 4gb on premium normal user) and other aspects. Therefore my last choice was to automate in some way telegram desktop in a way that directly interacts with the window (WinGetHandle, WinExists, etc etc.). Unfortunately, probably due to the fact that as I understood telegram is packed with electron, and electron AFAIK just displays a webapp into an exe,, trying to use Window Info tool doesn't give any result beside a main window, which has the current chat name and a random number. The only way to grab it is by classname like this: Func Window_Telegram_GetHandle() Return WinGetHandle("[CLASS:" & $WindowClass_Telegram & "]") EndFunc Func Window_Telegram_GetHandle() Return WinGetHandle("[CLASS:" & $WindowClass_Telegram & "]") EndFunc But I'm unable to catch any other button/UI element info with the telegram application. They all give the same handle info of the main page. I tried to disable/enable Spy++ detection logic but nothing changed. This leaves me to 3 roads: 1) Maybe there is another way to detect the handles and I don't know? 2) Trying some injector (https://github.com/itsKaynine/electron-injector for example) to inject html/js directly and interact with it 3) Download telegram desktop source code and do it by yself but I think it will take too much time. Anyone has suggestions/help? Additional considerations: The only way i can actually think of working with this right now, with autoit, unless someone has a better idea, is to sandbox the whole thing to have a fixed resolution, then work heavily with PixelChecksums and pixel detection methods Is there any other particular reason on how we can work through autoit detecting controls in it? I'm interested in digging the matter For the records, I see they use "Qt widgets" for the UI, and I see someone else digged into the matter
×
×
  • Create New...