#NoEnv :#Warn SendMode Input SetWorkingDir %A_ScriptDir% #SingleInstance off SetTitleMatchMode, 1 WinWait, Microsoft Excel - Resposta Penhoras, IfWinNotActive, Microsoft Excel - Resposta Penhoras, , WinActivate, Microsoft Excel - Resposta Penhoras, WinWaitActive, Microsoft Excel - Resposta Penhoras, StatusBarWait, Pronto Xl := ComObjActive("Excel.Application") coluna:= "A" linha := Xl.Range("B1").Value StringLeft, linha, linha, (StrLen(linha)-7) celula := coluna . linha entrada:= Xl.Range(celula).Value StringLeft, entrada, entrada, (StrLen(entrada)-7) Sleep, 100 pwb := ComObjCreate( "InternetExplorer.Application" ) ;Creates the ComObj pwb.Navigate("http://suflnprd/WorkplacePlusSSO/HomePage.jsp?mode=reset") pwb.Visible := True ; Shows the IE app While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 WinWait, Área de Trabalho WinMaximize, Área de Trabalho pwb.document.all.tags("A")[11].Click() While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 WinWait, Área de Trabalho pwb.document.all.tags("SPAN")[8].Click() While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 WinWait, Área de Trabalho pwb.document.all.tags("TABLE")[12].visible := true pwb.document.all.tags("SELECT")[6].value := 8 Sleep 10 pwb.document.all.tags("INPUT")[6].value := entrada Sleep 10 pwb.document.all.tags("BUTTON")[2].Click() Sleep 10 While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 WinWait, Área de Trabalho Escolha := pwb.document.all.tags("A")[41].InnerText Sleep 10 If Escolha = Tratamento do documento Goto TratamentoDocumento If Escolha = Validação e distribuição do trabalho Goto ValidacaoTrabalho ExitApp ;######################################################################################################################### ProcedimentosFinais: WinWait, Microsoft Excel - Resposta Penhoras, IfWinNotActive, Microsoft Excel - Resposta Penhoras, , WinActivate, Microsoft Excel - Resposta Penhoras, WinWaitActive, Microsoft Excel - Resposta Penhoras, StatusBarWait, Pronto Xl.Range("B1").Value ++ xl.document.getElementByName("CommanButton")[0].cLICK() Sleep, 200 Loop, { ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, G:\COMUM\Resposta Penhoras\ProcessarGPS.bmp if ErrorLevel = 0 break } Sleep, 100 OutputVarX +=10 OutputVarY +=15 Sleep, 200 MouseClick, left, OutputVarX, OutputVarY Sleep, 500 ExitApp ;################################################################################################################ TratamentoDocumento: pwb.document.all.tags("A")[41].Click() Sleep 100 While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 WinWait, Workplace: Processador de passos, IfWinNotActive, Workplace: Processador de passos, , WinActivate, Workplace: Processador de passos, WinWaitActive, Workplace: Processador de passos, WinMaximize, Workplace: Processador de passos Sleep 100 While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 ; Até este passo, funciona perfeito. Apenas não consigo aceder os elementos aqui elencados... pwb.document.getElementsByTagName("SELECT").item[3].value := 5 Sleep 100 pwb.document.getElementsByTagName("TEXTAREA")[0].value := "Resposta recolhida no SIPE" MsgBox % "Valeu?" ;Apenas para parar o script... WinKill, Área de Trabalho WinKill, Workplace: Processador de passos ExitApp ;########################################################################################################### ValidacaoTrabalho: pwb.document.all.tags("A")[41].Click() Sleep 100 While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 WinWait, Workplace: Processador de passos, IfWinNotActive, Workplace: Processador de passos, , WinActivate, Workplace: Processador de passos, WinWaitActive, Workplace: Processador de passos, WinMaximize, Workplace: Processador de passos Sleep 3000 MouseClick, left, 1080,360 While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 100 pwb.document.getElementsByTagName("A")[12].Click() Sleep 100 While ( Pwb.Busy || Pwb.ReadyState != 4 ) ; Waits for the webpage to finish loading Sleep 10 MsgBox % "Onde foi parar?" WinKill, Área de Trabalho WinKill, Workplace: Processador de passos ExitApp ;############################################################################################################ WBGet(WinTitle="ahk_class IEFrame", Svr#=1) { ;// based on ComObjQuery docs static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT") , IID := "{0002DF05-0000-0000-C000-000000000046}" ;// IID_IWebBrowserApp ;// , IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ;// IID_IHTMLWindow2 SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle% if (ErrorLevel != "FAIL") { lResult:=ErrorLevel, VarSetCapacity(GUID,16,0) if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 { DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc) return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc) } } } IEGet(name="") { IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame ;// Get active window if no parameter Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft)? ?Internet Explorer$") for pwb in ComObjCreate("Shell.Application").Windows() if pwb.LocationName=Name and InStr(pwb.FullName, "iexplore.exe") return pwb }