Jump to content

i am new to autoit and i need help with (control click)


Shaheen288
 Share

Recommended Posts

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

; 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.

Screenshot 2020-09-27 052756.png

Link to comment
Share on other sites

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"

; 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 by zeenmakr
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...