luckyluke
Active Members-
Posts
74 -
Joined
-
Last visited
luckyluke's Achievements
Wayfarer (2/7)
1
Reputation
-
robertocm reacted to a post in a topic:
How can i set excel cell color with RGB color
-
$t = '... 1-347-318-9643 1-347-318-9647 1-347-318-9648 1-347-318-9650 1-347-318-9651 1-347-318-9652 1-347-318-9653 1-347-318-9655 1-347-318- ...' $pattern = '347.*?318.*?9655' $tmp = StringRegExpReplace($t, $pattern, "|||", 1) ConsoleWrite($tmp & @CRLF) However i got this output: ... 1-||| 1-347-318- ... Why i got only that, where is the other string, i thought the output should be this: ... 1-347-318-9643 1-347-318-9647 1-347-318-9648 1-347-318-9650 1-347-318-9651 1-347-318-9652 1-347-318-9653 1-||| 1-347-318- ...
-
luckyluke reacted to a post in a topic:
Dllcall - console attach to read output from CMD error
-
luckyluke reacted to a post in a topic:
Dllcall - console attach to read output from CMD error
-
This code will get the output when the program ends. But i want to get the status when the program is running. Yes, i found it and tried it before. But the code actually get the output after the program exit. I want to get the console while the program is running. this is my code: the code will open the CMD and run "python ui.py" then get the output from console. #include 'array.au3' ;#include "UIAWrappers.au3" Global $DOS, $timer, $whd $live_file = IniRead(@ScriptDir & '\config.ini', 'py_run', 'live_file', '') $prediction_file = IniRead(@ScriptDir & '\config.ini', 'py_run', 'prediction_file', '') $training_file = IniRead(@ScriptDir & '\config.ini', 'py_run', 'training_file', '') $wait_time = IniRead(@ScriptDir & '\config.ini', 'py_run', 'wait_time', 6) FileDelete(@ScriptDir & '\pyConsole.txt') startPY() Sleep(1000) $checker = 1 $i = 1 While 1 $tmp = ControlGetText('python.exe', '', 'Button1') if StringInStr($tmp, 'check online for a solution') Then WinClose('python.exe') Sleep(3000) startPY() EndIf ;~ Sleep(50) ;; no need to go at full speed here. ;~ $sOutput='' ;~ While 1 ;~ $sOutput &= StdoutRead($DOS, False, False) ;~ If @error Then ;~ ExitLoop ;~ EndIf ;~ Sleep(10) ;~ ConsoleWrite($sOutput) ;~ WEnd $Message = StdoutRead($DOS) ;; ditched peek parameter + changed "=" to "&=" ... No more endless loop. if @error Then restartPY() startPY() EndIf ;$sOutput = StderrRead($DOS) ;ConsoleWrite($i & ':' & $sOutput & ',' & StringLen($sOutput) & @CRLF) ConsoleWrite($i & ':' & $Message & ',' & StringLen($Message) & @CRLF) $i=$i+1 if StringLen($Message)>2 and StringInStr($Message, @CRLF) Then ConsoleWrite('i:' & $i & ',' & $Message & @CRLF) ;$i=$i+1 if StringInStr($Message, ',') Then $tmp = StringSplit($Message, @CRLF) ;_ArrayDisplay($tmp) if not @error Then for $j = 1 to UBound($tmp)-1 if StringInStr($tmp[$j], ',') Then $file = FileOpen(@ScriptDir & '\pyConsole.txt', 1) FileWrite($file, $tmp[$j] & @CRLF) FileClose($file) EndIf Next EndIf EndIf $checker=1 Else $checker = $checker+1 ;ConsoleWrite('checker:' & $checker & @CRLF) if $checker=10 Then $timer = TimerInit() EndIf EndIf if $checker>=10000 Then $atime = TimerDiff($timer)/1000 if not @error Then if $atime>Number($wait_time) Then restartPY() startPY() EndIf EndIf EndIf if @error then exitloop WEnd Func restartPY() Do if WinExists('C:\Windows\system32\cmd.exe') then WinClose('C:\Windows\system32\cmd.exe') Else ExitLoop EndIf Until WinExists('C:\Windows\system32\cmd.exe')=0 WinActivate('Predictive model 1.0') Sleep(500) WinClose('Predictive model 1.0') WinWait('Confirm Exit', '', 3) WinActivate('Confirm Exit') WinMove('Confirm Exit', '', 0, 0) Sleep(500) if WinExists('Confirm Exit') then MouseClick('left', 109,94) Sleep(4000) EndFunc Func startPY() $CMD = 'cd ' & @DesktopDir & '\Predictive_model && ' & _ 'python ui.py' $DOS = Run(@ComSpec & ' /C ' & $CMD, @ScriptDir, @SW_SHOW, $STDOUT_CHILD+$RUN_CREATE_NEW_CONSOLE) ;$DOS = Run(@ComSpec & ' /C ' & $CMD, @ScriptDir, @SW_SHOW, $STDIN_CHILD + $STDERR_MERGED) ConsoleWrite($DOS & @CRLF) $mtitle = 'Predictive model 1.0' WinWait($mtitle, '', 5000) ;Sleep(5000) WinMove($mtitle, '', 0, 0) Sleep(1000) ;=====================================set value to GUI================================================= ;live file ;_UIA_Action("Title:=;controltype:=UIA_EditControlTypeId;class:=","setfocus") ;_UIA_Action("Title:=;controltype:=UIA_EditControlTypeId;class:=","setValue using keys", "C:\Users\Administrator\Desktop\Sabrina Betting\LV1.txt") WinActivate($mtitle) Sleep(1000) MouseClick('left', 345,87) Send("^a") Sleep(500) Send($live_file & '11') ;prediction file WinActivate($mtitle) Sleep(1000) MouseClick('left', 345,200) Send("^a") Sleep(500) Send($prediction_file) ;use control click WinActivate($mtitle) Sleep(1000) MouseClick('left', 345,234) Send("^a") Sleep(500) Send($training_file) ;click start button ;~ Local $oP1=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Predictive model 1.0;controltype:=UIA_WindowControlTypeId;class:=QWidget", $treescope_children) ;~ Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_CustomControlTypeId;class:=", $treescope_children) ;~ Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Start;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree) ;~ _UIA_action($oUIElement,"focus") ;~ _UIA_action($oUIElement,"click") WinActivate($mtitle) Sleep(1000) MouseClick('left', 593,301) Sleep(3000) EndFunc
-
Hello, Im trying to read the output from CMD using Dllcall, here is my code: #include <WinAPI.au3> #include <array.au3> Global Const $STD_OUTPUT_HANDLE = -11 Global Const $_CONSOLE_SCREEN_BUFFER_INFO = _ "struct;int dwSizeX;" & _ "short dwSizeY;" & _ "short dwCursorPositionX;" & _ "short dwCursorPositionY;" & _ "short wAttributes;" & _ "short Left;" & _ "short Top;" & _ "short Right;" & _ "short Bottom;" & _ "short dwMaximumWindowSizeX;" & _ "short dwMaximumWindowSizeY;endstruct" $pCmd = Run( "cmd.exe" ) Sleep(1000) $hCmd = WinGetHandle("") ConsoleWrite('handle:' & $hCmd & @CRLF) $aRet = DllCall("kernel32.dll", "int", "AttachConsole", "dword", $pCmd) ;_ArrayDisplay($aRet) If $aRet[0] <> 0 Then $vHandle_data='' $vHandle='' $vHandle_data = DllStructCreate($_CONSOLE_SCREEN_BUFFER_INFO) ; Screen Buffer structure $aRet1 = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", $STD_OUTPUT_HANDLE) if not @error Then $vHandle = $aRet1[0] $aRet = DllCall("kernel32.dll", "int", "GetConsoleScreenBufferInfo", "hwnd", $vHandle, _ "ptr", $vHandle_data) MsgBox(0, '1',DllStructGetData($vHandle_data, 'dwSizeX') & _WinAPI_GetLastErrorMessage()) EndIf It did not work, i got the message 'The handle is invalid'. Please help? Thank you in advance!
-
HTTP request error, does not know problem
luckyluke replied to luckyluke's topic in AutoIt General Help and Support
thank you -
luckyluke reacted to a post in a topic:
HTTP request error, does not know problem
-
HTTP request error, does not know problem
luckyluke replied to luckyluke's topic in AutoIt General Help and Support
Thank you. Actually, i am trying to use http request in VBA and it does not work, so i come to autoit and try it but it does not work too. So, how can i make it work if i only want to use http request? -
HTTP request error, does not know problem
luckyluke replied to luckyluke's topic in AutoIt General Help and Support
that is strange, i am using wins7 64bit, not sure what is the problem -
hi all, i tried to access to the website https://www.auction.com/residential/ with http request. here is the code: Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1"), $date, $limit, $rdir, $wpdir $agent ='Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36' $url = 'https://www.auction.com/residential/' ConsoleWrite($url & @CRLF) $oHTTP.Open("GET", $url, False) $oHTTP.setRequestHeader ("User-Agent", $agent) ;$oHTTP.Option(4) = 13056 $oHTTP.Send() $srcHTML = ($oHTTP.ResponseText) ConsoleWrite($srcHTML & @CRLF) But when i run it, i always get the error: ==> The requested action with this object has failed.: $oHTTP.Send() $oHTTP^ ERROR for other website, it is working well, but this one does not. Pls help me
-
A problem using winhttp request for https site
luckyluke replied to luckyluke's topic in AutoIt General Help and Support
Hi, i tested the code with other computer, and it did not work. Do you get the result or blank message box? I dont know why is that. -
Hello all, Im trying to get the information from https website, but it does not return any thing, here is the code: Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $agent ='Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36' $url = "https://www.sportinglife.com/racing/results" $oHTTP.Open("GET", $url, False) $oHTTP.setRequestHeader ("User-Agent", $agent) $oHTTP.Option(4) = 13056 $oHTTP.Send() $src = ($oHTTP.ResponseText) ConsoleWrite($url & @CRLF) MsgBox(0, '$src', $src) when i tried with other website, it is working, but this code does not works with this website. Pls help me thank you.
-
Read output from CMD using PID
luckyluke replied to luckyluke's topic in AutoIt General Help and Support
Juvigy check the careca 's code, it worked for me.