Jump to content

Repeating Hotkey Function IUI won't work.


Recommended Posts

I'm trying to make a script that automates alot of copy pasting and filling in fields with text. I'm using alot of IUI but when I close the application window and open a new application window to enter another set of data the IUI Functions don't work, like they are being skipped. Anyone know what is causing this? Here is my code. Do I have to reset the vars or something? It works perfectly the first time running it but consecutive ones don't work on new windows.

#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
;~ #au3check -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <CUIAutomation2.au3>
#include <UIAWrappers.au3>
#include <MsgBoxConstants.au3>
#include <Excel.au3>

Global $Paused = False

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Terminate")
HotKeySet("{NUMPAD1}", "Attachment0")
HotKeySet("{NUMPAD2}", "Attachment1")
HotKeySet("{NUMPAD3}", "Attachment2")
HotKeySet("{NUMPAD4}", "Attachment3")
HotKeySet("{NUMPAD5}", "Attachment4")
HotKeySet("{NUMPAD6}", "Attachment5")
HotKeySet("{NUMPAD7}", "Attachment6")
HotKeySet("{NUMPAD8}", "Attachment7")
HotKeySet("{NUMPAD9}", "Attachment8")
HotKeySet("{NUMPAD0}", "Attachment9")
HotKeySet("{INSERT}", "CopyPaste")
AutoItSetOption("MustDeclareVars", 1)

While 1
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Paused"',0,0)
    WEnd
    ToolTip("")
 EndFunc

Func Terminate()
    Exit 0
EndFunc


Func Attachment9()


AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1")    ;View Activity

_UIA_setVar("row0attachment","Title:=(Value=(.*)# Row=0 Column=File Name);controltype:=UIA_TextControlTypeId");ControlType:=UIA_TextControlTypeId;classname:=Email")
local $orow0attachment=_UIA_getObject("title:=Value=(.*)# Row=0 Column=File Name;ControlType:=UIA_TextControlTypeId")

_UIA_setVar("CopyoP1","Title:=Context;controltype:=UIA_MenuControlTypeId;class:=#32768")    ;Context

_UIA_setVar("CopyfromGrid","Title:=Copy From Grid;controltype:=UIA_MenuItemControlTypeId;class:=") ;ControlType:=UIA_MenuItemControlTypeId;classname:=")
_UIA_setVar("EntireGrid","title:=Entire Grid;classname:=WindowsForms10.BUTTON.app.0.30495d1_r9_ad1")
_UIA_setVar("Copy.mainwindow","title:=Copy;classname:=WindowsForms10.BUTTON.app.0.30495d1_r9_ad1")
_UIA_setVar("Maximize","Title:=Maximize;controltype:=UIA_ButtonControlTypeId;class:=") ;ControlType:=UIA_ButtonControlTypeId;classname:=")

   local $AttachmentsAmount = 0

;If IsObj($orow0attachment) Then

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

   _UIA_action("Maximize","highlight")
   _UIA_action("Maximize","click")

   _UIA_Action("row0attachment","highlight")
   _UIA_action("row0attachment","rightclick")

   local $posCopyfromGrid = WinGetPos("View Activity")
   local $CopyfromGridx = 250
   local $CopyfromGridy = 550

    WinActivate ( "View Activity" , "" )
    ControlFocus ( "View Activitys", "", "" )
    WinWaitActive("View Activity")
    MouseClick("left", $posCopyfromGrid[0] + $CopyfromGridx, $posCopyfromGrid[1] + $CopyfromGridy)

