Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/17/2022 in all areas

  1. @noellarkinIIRC, this occurs with the 32 bit version of Geckodriver. You need to either switch to the 64 bit version or supply the binary location as part of your capabilities string. This feature was added by @mLipokhere. The current implementation requires you to either provide the full path to the webdriver or it must exist in the current working directory. Unsure why it works in one editor and not the other.
    1 point
  2. Ditto (simpler) $source = "https://www.treshaut.net/tels/Installations_Auto/date_maj2.txt" $dest = "test.txt" RunWait('curl -L -s -k ' & $source & ' -o "' & $dest & '"', "", @SW_HIDE) or $out = _Get("https://www.treshaut.net/tels/Installations_Auto/date_maj2.txt") ConsoleWrite($out & @crlf) Func _Get($url) Local $cmd = "curl -L -s -k " & $url Local $iPID = Run($cmd, "", @SW_HIDE, 2) ;$STDOUT_CHILD ProcessWaitClose($iPID) Local $output = StdoutRead($iPID) Return $output EndFunc
    1 point
  3. Maybe need chance the number I have 1920 X 1080 display Func _TitleBarSize($aWinTitle = "[ACTIVE]") Local $aPos = WinGetPos($aWinTitle) ;$aPos[0] = X position $aPos[1] = Y position $aPos[2] = Width $aPos[3] = Height Local $aBarSize[4] ;$aBarSize[0] = X position $aBarSize[1] = Y position $aBarSize[2] = Width $aBarSize[3] = Height $aBarSize[0] = $aPos[0] + 8 $aBarSize[1] = $aPos[1] + 1 $aBarSize[2] = $aPos[2] - 16 $aBarSize[3] = 31 ConsoleWrite("BarSize: " & $aBarSize[2] & " X " & $aBarSize[3] & @CRLF) ; <<<<<<<<<<<<<< make ghost gui to check $ghost_gui = GUICreate("ghost_gui", $aBarSize[2], $aBarSize[3], $aBarSize[0], $aBarSize[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor("0xFFFF00") ; $COLOR_YELLOW WinSetTrans($ghost_gui, "", 80) GUISetState(@SW_SHOW, $ghost_gui) ; >>>>>>>>>>>>>>> then delete Return $aBarSize EndFunc ;==>_TitleBarSize
    1 point
  4. Maybe with _WinAPI_GetClientRect vs _WinAPI_GetWindowRect ?
    1 point
  5. NewCommer

    Websockets and AutoIt

    My websocket UDF: Only AutoIt code (combine Js from IE core): 😃 #RequireAdmin MsgBox(0x1000, 'Begin', 'Example1') example1() MsgBox(0x1000, 'Begin', 'Example2') example2() MsgBox(0x1000, 'Begin', 'Example3') example3() Func example1() Local $oWS = Websocket_Connect('wss://api.bitfinex.com/ws') Local $recv = Websocket_Send($oWS) For $index = 0 To $recv.length - 1 ConsoleWrite(' - Index ' & $index & ': ' & $recv.index($index) & @CRLF & @CRLF) Next Websocket_Close($oWS, 1000, '', 20000) EndFunc Func example2() Local $oWS = Websocket_Connect('wss://api.bitfinex.com/ws') Local $recv = Websocket_Send($oWS) $oJson = $recv.index(0, True) ;<= True = turn on Json parse MsgBox(0x1000, '$oJson.serverId', $oJson.serverId) Websocket_Close($oWS, 1000, '', 20000) EndFunc Func example3() Local $oWS = Websocket_Connect('wss://api.bitfinex.com/ws') Local $recv = Websocket_Send($oWS, '{"event":"subscribe","channel":"ticker","pair":"BTCUSD"}') Local $Timer = TimerInit() Do Sleep(1000) For $index = 0 To $recv.length - 1 ConsoleWrite(' - Index ' & $index & ': ' & $recv.index($index) & @CRLF & @CRLF) Next ConsoleWrite('-------------------------------------------------' & @CRLF) Until TimerDiff($Timer) > 30000 Websocket_Close($oWS, 1000, '', 20000) EndFunc Func Websocket_Connect($Ws_URL, $protocol = '', $binaryType = False, $timeout = 20000) _IE_Emulation(True) If @error Then Exit MsgBox(0x40000, 'Fatal Error', 'You must install Internet Explorer 11') Local Static $oEvent = ObjEvent('AutoIt.Error', '') Local $oWS = ObjCreate("HTMLFILE") $Ws_URL = '"' & $Ws_URL & '"' If $protocol Then $Ws_URL &= ', [' & StringRegExpReplace(StringRegExpReplace($protocol, '(?i)Sec-WebSocket-Protocol:\s+', '', 1), '(\w+)', '"${1}"') & ']' If $binaryType = Default Then $binaryType = False With $oWS.parentwindow .execScript( _ 'Array.prototype.item = function(i,parseJson) {if(typeof parseJson==''undefined''){return this[i]}else{return JSON.parse(this[i])}};' & _ ;Ma thuật giúp autoit thÆ°Æ¡ng tác JS Array 'Array.prototype.index = Array.prototype.item;' & _ 'var recv_data=[], event_close = [], event_error ;' & _ 'let socket = new WebSocket(' & $Ws_URL & ');' & _ 'socket.binaryType = "' & ($binaryType ? 'arraybuffer' : 'blob') & '";' & _ 'socket.onopen = function(event) {};' & _ 'socket.onmessage = function(event) {recv_data.push(event.data)};' & _ 'socket.onclose = function(event) {event_close = event};' & _ 'socket.onerror = function(error) {event_error= error.message};') If @error Then Return SetError(1, ConsoleWrite(@CRLF & '! [Websocket_Connect] Your IE don''t support websocket. Please update to IE11' & @CRLF & @CRLF), 0) Local $ti = TimerInit() Do Sleep(25) If TimerDiff($ti) > $timeout Then Return SetError(2, ConsoleWrite(@CRLF & '! [Websocket_Connect] Connect timeout' & @CRLF & @CRLF)) Until .eval('socket.readyState') = 1 EndWith ConsoleWrite(@CRLF & '> [Websocket_Connect] Connection established' & @CRLF & @CRLF) Return $oWS EndFunc Func Websocket_Send(ByRef $oWS, $Data = '', $timeout = 60000) If $Data Then $oWS.parentwindow.eval('socket').send($Data) Local $recv_data = $oWS.parentwindow.eval('recv_data') Local $ti = TimerInit() Do Sleep(25) If TimerDiff($ti) > $timeout Then Return SetError(1, ConsoleWrite('! [Websocket_Send] Receive timeout' & @CRLF & @CRLF)) Until $recv_data.length > 0 Return $recv_data EndFunc Func Websocket_ResetRecvData(ByRef $oWS) $oWS.parentwindow.eval('recv_data.splice(0, recv_data.length);') EndFunc Func Websocket_Close(ByRef $oWS, $Code = 1000, $Reason = '', $wait_ms = 0) With $oWS.parentwindow.eval('socket') .close() If .readyState >= 2 Then ConsoleWrite('> [Websocket_Close] The connection is in the process of closing...') If IsKeyword($wait_ms) Then $wait_ms = 0 If $wait_ms > 0 Then If $wait_ms < 10000 Then $wait_ms = 10000 Local $ti = TimerInit() Do Sleep(25) If TimerDiff($ti) > $wait_ms Then ExitLoop Until .readyState = 3 If .readyState = 3 Then Local $event_close = $oWS.parentwindow.eval('event_close') ConsoleWrite('The connection is closed with Code=' & $event_close.code & ($event_close.reason ? ' and Reason=' & $event_close.reason : '')) EndIf EndIf $oWS = Null ConsoleWrite(@CRLF & @CRLF) EndWith EndFunc Func _IE_Emulation($vTurnOn = True) ;By Huân Hoàng ;https://blogs.msdn.microsoft.com/patricka/2015/01/12/controlling-webbrowser-control-compatibility/ Local Static $isOn = False If $vTurnOn = True And $isOn = True Then Return Local Static $_Reg_BROWSER_EMULATION = '\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION' Local Static $_Reg_HKCU_BROWSER_EMULATION = 'HKCU\SOFTWARE' & $_Reg_BROWSER_EMULATION Local Static $_Reg_HKLM_BROWSER_EMULATION = 'HKLM\SOFTWARE' & $_Reg_BROWSER_EMULATION Local Static $_Reg_HKLMx64_BROWSER_EMULATION = 'HKLM\SOFTWARE\WOW6432Node' & $_Reg_BROWSER_EMULATION Local $_IE_Mode, $_AutoItExe = StringRegExp(@AutoItExe, '(?i)\\([^\\]+.exe)$', 1)[0] Local $_IE_Version = StringRegExp(FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe"), '^\d+', 1) If @error Then $isOn = False Return SetError(1, ConsoleWrite('! [_IE_Emulation]: Cannot get IE Version' & @CRLF & @CRLF), False) EndIf $_IE_Version = Number($_IE_Version[0]) Switch $_IE_Version Case 10, 11 $_IE_Mode = $_IE_Version * 1000 + 1 Case Else Return SetError(2, ConsoleWrite('! [_IE_Emulation]: You must install Internet Explorer 10 and Internet Explorer 11' & @CRLF & @CRLF), False) EndSwitch If $vTurnOn Then If RegRead($_Reg_HKCU_BROWSER_EMULATION, $_AutoItExe) <> $_IE_Mode Then RegWrite($_Reg_HKCU_BROWSER_EMULATION, $_AutoItExe, 'REG_DWORD', $_IE_Mode) If RegRead($_Reg_HKLM_BROWSER_EMULATION, $_AutoItExe) <> $_IE_Mode Then RegWrite($_Reg_HKLM_BROWSER_EMULATION, $_AutoItExe, 'REG_DWORD', $_IE_Mode) If @AutoItX64 And RegRead($_Reg_HKLMx64_BROWSER_EMULATION, $_AutoItExe) <> $_IE_Mode Then RegWrite($_Reg_HKLMx64_BROWSER_EMULATION, $_AutoItExe, 'REG_DWORD', $_IE_Mode) $isOn = True Else RegDelete($_Reg_HKCU_BROWSER_EMULATION, $_AutoItExe) RegDelete($_Reg_HKLM_BROWSER_EMULATION, $_AutoItExe) If @AutoItX64 Then RegDelete($_Reg_HKLMx64_BROWSER_EMULATION, $_AutoItExe) $isOn = False EndIf Return True EndFunc
    1 point
×
×
  • Create New...