Jump to content

Newb

Active Members
  • Posts

    232
  • Joined

  • Last visited

Profile Information

  • Location
    Italy

Recent Profile Visitors

290 profile views

Newb's Achievements

Polymath

Polymath (5/7)

9

Reputation

  1. 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
  2. Wow, I was going to answer but I ended up learning some new stuff. Always useful to monitor help request posts
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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?
  9. Update: I tried ControlGetHandle As suggested. NOTE: To make the Window info detection work, I had to deactivate Spy++ logic detection or else it won't detect all the properties correctly But maybe I'm doing something wrong in clicking the control. Here's what I do: WinActivate($WindowTitle) $a = ControlGetHandle("TrueCrypt","E&xit",1062) if Not $a Then MsgBox(0,"No handle","Not found") Else MsgBox(0,"Handle", String($a)) EndIf ControlClick($a, "E&xit", 1062) Here's with spy: Trying to close the program and it will stay in the traybar (so I can't kill the process). Handle is found: The click just doesn't happen. Anyone can help? EDIT: More info: I tried to check return value of controlclick MsgBox(0,"ctrlcickreturn", String(ControlClick($a, "E&xit", 1062))) and it returns 0, so basically looks like it's not working
  10. Ok, I will experiment with it. Anyway, I found a solution, I can just do it with keystrokes, it just required a bit of thinkering with how windows controls work. I just needed to send a few {UP} and {DOWN} keystrokes
  11. Hello! I want to automate the setup process and container mount. I knew about command line but making it with keystrokes was faster I also want to learn to get control handles efficiently to ease the automation processes. Anyway, I found a solution, I can just do it with keystrokes, it just required a bit of thinkering with how windows controls work. I just needed to send a few {UP} and {DOWN} keystrokes
  12. Hello AutoIT community, Long time I didn't log back here, absolutely happy to see the project is still alive and maintained. AutoIT taught me programming and gave me many joys, I was trying to automate some setups for a machine, and Powershell was just not enough for my needs: https://stackoverflow.com/questions/39353073/how-i-can-send-mouse-click-in-powershell Looking here, it seems quite a clunky task to do. So, since I automated a lot of stuff in AutoIT, I've decided to get back at it (and it feels so much better now that I'm a full stack developer since a decade). I managed to automate all the setup and configuration except a point where I need to select a drive in the scroll down list show here: I tried all that I know, so I think I'm missing something. The idea is to focus it, then move up and down with arrow (or Send() a drive letter so it gets highlighted) then follow up with TABS and ENTER and Send() to compile the rest of the form. Sample script: #Truecrypt window name Local Const $TC71WindowName = "TrueCrypt" Local Const $TC71Location = "C:\Program Files\TrueCrypt\TrueCrypt.exe" #Configuring TC Run($TC71Location) Sleep(500) If WaitAndActivateWindow($TC71WindowName) Then #TC installed Open and configure MsgBox(0,"Error", "Sending D") #Handler of drive select form Local $driveControlHandler = HWnd("[CLASS:Static; INSTANCE:2]") ControlFocus($driveControlHandler) Send("D") Sleep(200) Send("{TAB}") Sleep(200) Send("{TAB}") Sleep(200) Send($PathTc) Else Exit() EndIf The thing revolves around " HWnd("[CLASS:Static; INSTANCE:2]")" where I try to get handle of the window section in the screenshot. I also tried to get it by Window Name/Text and whatever, but it just seems that I cant navigate or interact with it. NOTE: The scroll list CANNOT be navigated with tab, arrow or anything. I've aleady tried. Also I would avoid doing MouseClicks because that's really resolution and window position dependent.. If anyone dares to try, heres the setup for Truecrypt 7.1a. http://www.oldversion.com/windows/truecrypt-7-1 or google it from wherever you feel BONUS: I really would like to avoid doing all the navigation in the old fashioned way "TAB TAB TAB ENTER TAB TAB SEND("SOMEKEYS") TAB TAB ENTER SPACE.....", you got what I mean. I would like to be able to handle buttons by their class/handle to do some bulletproof code. What am I missing? Why I can't select buttons and windows correctly?
  13. In the way that I just want to count how much times the buttons are pressed, I couldn't care less what is actually typed, if someone types 'apple' I want the number 5 as result, not what the user actually typed. I can post the source here if you want. Anyway this doesn't make you sure I haven't malicious intentions, so, well, it's finally all up to you. If I really had malicious intentions I could have just not mention what the final use of the program was and just ask you about storing a file online and modifying it.
×
×
  • Create New...