;_UIA_Action("CopyfromGrid","highlight")
;_UIA_action("CopyfromGrid","click")
   _UIA_action("EntireGrid","highlight")
   _UIA_action("EntireGrid","click")

   local $poscopy = WinGetPos("Select Grid Copy Options")
   local $gridcopyx = 200
   local $gridcopy = 60

    WinActivate ( "Select Grid Copy Options" , "" )
    ControlFocus ( "Select Grid Copy Options", "", "" )
    WinWaitActive("Select Grid Copy Options")
    MouseClick("left", $poscopy[0] + $gridcopyx, $poscopy[1] + $gridcopy)

   Global $oExcel = _Excel_Open()
   WinActivate ("Autoit Excel Test" , "")
   Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Autoit Excel Test.xlsx" )

   local $posexcel = WinGetPos("Autoit Excel Test - Excel")
   local $startupx = 60
   local $startupy = 235

   WinActivate ( "Book1 - Excel" , "" )
   MouseClick("left", $posexcel[0] + $startupx, $posexcel[1] + $startupy)

   Sleep(500)
   Send ("^v")

local $Attachment0 = _Excel_RangeRead($oWorkbook, 1, "C2", 3)
local $Attachment0type = _Excel_RangeRead($oWorkbook, 1, "D2", 3)
local $Attachment0description = _Excel_RangeRead($oWorkbook, 1, "E2", 3)

local $Attachment1 = _Excel_RangeRead($oWorkbook, 1, "C3", 3)
local $Attachment1type = _Excel_RangeRead($oWorkbook, 1, "D3", 3)
local $Attachment1description = _Excel_RangeRead($oWorkbook, 1, "E3", 3)

local $Attachment2 = _Excel_RangeRead($oWorkbook, 1, "C4", 3)
local $Attachment2type = _Excel_RangeRead($oWorkbook, 1, "D4", 3)
local $Attachment2description = _Excel_RangeRead($oWorkbook, 1, "E4", 3)

local $Attachment3 = _Excel_RangeRead($oWorkbook, 1, "C5", 3)
local $Attachment3type = _Excel_RangeRead($oWorkbook, 1, "D5", 3)
local $Attachment3description = _Excel_RangeRead($oWorkbook, 1, "E5", 3)

local $Attachment4 = _Excel_RangeRead($oWorkbook, 1, "C6", 3)
local $Attachment4type = _Excel_RangeRead($oWorkbook, 1, "D6", 3)
local $Attachment4description = _Excel_RangeRead($oWorkbook, 1, "E6", 3)

local $Attachment5 = _Excel_RangeRead($oWorkbook, 1, "C7", 3)
local $Attachment5type = _Excel_RangeRead($oWorkbook, 1, "D7", 3)
local $Attachment5description = _Excel_RangeRead($oWorkbook, 1, "E7", 3)

local $Attachment6 = _Excel_RangeRead($oWorkbook, 1, "C8", 3)
local $Attachment6type = _Excel_RangeRead($oWorkbook, 1, "D8", 3)
local $Attachment6description = _Excel_RangeRead($oWorkbook, 1, "E8", 3)

local $Attachment7 = _Excel_RangeRead($oWorkbook, 1, "C9", 3)
local $Attachment7type = _Excel_RangeRead($oWorkbook, 1, "D9", 3)
local $Attachment7description = _Excel_RangeRead($oWorkbook, 1, "E9", 3)

local $Attachment8 = _Excel_RangeRead($oWorkbook, 1, "C10", 3)
local $Attachment8type = _Excel_RangeRead($oWorkbook, 1, "D10", 3)
local $Attachment8description = _Excel_RangeRead($oWorkbook, 1, "E10", 3)

local $Attachment9 = _Excel_RangeRead($oWorkbook, 1, "C11", 3)
local $Attachment9type = _Excel_RangeRead($oWorkbook, 1, "D11", 3)
local $Attachment9description = _Excel_RangeRead($oWorkbook, 1, "E11", 3)

;_Excel_Close ( $oExcel )

WinActivate ( "View Activity" , "" )
_UIA_action("row0attachment","highlight")
_UIA_action("row0attachment","click")

   local $AttachmentsAmount = 1

