Jump to content

JohnWIlling

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

JohnWIlling's Achievements

Seeker

Seeker (1/7)

5

Reputation

  1. We are running on a VIrtual Machine via Remote Desktop. We are having a situation where the loading of the chromedriver.exe is taking longer on the VM than on a physical machine. It is causing the first call to WD_Post in _WD_CreateSession to fail. To workaround the Issue, I used a simplified version of (_WinAPI_GetTcpTable) UDF to Loop waiting for the driver port to be in the listening state. At that point, I know that the Post will work: Func _WaitForPort($ListenPort) Do Local $tMIB_TCPTABLE = DllStructCreate("dword[6]") Local $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", 0, "BOOL", True) Local $dwSize = $aRet[2] $tMIB_TCPTABLE = DllStructCreate("DWORD[" & $dwSize / 4 & "]") $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", $dwSize, "BOOL", True) If $aRet[0] <> 0 Then Return SetError(1) Local $iNumEntries = DllStructGetData($tMIB_TCPTABLE, 1, 1) Local $aRes[$iNumEntries][6] For $i = 0 To $iNumEntries - 1 Local $Type = DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 0) $aRet = DllCall("ws2_32.dll", "ushort", "ntohs", "uint", DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 2)) ; local port Local $Port = $aRet[0] ConsoleWrite("Checking Row:" & $i & " State:<" & $Type & "> Port:<" & $Port & ">" & @CRLF) ; Type 2 is LISTENING If $Type = 2 And $Port = $ListenPort Then Return 1; EndIF Next Sleep(500); Until 0; Return 0; EndFunc ;==>_WaitForPort
  2. I found a simple solution to reconnect to an existing chromedriver. Once the driver is loaded, the "session id" is returned. Subsequent communication is via TCP to the defined port while passing in the session id. Global $sSessionFileName = "Session.ID" $sSession = _WD_CreateSession($sDesiredCapabilities) If @error <> $_WD_ERROR_Success Then Exit -1 EndIf FileWrite($sSessionFileName, $sSession & @CRLF) What I've done is to write out to a file the value of the sessionid following the call to _WD_CreateSession. Then when restarting an new app, I would call the following: Func _WD_ReAttach($Type)     Local Const $sFuncName = "_WD_ReAttach"     Switch $Type         Case $eFireFox             SetupFireFox()         Case $eChrome             SetupChrome()         Case $eEdge             SetupEdge()     EndSwitch     Local $pFile = FileOpen($sSessionFileName, 0)     If (@error = 0) Then         $sSession = FileReadLine($pFile)     EndIf EndFunc   ;==>_WD_ReAttach Which sets up the _WD_Option then reads in the saved session string. I can then continue interacting with the Chrome driver.... John W.
  3. I have encountered a few apps that have an embedded IE browser where F12 is not available and no "inspect object" on the right-click. That is why I had to develop the "PageInfo" routine. Plus, it also gives a good example of how to reference the objects on the page. John W.
  4. Over the years I developed a routine to dump every page element for IE. I've attached the file that contains this routine (PageInfo). This way, given a page, I could identify all of the object as AutoIt sees it. Now I'm like to have something similar for WD using the FindElement. Any suggestion on how best to accomplish this? Test_IE.au3
  5. I used the latest version of AutoIT V3.3.14.3 which has several newer constants and APIs defined.
  6. IPC_IO.AU3 I am in the need for a simple synchronous Client/Server communication. I found several examples and references to various kinds of Inter-Process Communications such as TCP, Named Pipes, Mail Slots, Shared Memory, Memory Mapped Files, and simple Files. I wanted to see what the best solutions would be. I began developing a library and slowly began adding each of the IPC methods and ended up with a library with a very simple synchronous “ASCII” API where the application can choose which method to use at startup. For the Server side, a Server app must initialize communication by calling: Func InitConnection($cType = $cDefaultType, $ResourceName = "", $bBlock = $cDefaultBlocking, $fSleepFunc = "", $iBufSize = $DEFAULT_BUFSIZE) The optional arguments allow the app to specify the connection type (such as: $cNamedPipe, $cFile, $cTCP, $cSharedMem, $cMailSlot), a value for the resource name (such as the file, named pipe name, TCP port number, etc.), the communication buffer size, and a callback function for when the “read” is waiting for data. A “File Descriptor” is returned and must be used in the future API calls. The Server side must then call: Func StartConnection($iFD) This call waits for a Client to connect. The Server then calls: Func ReadData($iFD, ByRef $sData) To read a Request from the Client and then calls: Func WriteData($iFD, ByRef $sData) To send the reply back to the Client. When communication with the Client is done, the Server app will call: Func StopConnection($iFD) When the Server app is done with the communications it will call: Func EndConnection($iFD) For the Client side, a Client app must open the communication by calling: Func OpenConnection($cType = $cDefaultType, $ResourceName = "", $bBlock = $cDefaultBlocking, $fSleepFunc = "", $iBufSize = $DEFAULT_BUFSIZE) The optional arguments allow the app to specify the connection type (such as: $cNamedPipe, $cFile, $cTCP, $cSharedMem, $cMailSlot), a value for the resource name (such as the file, named pipe name, TCP port number, etc.), the communication buffer size, and a callback function for when the “read” is waiting for data. A “File Descriptor” is returned and must be used in the future API calls. The Client side then send a request to the Server app by calling: Func WriteData($iFD, ByRef $sData) To read a Response from the Server by calling: Func ReadData($iFD, ByRef $sData) To end the connection to the Server by calling: Func CloseConnection($iFD) Within the IPC_IO.AU3 library, each IPC method is ether: · “stream” based where data is read/written by calling _WinAPI_ReadFile/TCPRecv or _WinAPI_WriteFile/ TCPSend · “direct” based for Shared memory where the Client reads the data directly from the Server App’s memory and the Server directly reads the Client App’s memory In processing a request, the “ReadData” process starts by checking if data is ready to be read by calling the routine: “ReadStart”, then it reads in the size of the request by calling “ReadSize”, it then reads in the Ascii Request by calling “ReadBuffer”, then the sequence is completed by calling “ReadEnd”. The Write Process follows the same sequence with “WriteData” calling “WriteStart”, “WriteSize”, “WriteBuffer”, “WriteEnd”. Results My testing showed that the performance of sending and receiving of a 10k file took: · "Shared Memory" was the fastest, at 0.007468 Sec · “Named Pipes” at 0.015954 · “Mail Slots” at 0.016427 · “File Based” at 0.270287 · “TCP” at 0.994884 IPC_IO.au3 Client.au3 Server.au3
  7. Found it in the documentation for DllCall... By default, AutoIt uses the 'stdcall' calling method. To use the 'cdecl' method place ':cdecl' after the return type.
  8. That worked great. So when does one use just "none" vs. "none:cdecl"?
  9. So is there another method to do this? Do you know of a routine in msvcrt.dll or KERNEL.dll that can do division with longs?
  10. I'm trying to call the srand function in the msvcrt.dll. It is defined as void srand( unsigned int seed ); My sample code is: Local $aResult Local $h_DLL = DllOpen("msvcrt.dll") If $h_DLL <> -1 Then     Local $uint = DllStructCreate("uint")     DllStructSetData($uint, 1, 54321)     ConsoleWrite('@@'  & @ScriptLineNumber & ' uint[' & DllStructGetSize($uint) & ']:' & DllStructGetData($uint, 1) & @CRLF)     $aResult = DllCall($h_DLL, "none", "srand", "int", $uint)     ConsoleWrite('@@'  & @ScriptLineNumber & ' srand done' & @CRLF)     If @error Then         ConsoleWrite('@@'  & @ScriptLineNumber & ' srand Error:' & @error & @CRLF)     EndIf Else     ConsoleWrite('@@'  & @ScriptLineNumber & ' srand DLL Error' & @CRLF) EndIf When I run it I get: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\AutoIt3\PasswordTool\Tweaks\srand.au3"     --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop @@7 uint[4]:54321 !>15:15:08 AutoIt3.exe ended.rc:-1073741819 +>15:15:08 AutoIt3Wrapper Finished. >Exit code: 3221225477    Time: 0.6205 Which indicates an Access violation. Using windbg, I can see in the assembly that it is trying to do a PTR on a 0x00 value. Searching the web, I found a reference to what the srand routine is trying to do:   void __cdecl srand (unsigned int seed) { _getptd()->_holdrand = (unsigned long)seed; } int __cdecl rand (void) { _ptiddata ptd = _getptd(); return ( ((ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L) >> 16) & 0x7fff ); } Do I need to do something to the msvcrt.dll library before it can reference any global pointers. I'm assuming that _getptd() must reference some global pointer?
  11. Trying to do some math with 64 bit and noticed math was not coming out right. Local $tDec = DllStructCreate("int64 num") $tDec.num = 0xDEADBEDDEADBED ConsoleWrite('Before:' & $tDec.num & @CRLF); $tDec.num = $tDec.num / 1 ConsoleWrite(' After:' & $tDec.num & @CRLF); This is generating: Before:62678480108313581  After:62678480108313585 Am I missing something? If I replace the divide ("/") with Multiply ("*") it works but the divides do not. If I divide by 2, I get: Local $tDec = DllStructCreate("int64 num") $tDec.num = 0xDEADBEDDEADBED ConsoleWrite('Before:' & $tDec.num & @CRLF); $tDec.num = $tDec.num / 2 ConsoleWrite(' After:' & $tDec.num & @CRLF); Before:62678480108313581  After:31339240054156793 But the number should be: 31339240054156790 Running with 32 bit AutoIT 3.3.14.2
  12. While trying to debug a "bad variable type" being set while calling some IE routines, I notice that almost all calls to SetError are actually done as a "Return SetError" but I also found a few spots where an error is set but not returned and on the next return statement, it is returned as a success. Around line 1095: Case 0 If Not $bIsMultiple Then __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _ "$iSelect=0 only valid for type=select multiple") SetError($_IESTATUS_InvalidValue, 3) EndIf If $oItem.selected Then $oItem.selected = False If $iFireEvent Then $oObject.fireEvent("onChange") $oObject.fireEvent("OnClick") EndIf EndIf Return SetError($_IESTATUS_Success, 0, 1) Case 1 Notice the first SetError is not part of a return so it will infact return as a Success. This is also at line 1136 and 1177.
  13. I created a script to "tail" the Windows Event Log (Attached: EventLogTail.au3). The script will examine the 4 main logs of "Application", "Security", "Setup" and "System". I also added buttons to generate an Event Reports for the 4 logs. If a generate (or if an event arrives) for "Application", the count will increase for "Application" log but so will the count for "Setup" although the Event Viewer will only show the entry for "Application". If I generate (or if an event arrives) for "Setup", the count will increase for "Setup" log but so will the count for "Application" although the Event Viewer will only show the entry for "Application". Currently running version 3.3.14.2 EventLogTail.au3
  14. When Compiling the Source with AutoIt v3.3.14.2, I encountered some issues. First I changed the Directives to remove the obsoleted values: #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly to be #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so Then in LIbs/resources.au3 there are two lines: ./Libs/resources.au3: $hImage = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "ptr*",0) ./Libs/resources.au3: $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "ptr*",0) That reference $ghGDIPDll that is not defined anywhere. Looking around I found a reference to $__g_hGDIPDll so I changed those two lines to the reference I found. In Ford Builder Source, around line 7081 where there is no space between the "]" and "Then". If $Parents[$i] = $GUIHandles[_GetCurrentWin()]Then to If $Parents[$i] = $GUIHandles[_GetCurrentWin()] Then Now it will compile. When I run it, I get: "D:\Downloads\AutoIt\Form Builder Source\Form Builder Source_stripped.au3" (22718) : ==> Subscript used on non-accessible variable.: WinMove($__hWnd_SciLexer, "", 152, 54, $hGUIWidth, $hClientSize[1]-54-$hOutputSize[1]-7) WinMove($__hWnd_SciLexer, "", 152, 54, $hGUIWidth, $hClientSize[1]-54-$hOutputSize^ ERROR Here I traced the problem down to line 14910: $hOutputSize = WinGetClientSize($hOutputEditor) Which is returning an Error and $hOutputSize being undefined value so the reference to $hOutputSize[1] is not accessible. The Handle $hOutputEditor is set on Line 267: $hOutputEditor = Sci_CreateEditor($hGUI, 152, 527, 646, 177) _Sci_DebugWindowStyle($hOutputEditor) Which is assigned a value of 0x0000000000000000 Any help on getting it to compile on the newer AutoIt would be appreciated. W
  15. Are you still supporting this. This has been very useful but we ran into some conditions when using various constructions kits like JFace, JQuery, etc.. The html elements do not have "name" attributes but do have generated "id" attributes. I added some additional routines to support this: ; #FUNCTION# ;=============================================================================== ; ; Name...........: _ChromeLoadURL() ; Description ...: Load a URL web page based. ; Syntax.........: _ChromeLoadURL($url, $timeout = 5) ; Parameters ....: $url - the URL to load ; $timeout - Optional: a number of minutes before exiting the function. ; Return values .: On Success - Returns "". ; On Failure - Returns "", and sets @ERROR = 2. ; Author ........: seangriffin ; Modified.......: ; Remarks .......: A prerequisite is that the Chrome browser is open ; (Window title = "[REGEXPTITLE:.*- Google Chrome]"). ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ; ;========================================================================================== Func _ChromeLoadURL($url, $timeout = 30) Dim $response = "" $response = Chrome_Eval("Chrome_LoadURL=" & $url, $timeout) SetError(@error) Return $response EndFunc ; #FUNCTION# ;=============================================================================== ; ; Name...........: _ChromeInputClickByID() ; Description ...: Clicks an <input> element based on it's "ID" attribute. ; Syntax.........: _ChromeInputClickByID($objid, $timeout = 5) ; Parameters ....: $objid - the value of the "name" attribute ; $timeout - Optional: a number of minutes before exiting the function. ; Return values .: On Success - Returns "". ; On Failure - Returns "", and sets @ERROR = 2. ; Author ........: seangriffin ; Modified.......: ; Remarks .......: A prerequisite is that the Chrome browser is open ; (Window title = "[REGEXPTITLE:.*- Google Chrome]"). ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ; ;========================================================================================== Func _ChromeInputClickByID($objid, $timeout = 5) dim $response = "" $response = _ChromeEval("document.getElementByID('" & $objid & "').click();", $timeout) SetError(@error) return $response EndFunc ; #FUNCTION# ;=============================================================================== ; ; Name...........: _ChromeObjGetValueByID() ; Description ...: Gets the value of an element based on it's "id" attribute. ; Syntax.........: _ChromeObjGetValueByID($objid, $index = 0, $timeout = 5) ; Parameters ....: $objid - the value of the "id" attribute ; $timeout - Optional: a number of minutes before exiting the function. ; Return values .: On Success - Returns $value. ; On Failure - Returns "", and sets @ERROR = 2. ; Author ........: seangriffin ; Modified.......: ; Remarks .......: A prerequisite is that the Chrome browser is open ; (Window title = "[REGEXPTITLE:.*- Google Chrome]"). ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ; ;========================================================================================== Func _ChromeObjGetValueByID($objID, $timeout = 5) dim $response = "" $response = _ChromeEval("document.getElementByID('" & $objid & "').value;", $timeout) SetError(@error) return $response EndFunc ; #FUNCTION# ;=============================================================================== ; ; Name...........: _ChromeObjSetValueByID() ; Description ...: Sets the "value" attribute of a element based on it's "id" attribute. ; Syntax.........: _ChromeObjSetValueByID($objid, $value, $timeout = 5) ; Parameters ....: $objid - the value of the "id" attribute ; $value - The text to set the "value" attribute to ; $timeout - Optional: a number of minutes before exiting the function. ; Return values .: On Success - Returns $value. ; On Failure - Returns "", and sets @ERROR = 2. ; Author ........: seangriffin ; Modified.......: ; Remarks .......: A prerequisite is that the Chrome browser is open ; (Window title = "[REGEXPTITLE:.*- Google Chrome]"). ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ; ;========================================================================================== Func _ChromeObjSetValueByID($objid, $value, $timeout = 5) dim $response = "" $response = _ChromeEval("document.getElementByID('" & $objid & "').value = '" & $value & "';", $timeout) SetError(@error) return $response EndFunc Would you be able to add these to your base? We also added _ChromeLoadURL to change the current URL I added the following to contentscript.js: if (request.greeting.indexOf("Chrome_LoadURL=") == 0) { var arg = request.greeting.substr("Chrome_LoadURL=".length); window.location.assign(arg); } chrome_additional.au3 contentscript.js
×
×
  • Create New...