Shaheen288 Posted September 26, 2020 Share Posted September 26, 2020 i am new to autoit and i don't know any programming i am trying to auto complete a app named irfanview, everything was fine but i can't control click one button others work fine. the button i cant click is called "start Batch" Autoit Window info >>>> Window <<<< Title: Batch conversion Class: #32770 Position: 32, 98 Size: 886, 728 Style: 0x96CC00C4 ExStyle: 0x00010101 Handle: 0x0000000000030666 >>>> Control <<<< Class: Button Instance: 5 ClassnameNN: Button5 Name: Advanced (Class): [CLASS:Button; INSTANCE:5] ID: 1 Text: &Start Batch Position: 18, 556 Size: 116, 28 ControlClick Coords: 75, 18 Style: 0x50010000 ExStyle: 0x00000004 Handle: 0x00000000000606D4 >>>> Mouse <<<< Position: 133, 703 Cursor ID: 0 Color: 0xE1E1E1 And My code expandcollapse popup; Terminate script if no command-line arguments If $CmdLine[0] = 0 Then Exit (1) Global $imageName imageName = $cmdline[1] ;run iview Run(@ScriptDir & '\iview\i_view64.exe') AutoItSetOption('MouseCoordMode', 0) WinWait('IrfanView') WinActivate('IrfanView') ; open Batch conversion Send('b') WinWait('Batch conversion') WinActivate('Batch conversion') ; input Image name ControlClick('Batch conversion', '', 1001) Sleep(300) Send($imageName & '_##', 1) Sleep(300) ; Add All ControlClick('Batch conversion', 'A&dd all', 1906) Sleep(300) ;this button-----------------------------------------<<<<<<<<<< ; start Batch ControlClick('Button', '&Start Batch', 1) ; Wait for Batch Sleep(3000) WinWait('Batch conversion done') WinActivate('Batch conversion done') ; close Batch ControlClick('Batch conversion done', 'Exit batch', 2) ; close IrfanView WinWait('IrfanView') WinActivate('IrfanView') Send('{ESC}') Thanks. Link to comment Share on other sites More sharing options...
zeenmakr Posted September 27, 2020 Share Posted September 27, 2020 (edited) 11 hours ago, Shaheen288 said: i am trying to auto complete a app named irfanview, everything was fine but i can't control click one button others work fine. the button i cant click is called "start Batch" expandcollapse popup; Terminate script if no command-line arguments If $CmdLine[0] = 0 Then Exit (1) Global $sImageName $sImageName = $cmdline[1] ;~ $sImageName = 'hello' ;for testing purposes ;~ AutoItSetOption('MouseCoordMode', 0) Opt('TrayIconDebug', 1) Global $_CLASS_TITLE_IRFANVIEW = '[CLASS:IrfanView; TITLE:IrfanView]' Global $_CLASS_TITLE_IRFANVIEW_BATCH = '[CLASS:#32770; TITLE:Batch conversion]' Global $_CLASS_TITLE_IRFANVIEW_BATCH_DONE = '[CLASS:#32770; TITLE:Batch conversion done]' ; directory for all images Global $_IMAGE_SOURCE_DIRECT_FOLDER = '_Images' ;IMPORANT: will be used to check later if folder is fully loaded Global $_IMAGE_SOURCE_FOLDER_PATH = @DesktopDir &'\'& $_IMAGE_SOURCE_DIRECT_FOLDER Global $_IMAGE_DESTINATION_FOLDER_PATH = @DesktopDir &'\OutPut_Images' ; source path check If Not FileExists($_IMAGE_SOURCE_FOLDER_PATH) Then MsgBox(0, @ScriptLineNumber&': ERROR', 'Folder not found ['& $_IMAGE_SOURCE_FOLDER_PATH&']') Exit EndIf ; destination path check If Not FileExists($_IMAGE_DESTINATION_FOLDER_PATH) Then DirCreate($_IMAGE_DESTINATION_FOLDER_PATH) ; ------------------------------------------------ ; 1st Main-Window - IrfanView ; ------------------------------------------------ ;run iview Local $hWnd Local $exeFile = 'i_view64.exe' ;~ Local $exeFile = 'i_view32.exe' If Not ProcessExists($exeFile) Then Run(@ScriptDir & '\iview\'& $exeFile) $hWnd = WinWait($_CLASS_TITLE_IRFANVIEW) ; . . . . . . . . . . . . . . . . . . . . . . . . . . . . ; for testing purposes ; . . . . . . . . . . . . . . . . . . . . . . . . . . . . ;~ If ProcessExists($exeFile) Then ;~ $hWnd = WinGetHandle($_CLASS_TITLE_IRFANVIEW) ;~ Else ;~ MsgBox(0, @ScriptLineNumber&': Error', '') ;~ Exit ;~ EndIf ;~ WinActivate($hWnd) ;~ WinWaitActive($hWnd, '', 10) ; close existing window - Batch conversion If WinExists($_CLASS_TITLE_IRFANVIEW_BATCH) Then WinClose($_CLASS_TITLE_IRFANVIEW_BATCH) ; ------------------------------------------------ ; 2nd window - Batch Conversion ; ------------------------------------------------ ; open a fresh window - Batch conversion WinMenuSelectItem($hWnd, "", "&File", "&Batch Conversion/Rename...") Local $hWndChild = WinWait($_CLASS_TITLE_IRFANVIEW_BATCH) WinWaitActive($hWndChild, 10) ; select radio button in [Work as:] ;~ ControlClick($hWndChild, '', 'Button15') ;Batch conversion ;~ ControlClick($hWndChild, '', 'Button16') ;Batch rename ControlClick($hWndChild, '', 'Button17') ;Batch conversion - rename result file ; set Name pattern: in [Batch rename settings:] ControlSetText($hWndChild, '', 'Edit2', $sImageName &'_##') ; set images Source Folder Path ControlSetText($hWndChild, '', 'Edit1', $_IMAGE_SOURCE_FOLDER_PATH) ControlSend($hWndChild, '', 'Edit1', '{ENTER}') ;do not use ControlSend to set text in this case use ControlSetText() instead ; set iamges Destinaton Folder Path ControlSetText($hWndChild, '', 'Edit3', $_IMAGE_DESTINATION_FOLDER_PATH) ; wait for newly selected source folder fath to fully load ; sometimes it takes longer than usually to load sub-folder and images due to system priorities or slow hdd. While 1 Local $sLoadedImageSourceFolder = ControlCommand($hWndChild, "", "ComboBox1", "GetCurrentSelection", '') If Not StringCompare($sLoadedImageSourceFolder, $_IMAGE_SOURCE_DIRECT_FOLDER, 0) Then ExitLoop WEnd Sleep(1000) ;<--- set more sleep time here if required if while loop above doesnt wait long enought for source folder to fully load ; click button - Add All ControlClick($hWndChild, '', 'Button8') ; check if images successfully added by count - [Input files:] Local $iCount = ControlGetText($hWndChild, '', 'Static11') If StringRegExp($iCount, '^\(\s(\d{1,})\s\)$') Then ;this button-----------------------------------------<<<<<<<<<< ; click button - Start Batch ControlClick($hWndChild, '', 'Button5') EndIf ; ------------------------------------------------ ; 3rd Window - Batch Conversion Done ; ------------------------------------------------ ; Wait for Batch to finish up Local $hWndSubChild = WinWait($_CLASS_TITLE_IRFANVIEW_BATCH_DONE) WinWaitActive($hWndSubChild) If WinActive($hWndSubChild) Then ; close 'Batch Conversion Done' window ; also closes 'Batch conversion' window along with it ControlClick($hWndSubChild, '', 'Button2') ; close IrfanView WinClose($hWnd) EndIf Edited September 27, 2020 by zeenmakr Link to comment Share on other sites More sharing options...
Shaheen288 Posted September 27, 2020 Author Share Posted September 27, 2020 Thank you very much for your time and effort. it's working fine. And yes "I Can't Thank You Enough" Link to comment Share on other sites More sharing options...
JockoDundee Posted September 27, 2020 Share Posted September 27, 2020 4 hours ago, Shaheen288 said: it's working fine. And yes "I Can't Thank You Enough" You could always write a program to ControlClick zeenmakr’s “like” button Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 27, 2020 Moderators Share Posted September 27, 2020 JockoDundee, Quote You could always write a program to ControlClick zeenmakr’s “like” button I know you are only joking, but I would take this opportunity to point you, and any other readers, to the Forum rules - particularly the "Interacting with this website" section. What you suggest has been done in the past and has not ended well for the miscreants. M23 TheDcoder 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dmob Posted September 27, 2020 Share Posted September 27, 2020 Irfanview has a very good command line interface, including batch conversion. I would suggest you utilise that rather than window automation. Shaheen288 1 Link to comment Share on other sites More sharing options...
zeenmakr Posted September 27, 2020 Share Posted September 27, 2020 7 hours ago, Shaheen288 said: Thank you very much for your time and effort. it's working fine. And yes "I Can't Thank You Enough" 2 hours ago, JockoDundee said: ControlClick zeenmakr’s “like” button 2 hours ago, Melba23 said: I know you are only joking, but controlclick the browser with the existing method would be interesting (: @Shaheen288 you might want to incorporate a while loop for this section as well, from this ; check if images successfully added by count - [Input files:] Local $iCount = ControlGetText($hWndChild, '', 'Static11') If StringRegExp($iCount, '^\(\s(\d{1,})\s\)$') Then ;this button-----------------------------------------<<<<<<<<<< ; click button - Start Batch ControlClick($hWndChild, '', 'Button5') EndIf to this ; check if images successfully added by count - [Input files:] ; again some instances take time to load all images to the list While 1 Local $iCount = ControlGetText($hWndChild, '', 'Static11') If StringRegExp($iCount, '^\(\s(\d{1,})\s\)$') Then ;this button-----------------------------------------<<<<<<<<<< ; click button - Start Batch ControlClick($hWndChild, '', 'Button5') ExitLoop EndIf Sleep(10) WEnd Link to comment Share on other sites More sharing options...
zeenmakr Posted September 27, 2020 Share Posted September 27, 2020 1 minute ago, dmob said: Irfanview has a very good command line interface, including batch conversion. I would suggest you utilise that rather than window automation. 100% Shaheen288 1 Link to comment Share on other sites More sharing options...
Shaheen288 Posted September 29, 2020 Author Share Posted September 29, 2020 On 9/28/2020 at 1:22 AM, dmob said: Irfanview has a very good command line interface, including batch conversion. I would suggest you utilise that rather than window automation. Thanks for your suggestion i will try it later. 😀 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now