_UIA_setVar("row1attachment","Title:=(Value=(.*)# Row=1 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow1attachment=_UIA_getObject("title:=Value=(.*)# Row=1 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow1attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row1attachment","highlight")
   _UIA_action("row1attachment","click")

   local $AttachmentsAmount = 2

_UIA_setVar("row2attachment","Title:=(Value=(.*)# Row=2 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow2attachment=_UIA_getObject("title:=Value=(.*)# Row=2 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow2attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row2attachment","highlight")
   _UIA_action("row2attachment","click")

   local $AttachmentsAmount = 3

_UIA_setVar("row3attachment","Title:=(Value=(.*)# Row=3 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow3attachment=_UIA_getObject("title:=Value=(.*)# Row=3 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow3attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row3attachment","highlight")
   _UIA_action("row3attachment","click")

   local $AttachmentsAmount = 4

_UIA_setVar("row4attachment","Title:=(Value=(.*)# Row=4 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow4attachment=_UIA_getObject("title:=Value=(.*)# Row=4 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow4attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row4attachment","highlight")
   _UIA_action("row4attachment","click")

   local $AttachmentsAmount = 5

_UIA_setVar("row5attachment","Title:=(Value=(.*)# Row=5 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow5attachment=_UIA_getObject("title:=Value=(.*)# Row=5 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow5attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row5attachment","highlight")
   _UIA_action("row5attachment","click")

   local $AttachmentsAmount = 6

_UIA_setVar("row6attachment","Title:=(Value=(.*)# Row=6 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow6attachment=_UIA_getObject("title:=Value=(.*)# Row=6 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow6attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row6attachment","highlight")
   _UIA_action("row6attachment","click")

   local $AttachmentsAmount = 7

_UIA_setVar("row7attachment","Title:=(Value=(.*)# Row=7 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow7attachment=_UIA_getObject("title:=Value=(.*)# Row=7 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow7attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row7attachment","highlight")
   _UIA_action("row7attachment","click")

   local $AttachmentsAmount = 8

_UIA_setVar("row8attachment","Title:=(Value=(.*)# Row=8 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow8attachment=_UIA_getObject("title:=Value=(.*)# Row=8 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow8attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row8attachment","highlight")
   _UIA_action("row8attachment","click")

   local $AttachmentsAmount = 9

_UIA_setVar("row9attachment","Title:=(Value=(.*)# Row=9 Column=File Name);controltype:=UIA_TextControlTypeId")
local $orow9attachment=_UIA_getObject("title:=Value=(.*)# Row=9 Column=File Name;ControlType:=UIA_TextControlTypeId")

;If IsObj($orow9attachment) Then

   _UIA_setVar("View Activity","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity

   _UIA_Action("View Activity","highlight")
   _UIA_Action("View Activity","setfocus")

WinActivate ( "View Activity" , "" )

   _UIA_action("row9attachment","highlight")
   _UIA_action("row9attachment","click")

   local $AttachmentsAmount = 10

;Endif
;Endif
;Endif
;Endif
;Endif
;Endif
;Endif
;Endif
;Endif
;Endif

_UIA_setVar("NewActivity","Title:=Activity / Suspense;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1")
_UIA_action("NewActivity","highlight")
_UIA_Action("NewActivity","setfocus")

_UIA_setVar("OpenAttachmentWindow","Title:=Attachments;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("OpenAttachmentWindow","highlight")
_UIA_action("OpenAttachmentWindow","click")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")

;~    local $posaddress = WinGetPos("Attach File(s)")
;~    local $addressx = 425
;~    local $addressy = 40

;~    MouseClick("left", $posaddress[0] + $addressx, $posaddress[1] + $addressy)

;~    send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments")
;~    send("{ENTER}")

   send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment0)
   send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment1)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment2)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment3)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment4)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment5)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment6)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment7)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment8)
send("{ENTER}")

_UIA_setVar("AttachFile","Title:=Attach File;controltype:=UIA_HyperlinkControlTypeId;class:=") ;ControlType:=UIA_HyperlinkControlTypeId;classname:=")
_UIA_action("AttachFile","highlight")
_UIA_action("AttachFile","click")
send("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments\" & $Attachment9)
send("{ENTER}")

   local $poscopy = WinGetPos("Attachments")
   local $Description0x = 350
   local $Description0y = 210
   local $Description1x = 350
   local $Description1y = 235
   local $Description2x = 350
   local $Description2y = 260
   local $Description3x = 350
   local $Description3y = 285
   local $Description4x = 350
   local $Description4y = 310
   local $Description5x = 350
   local $Description5y = 335
   local $Description6x = 350
   local $Description6y = 360
   local $Description7x = 350
   local $Description7y = 385
   local $Description8x = 350
   local $Description8y = 310
   local $Description9x = 350
   local $Description9y = 335

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description0x, $poscopy[1] + $Description0y)
    send($Attachment0description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description1x, $poscopy[1] + $Description1y)
    send($Attachment1description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description2x, $poscopy[1] + $Description2y)
    send($Attachment2description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description3x, $poscopy[1] + $Description3y)
    send($Attachment3description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description4x, $poscopy[1] + $Description4y)
    send($Attachment4description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description5x, $poscopy[1] + $Description5y)
    send($Attachment5description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description6x, $poscopy[1] + $Description06y)
    send($Attachment6description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description7x, $poscopy[1] + $Description7y)
    send($Attachment7description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description8x, $poscopy[1] + $Description8y)
    send($Attachment8description)

    WinActivate ( "Attachments" , "" )
    ControlFocus ( "Attachments", "", "" )
    WinWaitActive("Attachments")
    MouseClick("left", $poscopy[0] + $Description9x, $poscopy[1] + $Description9y)
    send($Attachment9description)

Cleanup()

EndFunc





Func Cleanup()

WinKill("[CLASS:AcrobatSDIWindow]","")
WinKill("[CLASS:Notepad++]","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")
WinKill("Photos","")

DirRemove("C:\Users\%USERNAME%\AppData\Local\Temp\AMS\Attachments", 1)

EndFunc







Func CopyPaste()


_UIA_setVar("ViewActivityInsert","Title:=View Activity;controltype:=UIA_WindowControlTypeId")
_UIA_setVar("ViewActivityInsert2","Title:=;controltype:=UIA_TitleBarControlTypeId;class:=")
_UIA_setVar("Maximize","Title:=Maximize;controltype:=UIA_ButtonControlTypeId;class:=") ;ControlType:=UIA_ButtonControlTypeId")

_UIA_Action("ViewActivityInsert","highlight")
_UIA_Action("ViewActivityInsert","setfocus")

_UIA_action("Maximize","highlight")
_UIA_action("Maximize","click")

    Local $descriptionx = 350
    Local $descriptiony = 335
    Local $saveddate1x = 475
    Local $saveddate1y = 207
    Local $saveddate2x = 545
    Local $saveddate2y = 207
    Local $tran1x =130
    Local $tran1y =185
    Local $tran2x =330
    Local $tran2y =185
    Local $claim1x =130
    Local $claim1y =255
    Local $claim2x =330
    Local $claim2y =255
    Local $action1x =475
    Local $action1y =120
    Local $action2x =675
    Local $action2y =120
    Local $date1x = 475
    Local $date1y = 185
    Local $date2x = 545
    Local $date2y = 185
    Local $time1x = 625
    Local $time1y = 185
    Local $time2x = 675
    Local $time2y = 185
    Local $policy1x = 130
    Local $policy1y = 115
    Local $policy2x = 330
    Local $policy2y = 115
    Local $effectivedate1x =130
    Local $effectivedate1y =160
    Local $effectivedate2x =330
    Local $effectivedate2y =160
    Local $maximizex =720
    Local $maximizey =10

;~     Local $pos = WinGetPos("View Activity")

;~     WinActivate ( "View Activity" , "" )
;~     ControlFocus ( "View Activity", "", "" )
;~  WinWaitActive("View Activity")
;~  Sleep(100)
;~  MouseClick("left", $pos[0] + $maximizex, $pos[1] + $maximizey)
;~  Sleep(100)

    Local $pos = WinGetPos("View Activity")

    WinActivate ( "View Activity" , "" )
    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    Sleep(100)
    MouseClick("left", $pos[0] + $descriptionx, $pos[1] + $descriptiony)
    Send ("^a")
    Send ("^c")
    Sleep(100)
    Local $tDescription = ClipGet()

    ;ControlFocus ( "View Activity", "", "" )
    ;WinWaitActive("View Activity")
    ;MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $saveddate1x, $pos[1] + $saveddate1y, $pos[0] + $saveddate2x, $pos[1] + $saveddate2y )
    ;Local $tsaveddate = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $tran1x, $pos[1] + $tran1y, $pos[0] + $tran2x, $pos[1] + $tran2y )
    Send ("^a")
    Send ("^c")
    Local $ttran = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $claim1x, $pos[1] + $claim1y, $pos[0] + $claim2x, $pos[1] + $claim2y )
    Send ("^a")
    Send ("^c")
    Local $tclaim = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $action1x, $pos[1] + $action1y, $pos[0] + $action2x, $pos[1] + $action2y )
    Send ("^a")
    Send ("^c")
    Local $taction = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $date1x, $pos[1] + $date1y, $pos[0] + $date2x, $pos[1] + $date2y )
    Send ("^a")
    Send ("^c")
    Local $tdate = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $time1x, $pos[1] + $time1y, $pos[0] + $time2x, $pos[1] + $time2y )
    Send ("^a")
    Send ("^c")
    Local $ttime = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $policy1x, $pos[1] + $policy1y, $pos[0] + $policy2x, $pos[1] + $policy2y )
    Send ("^a")
    Send ("^c")
    Local $tpolicy = ClipGet()

    ControlFocus ( "View Activity", "", "" )
    WinWaitActive("View Activity")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $pos[0] + $effectivedate1x, $pos[1] + $effectivedate1y, $pos[0] + $effectivedate2x, $pos[1] + $effectivedate2y )
    Send ("^a")
    Send ("^c")
    Local $teffectivedate = ClipGet()

    Local $FIADescriptionx = 350
    Local $FIADescriptiony = 325

    Local $FIAactionx = 355
    Local $FIAactiony = 220

    Local $FIADate1x = 525
    Local $FIADate1y = 225
    Local $FIADate2x = 600
    Local $FIADate2y = 225

    Local $FIAtime1x = 685
    Local $FIAtime1y = 225
    Local $FIAtime2x = 750
    Local $FIAtime2y = 225

    Local $FIApolicyx = 600
    Local $FIApolicyy = 115

    Local $FIAeffectivedatex = 600
    Local $FIAeffectivedatey = 140

    WinActivate ( "Activity / Suspense", "" )
    ControlFocus ( "Activity / Suspense", "", "" )
    WinWaitActive("Activity / Suspense")

    Local $FIApos = WinGetPos("Activity / Suspense")

    Sleep(100)
    MouseClick("left", $FIApos[0] + $FIADescriptionx, $FIApos[1] + $FIADescriptiony)
    MouseClick("left", $FIApos[0] + $FIADescriptionx, $FIApos[1] + $FIADescriptiony)
    ClipPut($tDescription)
    Sleep(100)
    Send ("^a")
    Send ("^v")

    ControlFocus ( "Activity / Suspense", "", "" )
    WinWaitActive("Activity / Suspense")
    MouseClick("left", $FIApos[0] + $FIAactionx, $FIApos[1] + $FIAactiony)
    MouseClick("left", $FIApos[0] + $FIAactionx, $FIApos[1] + $FIAactiony)
    If $taction = "Mail Out" then
        Send ("correspondence")
    ElseIF $taction = "Agency Bill Collection Follow up" then
        Send ("accounting")
    ElseIF $taction = "Appointment" then
        Send ("Appointment")
    ElseIF $taction = "Audit Report Form" then
        Send ("Audit")
    ElseIF $taction = "Billing" then
        Send ("Accounting")
    ElseIF $taction = "Certificate" then
        Send ("Certificate")
    ElseIF $taction = "Claim" then
        Send ("Claim")
    ElseIF $taction = "Declined by Company" then
        Send ("Declined by Company")
    ElseIF $taction = "Declined by Customer" then
        Send ("Declined by Customer")
    ElseIF $taction = "Direct Bill Copy" then
        Send ("correspondence")
    ElseIF $taction = "Fax" then
        Send ("correspondence")
    ElseIF $taction = "Follow-up" then
        Send ("Follow-up")
    ElseIF $taction = "Fraud Form" then
        Send ("correspondence")
    ElseIF $taction = "Insd provided docs/UW" then
        Send ("customer information")
    ElseIF $taction = "Lease Agreement" then
        Send ("customer information")
