ComradVlad Posted May 25, 2018 Author Share Posted May 25, 2018 (edited) expandcollapse popup#include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include <file.au3> #include <InetConstants.au3> #include <WinAPIFiles.au3> #include <Date.au3> #include <DateTimeConstants.au3> ;Global variable;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;REPLACEDROOTURL//PDFTK//PDFViewer.php?filename=db1208020249merged192149172328.pdf ;pdf url REPLACEDROOTURL//PDFTK//PDFViewer.php?filename=db1208020249merged1266445012.pdf global $main=0 global $db = ?????; DOnt forget to set default control db value global $inipath = @scriptdir&"\settings.ini" global $oURL = "REPLACEDROOTURL/application/vorder_add.php?key=" global $pURL = "REPLACEDROOTURL/application/poc_add.php?key=" global $edit = 0 global $cOrder = 0 ;54220 ;;;;;;current order number global $dirFile = @scriptdir&'\ordertasklist'&stringreplace(_nowdate(),"/","")&'.csv' global $gdtype = 1 ;;;1 for order 2 for poc global $end = 0 global $oIE = 0 global $username = 0 global $password = 0 ;_IEErrorHandlerRegister() ;interface init;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $main=guicreate("Order Tool",210,185,0,0,-1,$WS_EX_TOPMOST) ;WinSetTrans($main, "", 170) ;$main=guicreate("Order Buddy",195,70,@desktopwidth-220,20,-1,$WS_EX_TOPMOST) guisetstate(@SW_SHOW) Opt("GUIOnEventMode", 1) guisetonevent($GUI_EVENT_CLOSE,"quit") global $uField = guictrlcreateinput('Username',5,5,200,20) global $pField = guictrlcreateinput('Password',5,30,200,20,0x0020) global $dbField = guictrlcreateinput('??????',5,55,200,20) global $tRadio1 = guictrlcreateradio('Orders',5,80) GUICtrlSetState($tRadio1, $GUI_CHECKED) global $tRadio2 = guictrlcreateradio('Plans of Care',80,80) global $max = guictrlcreateinput('Start (max)',5,105,80,20) global $min = guictrlcreateinput('End (min)',125,105,80,20) guictrlcreatelabel("-->",100,105) global $gButton = guictrlcreatebutton('Start',50,130,100,30) global $sLabel =guictrlcreatelabel("Status:Idle",5,165,200,20) guictrlsetonevent($gButton,"start") while 1 sleep(100) WEnd func start() $oIE = _IECreate("REPLACEDROOTURL") $db = guictrlread($dbField) $username = guictrlread($uField) $password = guictrlread($pField) $cOrder = guictrlread($max) $end = guictrlread($min) if guictrlread($tRadio1) = 1 Then $gdtype = 1 Else $gdtype = 2 endif _login() if $gdtype = 2 Then $dirFile = @scriptdir&'\poctasklist'&stringreplace(_nowdate(),"/","")&'.csv' filewriteline($dirFile,'Doc ID, Patient MR, POC Number, Task') Else $dirFile = @scriptdir&'\ordertasklist'&stringreplace(_nowdate(),"/","")&'.csv' filewriteline($dirFile,'Doc ID,Patient MR, Order Number, Task') endif While $cOrder > $end - 1 guictrlsetdata($sLabel,"Status: working on order " & $cOrder) _goToOrder($cOrder,$gdtype) _decide ($cOrder,$gdtype) $cOrder = $cOrder - 1 wend guictrlsetdata($sLabel,"Idle") _IEQuit($oIE) endfunc func _download ($location,$pName,$onumber) _IENAvigate($Oie,$location) sleep(100) ;_IEPropertyGet ( $oIE, "hwnd" ) winactivate(_IEPropertyGet ( $oIE, "hwnd" )) ;sleep(300) send("^S") sleep(300) send(@scriptdir&"\"&$pname&"\"&$onumber) endfunc ;functions;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;???? login function func _login () Local $oForm = _IEFormGetObjByName($oIE, "loginForm") Local $oText = _IEFormElementGetObjByName($oForm, "USERNAME") _IEFormElementSetValue($oText, $username) $oText = _IEFormElementGetObjByName($oForm, "PASSWORD") ;_IEFormElementSetValue($oText, iniread($inipath,"Login","p",1)) _IEFormElementSetValue($oText, $password) local $element = _IEFormElementGetObjByName($oForm, "sign-in") _IEAction($element,"click") sleep(1000) _ieloadwait($oIE) endfunc func quit () ; local $buddyLoc = WinGetPos($main) ;iniwrite($path,"settings","buddyx",$buddyLoc[0]) ; iniwrite($path,"settings","buddyy",$buddyLoc[1]) _IEQuit($oIE) Exit endfunc ;function that navigates to new order func _goToOrder ($idIn, $dtype) local $tURL = $oURL if $dtype = 2 Then $tURL = $pURL endif _ienavigate($oIE,$tURL&$idIn) if @error Then _goToOrder($idIn, $dtype) EndIf endfunc ;logic function decides what to do with each order Func _decide ($dOrder,$dtype) Local $oForm = _IEFormGetObjByName($oIE, "add") local $type = _IEFormElementGetObjByName($oForm,"table_xyz") local $status = _IEFormElementGetObjByName($oForm,"status") if $dtype = 1 then local $effective = _IEFormElementGetObjByName($oForm,"dateeff") else local $effective = _IEFormElementGetObjByName($oForm,"datevosoc") endif if $dtype = 2 then local $docid = _IEFormElementGetObjByName($oForm,"pupin") else sleep(200) local $docid=_IEFormElementGetCollection($oForm,117) if $docid.value = "" Then $docid=_IEFormElementGetCollection($oForm,118) endif endif local $ptid = _IEFormElementGetObjByName($oForm,"ptid") local $ptid2 = _IEFormElementGetObjByName($oForm,"ptid_xyz") local $sent = _IEFormElementGetObjByName($oForm,"datesent") local $sent2 = _IEFormElementGetObjByName($oForm,"datesent2") local $sent3 = _IEFormElementGetObjByName($oForm,"datesent3") local $sent4 = _IEFormElementGetObjByName($oForm,"datesent4") ;;;;pt attribute value testing ;;;;;;; if $status.value = "READY TO SEND" Then ;msgbox(0,"Decision","Order is ready to send") filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',was sent') _eFax($dtype) _sendDate ($dOrder, $dtype,1) elseif $status.value = "UNCONFIRMED" Then ;filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',Is not ready to be sent') elseif $status.value = "CONFIRMED" Then ;filewriteline($dirFile,'Order ' & $dOrder &' already confirmed') elseif $status.value = "VOID" Then ;filewriteline($dirFile,'Order ' & $dOrder &' Order Void') elseif _dateD ($effective.value,30) = 1 then if _oCheck ($dOrder, $ptid.value) = 0 Then ;check if order is in e records ;msgbox(0,"Decision","effective date over 30 days and order not in e records") filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',over 30 days old not in erecords needs checking') Else ;if order present in e records ;msgbox(0,"Decision","effective date over 30 days and order found in e records") _sendDate ($dOrder, $dtype,0) filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',was found in e records and confirmed') endif ;if effective date is over 30 days old elseif $sent.value <> "" and $sent2.value = "" and _dateD ($sent.value,6) = 1 Then ;msgbox(0,"Decision","Order has been sent once before and needs to be sent again") filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&' ,was resent') _eFax($dtype) _sendDate ($dOrder, $dtype,2) ;send if only one sent date which is over 7 days elseif $sent2.value <> "" and $sent3.value = "" and _dateD ($sent2.value,6) = 1 Then ;if sent and resent2 date arent blank and resent2 date is more than 7 days if _oCheck ($dOrder, $ptid.value) = 0 Then ;check if order is in e records ;msgbox(0,"Decision","Order has been sent twice before and is not in e records") filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',not in e records and was NOT resent needs follow up call') ;_eFax($dtype) _sendDate ($dOrder, $dtype,3) Else ;if order present in e records ;msgbox(0,"Decision","Order has been sent twice before and is found in e records") _sendDate ($dOrder, $dtype,0) filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',was found in e records and confirmed') endif elseif $sent3.value <> "" and $sent4.value = "" Then ;3rd rsend not blank and over 30 days if _oCheck ($dOrder, $ptid.value) = 0 Then ;check if order is in e records ;msgbox(0,"Decision","Order has been sent thrice before and is not in e records") filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',has been sent 3 times needs checking') Else ;if order present in e records ;msgbox(0,"Decision","Order has been sent thrice before and is found in e records") _sendDate ($dOrder, $dtype,0) filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',was found in e records and confirmed') endif elseif $sent4.value <> "" then ;4rd rsend not blank and over 30 days if _oCheck ($dOrder, $ptid.value) = 0 Then ;check if order is in e records ;msgbox(0,"Decision","Order has been sent four times and is not in e records") filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',has been sent 4 times needs checking') Else ;if order present in e records ;msgbox(0,"Decision","Order has been sent four times and is found in e records") _sendDate ($dOrder, $dtype,0) filewriteline($dirFile,$docid.value&','&$ptid.value&','&$dOrder&',was found in e records and confirmed') endif else ;msgbox(0,"Decision","no action taken") ;filewriteline($dirFile,'Order ' & $dOrder &' doesnt require any action') endif EndFunc ;send e fax through ????? interface Func _eFax($dType2) Local $oForm = _IEFormGetObjByName($oIE, "add") local $coll = _ieformelementgetcollection($oForm,1) ;msgbox(0,"test",$coll.value) _IEAction($coll,"click") local $loop=1 local $handle while $loop = 1 if winexists('PDF CREATOR - Internet Explorer') Then $handle=wingethandle('PDF CREATOR - Internet Explorer') $loop=0 EndIf sleep(100) wend $faxWindow=_IEattach($handle,"hwnd") sleep(100) _IELoadwait($faxWindow) if $dType2 = 1 then _IENavigate($faxWindow,'REPLACEDROOTURL//PDFTK//hts_app/?faxto=&faxnum=#/faxingSend?file=db' & $db &_pdfName($faxWindow)&'&key='&$cOrder&'&type=vorder') else _IENavigate($faxWindow,'REPLACEDROOTURL//PDFTK//hts_app/?faxto=&faxnum=#/faxingSend?file=db' & $db &_pdfName($faxWindow)&'&key='&$cOrder&'&type=poc') endif _IELoadwait($faxWindow) while $loop = 0 if winexists('FAXING SEND | ????? - Internet Explorer') Then $handle=wingethandle('FAXING SEND | ??????? - Internet Explorer') $faxWindow=_IEattach($handle,"hwnd") $loop=1 sleep(500) EndIf sleep(100) wend $oFP = _IEFormGetCollection($faxWindow, 0) sleep(100) local $sDoctor = _ieformelementgetcollection($oFP,2) if $sDoctor.value = 'REPLACED DOC NAME' then;;Exclusion List filewriteline($dirFile,'Disregard the previous line, doctor is on exclusion list. Fax was not sent but follow up if needed') _IEQuit($faxWindow) return 0 endif local $sAccount = _ieformelementgetcollection($oFP,0) _IEFormElementOptionSelect($sAccount, 1, 1, "byIndex") _IEAction($sAccount,"focus") sleep(100) send("{down}") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;fax account select sleep(100) ;local $sFax = _ieformelementgetcollection($oFP,3) ;_IEAction($sFax,"focus") ;send("phone number") local $sButton = _ieformelementgetcollection($oFP,6) sleep(100) _IEAction($sButton,"click") sleep(5000) _IEQuit($faxWindow) EndFunc ;;; pulls pdf file name from ht window containing pdf Func _pdfName ($windowIN) local $HTML = _IEBodyReadHTML($windowIN) local $start = stringinstr($HTML,"merged") local $end = stringinstr($HTML,".pdf&fax") local $file = stringmid($HTML,$start,$end + 4 - $start) return $file endfunc ;;;;;function that returns 1 if current date is x more daya than $difIN func _dateD ($dIN,$difIN) local $fDate = stringmid($dIN,7,4)&'/'&stringmid($dIN,1,2)&'/'&stringmid($dIN,4,2) local $pDate = stringSplit(_nowDate(),'/') local $nDate = $pDate[3] & "/" & $pDate[1] & "/" & $pDate[2] if $difIN < _datediff("D",$fDate,$nDate) Then return 1 else return 0 endif endfunc ;;;;;function to check if order is in erecords returns loc if present returns 0 if not func _oCheck ($oIN, $ptIn) local $checkWindow = _iecreate("REPLACEDROOTURL/application/patient_add.php?key="&$ptIn & "#e_recordsTab") local $oHTML = _iebodyreadhtml($checkWindow) ;msgbox(0, "testing "&$oIn,"ORDER "&$oIN) _ieQuit($checkWindow) return stringinstr($oHTML,"ORDER "&$oIN) endfunc func _sendDate ($idIN, $dtype,$sField) ;order number in, poc or order, field to mark _goToOrder($idIn, $dtype) Local $oForm = _IEFormGetObjByName($oIE, "add") if $sfield = 1 Then local $sent = _IEFormElementGetObjByName($oForm,"datesent") _IEformelementsetvalue($sent,_nowdate()) local $option = _IEFormElementGetObjByName($oForm,"status") if $dtype = 1 then _IEFormElementOptionselect($option,4,1,"byIndex") Else _IEFormElementOptionselect($option,2,1,"byIndex") endif ElseIf $sfield = 2 Then local $sent = _IEFormElementGetObjByName($oForm,"datesent2") _IEformelementsetvalue($sent,_nowdate()) ElseIf $sfield = 3 Then local $sent = _IEFormElementGetObjByName($oForm,"datesent3") _IEformelementsetvalue($sent,_nowdate()) ElseIf $sfield = 4 Then local $sent = _IEFormElementGetObjByName($oForm,"datesent4") _IEformelementsetvalue($sent,_nowdate()) ElseIf $sfield = 0 Then ;only sets status to confirmed local $option = _IEFormElementGetObjByName($oForm,"status") if $dtype = 1 then _IEFormElementOptionselect($option,6,1,"byIndex") Else _IEFormElementOptionselect($option,4,1,"byIndex") endif endif local $submit = _IEFormElementGetObjByName($oForm,"submit_xyz") sleep(1000) _IEAction($submit,"click") sleep(1000) _validate() _ieloadwait($oIE) endfunc func _validate() local $vWidnow sleep(1000) if winexists('VALIDATING - Internet Explorer') Then $handle=wingethandle('VALIDATING - Internet Explorer') $vWindow=_IEattach($handle,"hwnd") ;;;;; local $oInputs = _IETagNameGetCollection($vWindow, "input") For $oInput In $oInputs if stringinstr($oInput.value , "SUBMIT" ) <> 0 Then $submitbtn = $oInput endif Next _IEAction ($submitbtn, "click") sleep(2000) ;;;;; EndIf endfunc  Edited May 25, 2018 by ComradVlad Link to comment Share on other sites More sharing options...
ComradVlad Posted May 25, 2018 Author Share Posted May 25, 2018 22 hours ago, junkew said: What happens when you restart the computers? Could itbe you have dozens of ie processes running. Maybe specific addins are loaded. Can you manually browse to the url you want. Restarting computers doesn't work, once the program starts failing it doesn't stop and always fails as soon as it hits the _goToOrder function. I can Manually go to the url just fine. Â Posted the code with identifying info removed up top. Link to comment Share on other sites More sharing options...
Juvigy Posted May 28, 2018 Share Posted May 28, 2018 Do you have #requireadmin ? If not - put it and test if it works. Does the failing PC/Logged users have admin rights? Link to comment Share on other sites More sharing options...
ComradVlad Posted May 31, 2018 Author Share Posted May 31, 2018 On 5/28/2018 at 1:00 AM, Juvigy said: Do you have #requireadmin ? If not - put it and test if it works. Does the failing PC/Logged users have admin rights? All users are admins, I tried #requireadmin and the program exits with 0 exit code instead of throwing ie navigate error. Link to comment Share on other sites More sharing options...
Juvigy Posted June 1, 2018 Share Posted June 1, 2018 You mean it exits and does nothing? What if you right click it and choose runasadministrator? Link to comment Share on other sites More sharing options...
mLipok Posted June 1, 2018 Share Posted June 1, 2018 On 24.05.2018 at 6:26 PM, ComradVlad said: ill give it a try Did you try Au3.3.12.0 ?  Signature beginning:* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *  My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"  , be   and    \\//_. Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
ComradVlad Posted June 8, 2018 Author Share Posted June 8, 2018 On 6/1/2018 at 2:08 AM, Juvigy said: You mean it exits and does nothing? What if you right click it and choose runasadministrator? same thing Link to comment Share on other sites More sharing options...
ComradVlad Posted June 8, 2018 Author Share Posted June 8, 2018 On 6/1/2018 at 2:18 AM, mLipok said: Did you try Au3.3.12.0 ? Â yup same deal: Â "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (272) : ==> The requested action with this object has failed.: $oObject.navigate($sUrl) $oObject^ ERROR Link to comment Share on other sites More sharing options...
Juvigy Posted June 11, 2018 Share Posted June 11, 2018 Put an error handler to see what exactly is going on. Instead of using the UDF, try the navigate method directly: For example like this: $oIE = _IECreate("abv.bg") _IELoadWait($oIE) $oIE2 = $oIE.navigate2("dir.bg")  Link to comment Share on other sites More sharing options...
ComradVlad Posted April 24, 2019 Author Share Posted April 24, 2019 Resurrecting this old thread in case someone else is looking for the answer. The issue was that windows defender blocked a portion of the program, specifically the IE navigate function. It only did this on some computers. Not sure why. Disabling protection for IExplore gets rid of this issue. There was nothing wrong with the code. 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