;   ElseIF $taction = "Loss Runs" then
;       Send ("Loss run")
    ElseIF $taction = "Mail Out" then
        Send ("correspondence")
    ElseIF $taction = "Non-renewal Notified Agency" then
        Send ("Non-renewal Notified Agency")
    ElseIF $taction = "Policy Change Request" then
        Send ("Policy Change Request")
    ElseIF $taction = "Policy PDF" then
        Send ("Policy processed")
    ElseIF $taction = "Premium Audit" then
        Send ("audit processed")
    ElseIF $taction = "Quote" then
        Send ("Quote Received")
    ElseIF $taction = "Renewal" then
        Send ("Renewal")
    ElseIF $taction = "Telephone In" then
        Send ("Telephone")
    ElseIF $taction = "Telephone Out" then
        Send ("Telephone")
    ElseIF $taction = "Terrorism" then
        Send ("correspondence")
    ElseIF $taction = "Auto ID Card" then
        Send ("Auto ID Card")
    ElseIF $taction = "Binder" then
        Send ("Binder")
    ElseIF $taction = "Application" then
        Send ("Application")
    ElseIF $taction = "Claim Deleted" then
        Send ("claim payment/claim closed")
    ElseIF $taction = "E-Mail Out" then
        Send ("correspondence")
    ElseIF $taction = "E-Mail In" then
        Send ("correspondence")
    Endif

    ControlFocus ( "Activity / Suspense", "", "" )
    WinWaitActive("Activity / Suspense")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $FIApos[0] + $FIADate1x, $FIApos[1] + $FIADate1y, $FIApos[0] + $FIADate2x, $FIApos[1] + $FIADate2y )
    ClipPut($tdate)
    Send ("^v")

    ControlFocus ( "Activity / Suspense", "", "" )
    WinWaitActive("Activity / Suspense")
    MouseClickDrag ( $MOUSE_CLICK_LEFT, $FIApos[0] + $FIAtime1x, $FIApos[1] + $FIAtime1y, $FIApos[0] + $FIAtime2x, $FIApos[1] + $FIAtime2y )
    ClipPut($ttime)
    Send ("^v")

    ControlFocus ( "Activity / Suspense", "", "" )
    WinWaitActive("Activity / Suspense")
    MouseClick("left", $FIApos[0] + $FIApolicyx, $FIApos[1] + $FIApolicyy)
    MouseClick("left", $FIApos[0] + $FIApolicyx, $FIApos[1] + $FIApolicyy)
    Send ($tpolicy)

    ControlFocus ( "Activity / Suspense", "", "" )
    WinWaitActive("Activity / Suspense")
    MouseClick("left", $FIApos[0] + $FIAeffectivedatex, $FIApos[1] + $FIAeffectivedatey)
    MouseClick("left", $FIApos[0] + $FIAeffectivedatex, $FIApos[1] + $FIAeffectivedatey)
    Send ($teffectivedate)

EndFunc

 

Edited by milkmoron
Link to comment
Share on other sites

Its actually a little more complicated

Within udf i keep runtimeinformation cached in same 2d array and first column has key

rti.yourvarname

https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDelete.htm

You have to use that function on $uia_vars array after finding index with

https://www.autoitscript.com/autoit3/docs/libfunctions/_ArraySearch.htm

Will put on todo list to handle this in easier way.

You could try this do not forget rti. As prefix including dot

_uia_setvar("rti.yourvarname","")

 

 

 

 

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

×
×
  • Create New...