Jump to content

Network_Guy

Active Members
  • Posts

    59
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Network_Guy

  1. using return("string") like this bugging the script it should return variable only . try use msgbox or console write instead. and i recommend using processwaitexit method to get the output std than the loop method in your case .exp #include <constants.au3> Func _GetActiveSSID() Local $line, $pid = Run(@ComSpec & " /c " & 'netsh wlan show interfaces', "", @SW_HIDE, $STDERR_CHILD+ $STDOUT_CHILD ) ProcessWaitClose($pid) $line = StringStripWS(StdoutRead($pid), 4) If @error Then ConsoleWrite("Error") If StringInStr($line, "SSID") Then $line = StringTrimLeft($line, StringInStr($line, "SSID")+6) ConsoleWrite(StringTrimRight($line, StringLen($line)-StringInStr($line, "BSSID")+2)) ElseIf StringInStr($line, "disconnected") Then ConsoleWrite("None"&@CRLF) EndIf StdioClose($pid) EndFunc While 1 MsgBox(0, "SSID", _GetActiveSSID(), 0.5) Sleep(500) WEnd
  2. @nine , true that iRet contain the pid of taskkill external process ,but as i know this process(taskkill) will exit when qbwc.exe and all its children are closed , or i miss something ?
  3. true ,sry my fault i will change the original post
  4. change processwaitclose("qbwc.exe") to processwaitclose($iRet) with killprocess /T cause if qbwc spwan child process , with processwaitclose("qbwc.exe") u wait for the parent exe only ,but using processwaitclose($iRet) u will wait for parent and child process to close
  5. may be the process "qbwc.exe" spawn some child process so try using the "/T" switch with "taskkill" ,try this code :- While 1 Sleep(100) ; Sleep to reduce CPU usage If FileExists("e:\QuickBooks\ResetWebConnector.txt") Then ; Check for trigger file Local $iRet = Run ("TaskKill /IM qbwc.exe /T /F") ProcessWaitClose($iRet) ConsoleWrite ("closing process : "&$iRet & " / Error : " & @error & @CRLF) ;MsgBox($MB_SYSTEMMODAL, "Restarting Web Connector", "The Web Connector will restart in 5 seconds or click OK to start it now.", 5) ;ShellExecute("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe") ; Restart the QuickBooks Web Connector Local $iRet = Run("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe") ConsoleWrite ("starting process : "&$iRet & " / Error : " & @error & @CRLF) $iResetCount = $iResetCount + 1 GUICtrlSetData( $iLastReset, "Last Reset: " & _Now() & " Count: " & $iResetCount ) FileDelete("e:\QuickBooks\ResetWebConnector.txt") ; Delete trigger file EndIf WEnd
  6. hello autoit community, i would like to share this ping util based on .Net core App domain , which have some more functions than the standard autoit ping , like :- 1- send ping with specified TTL & size & dontfragment flag & time out 2-true multithreading ping (send many ping packets same time) 3- no 3rd party exe or dll included requirements:- DotNet All Functions:- 1-$result=_ping($ip[,$timeout,$TTL,$dontfragment,$buffersize]) input:- $ip=(string) can be single ip or array of IP (ping will be sent to all ips in the array on same time) $timeout=(int) default is 4000 $TTL= (int) default is 255 $dontfragment=(bool) default is false $buffersize=(int) default is 32 output:- $result=ping time as single int if $ip was single ip or array of int if $ip was array of ip's , $result=0 if host unreachable or offline $result=-1 if host not exist(bad domain name) or general error 2-_ping_debug($enable) $enable = (bool) enable debugging output to console , false by default examples:- 1-MTU example #include<PingEX.au3> $ip="8.8.8.8" $timeout=200 $ttl=200 $dontfragment=true for $packetsize=1500 to 1480 step -1 $packetheader=28 $result=_ping($ip,$timeout,$ttl,$dontfragment,$packetsize-$packetheader) if $result>0 Then ConsoleWrite("Max allowed packet size without fragmentation is : "&$packetsize &@crlf) ExitLoop endif next 2- Multi threading ping:- #include<PingEX.au3> $codeperformance=TimerInit() global $IP_list[5]=["192.168.1.1","10.0.0.1","www.google.com","Wrongdomain","192.168.1.1.1.1.1"] $timeout=1000 $result=_ping($IP_list,$timeout) for $i=0 to UBound($IP_list)-1 ConsoleWrite("Pinging "&$IP_list[$i]&" :Result is = "&$result[$i]&@CRLF) next ConsoleWrite("Code executed in : "&TimerDiff($codeperformance)&@CRLF) PingEX.au3
  7. try to manualy copy the pptx file to local disk then open it with shell execute and delete it after u close powerpointviewer,exp:- #include <WinAPIShellEx.au3> #include <WinNet.au3> ;I do declare the variables with the server credentials $sServer = '192.168.20.13' $sShare = 'Compartida\Carpetas Personales\formacion\formacion' $sUsername = 'localserver\userfake' $sPassword = 'pssworduserfake' $sServerShare = '\\' & $sServer & '\' & $sShare $result = _WinNet_AddConnection2("", $sServerShare, $sUsername, $sPassword, 1) If $result Then FileCopy($sServerShare & "\AAAA.ppsx",@TempDir&"\AAAA.ppsx") $PID=ShellExecute(@TempDir&"\AAAA.ppsx") ProcessWaitClose($PID) FileDelete(@TempDir&"\AAAA.ppsx") Else ConsoleWrite("Unable to connect to " & $sServerShare & @CRLF) EndIf
  8. try this :- #include<AutoItConstants.au3> #include<MsgBoxConstants.au3> $process=Run("help dir","", @SW_MAXIMIZE,$STDOUT_CHILD) ProcessWaitClose($process) ;w8 the command to be executed $Result=StdoutRead($process) ;the command output will be stored on $Result variable MsgBox($MB_OK,"Command result",$Result) ;show the output on a msgbox FileWrite("helpdir.txt",$Result) ; save the output in txt file
  9. in short if u try to send "a" down for a game or a full window app it may or may not work and its totally depend on the game or app .
  10. thanks for this awesome UDF, can u provide an example of using Asymmetric RSA ?
  11. in your case u should change UDPopen() to UDPbind() , here is a working example:- $DST_IP="10.27.20.202" ; PLC IP $DST_Port=2051 ; PLC RX port $SRC_IP="127.0.0.1" ; WIN IP $SRC_Port=2050 ; WIN port which u want it to be the src port $Receive_Socket=UDPBind($SRC_IP,$SRC_Port) $Transmit_socket=$Receive_Socket $Transmit_socket[2]=$DST_IP $Transmit_socket[3]=$DST_Port ; For simple data transmit to PLC u just use this code :- $mydata="hello !" UDPSend($Transmit_socket,$mydata) by the way u can use one port to send & receive at same time , that will reduce design complexity .
  12. here is the problem :- 1- $Data_Err &= StderrRead($SSH_Process_Id) so variable $data_err will always have "Store key in cache" string , so If StringInStr($Data_Err, "Continue with connection? (y/n)") > 0 Or StringInStr($Data_Err, "Store key in cache? (y/n)") > 0 Then StdinWrite($SSH_Process_Id, "y") the first if statement will always be true , and the ElseIf StringInStr($Data_Out, "login as:") > 0 Then ExitLoop EndIf will never be executed so your code just spam "y" 2-you need to use @crlf after each command not CR alone
  13. you need some debugging methods (like consolewrite ) to track your code for exp :- While 1 $GUi_Value=ControlGetText("Window", "", 2865) $LowVac=number($LowVac) $HiVac=number($HiVac) $GUi_Value=number($GUi_Value) ConsoleWrite("variable LowVac = "&$LowVac&@CRLF) ;For debug ConsoleWrite("variable HiVac = "&$HiVac&@CRLF) ;for debug ConsoleWrite("variable GUi_Value = "&$GUi_Value&@CRLF) ;for debug if not ($LowVac > $GUi_Value and $HiVac < $GUi_Value) Then ExitLoop Sleep (1000) $BadPressTime = $BadPressTime +1 GUICtrlSetData (4, $BadPressTime) GUICtrlSetData (6, "Please wait.") GetPress() WEnd
  14. wingethandle("[ACTIVE]") will return current active window handle (can return handle for another window than notebad ) ,so use this code instead $VAR_NotepadHWND =WinGetHandle("[CLASS:Notepad]") second , dont forget the Control ID in ControlSend so it should be :- Func Sim() Return ControlSend($VAR_NotepadHWND, "", "Edit1" , "Hello World !!") ;ControlID EndFunc
  15. using Run() will run new process in totally separated memory and thats the reason for your problem with $cell . i cant rly get what are you trying to do with this script , but here is mini example for calling function from included au3 with shared global variable. Main #include<test.au3> Global $var=0 for $i =0 to 2 _Function() $var+=1 next Include(test.au3) #include-once func _function() MsgBox(0,"",$var) EndFunc
  16. you run file2.au3 in a new process which have a totally separated memory .
  17. you can just encrypt section&key&values then use iniwrite to write the encrypted string and for read use iniread to get the encrypted section&key&values then decrypt it to get the orignal data ,example :- #include <Crypt.au3> _Crypt_Startup() INI_Encrypt_Write("test.ini","1234","Testsection","TestKey","TestValue") MsgBox(0,"", INI_Decrypt_Read("test.ini","1234","Testsection","TestKey",0)) func INI_Encrypt_Write( $filename,$password , $section,$key,$value) $section=_Crypt_EncryptData ( StringToBinary($section), $password, $CALG_AES_256) $key=_Crypt_EncryptData ( StringToBinary($key), $password, $CALG_AES_256) $value=_Crypt_EncryptData ( StringToBinary($value), $password, $CALG_AES_256) IniWrite($filename,$section,$key,$value) endfunc func INI_Decrypt_Read( $filename,$password , $section,$key,$default) $section=_Crypt_EncryptData ( StringToBinary($section), $password, $CALG_AES_256) $key=_Crypt_EncryptData ( StringToBinary($key), $password, $CALG_AES_256) $encryptedString=IniRead($filename,$section,$key,$default) $decrypt=BinaryToString(_Crypt_DecryptData($encryptedString, $password, $CALG_AES_256)) return $decrypt endfunc _Crypt_Shutdown() here is the test.ini [0x9C8DC54F9391114C9168053C313A58AB] 0x2C30CEBB1003D32EE8B2B45BEE3AA723=0x9C0E57198A990F1D35B6A54136E0405E BTW :- i agree with every one that ini is not recommended .
  18. you can try my MultiTasking.au3 to execute a function (drivesearch,_search , etc ) in parallel ,and if you are interested to create a GUI script ,you can use this UDF also to do search without effecting (Hanging) the GUI. Note :- (you need to download Multi-Tasking ,MailSlot UDF), in your case try this code (without GUI):- #include <array.au3> #include <file.au3> #include <FileConstants.au3> #include <MultiTasking.au3> $timer = TimerInit() ; Calcuate total execution time from here _Task_SetVar("ResultString", "") ;Create string variable all Tasks can Read & Write to it $Drives = DriveGetDrive("All") ;get all drives on your PC Local $TaskArray[0] ; create PID array for all created Tasks For $i = 1 To $Drives[0] If DriveStatus($Drives[$i]) = "READY" Then ; Scan usable drives only (Ignore empty CD , unformated partion , etc ......) $TaskID = _Task_Create("", "SearchDrive", $Drives[$i]) ; parallel execute searchdrive function with 1 parmeter ( driveletter from $drives array) _ArrayAdd($TaskArray, $TaskID) ; add current Task PID to all Tasks PID array EndIf Next _Task_Join($TaskArray) ; wait for all parallel tasks to complete ; $temp = _Task_GetVar("ResultString") ; get result as big string $temp = StringTrimRight($temp, 1) ; remove last "|" char $ResultArray = StringSplit($temp, "|", 2) ; convert string to array $totaltime = TimerDiff($timer) ; calculate total exec time _ArrayDisplay($ResultArray) ;show result MsgBox(0, "", $totaltime) ; show total exec time Func SearchDrive($drive) $Searchlocation = $drive ; drive to be searched $SearchFor = "RootFolder" ; folder name ;~ $SearchLvlDepth=1 ; 1 lvl Depth ;~ $SearchLvlDepth=2 ; 2 lvl Depth so on $SearchLvlDepth = -1 ; Search in all subfolders (unlimited recursion) $array = _FileListToArrayRec($Searchlocation, $SearchFor, $FLTAR_FOLDERS, -1 * $SearchLvlDepth, $FLTAR_NOSORT, $FLTAR_FULLPATH) If $array <> "" Then _ArrayDelete($array, 0) $Result = _ArrayToString($array) ; convert result array to string _Task_SetVarEx("ResultString", "&=", $Result & "|") ; safe append current result to ResultString (all tasks can read &write to Resultstring) EndIf EndFunc ;==>SearchDrive
  19. @_leo_ just type @Davidowicza code manually (don't copy&paste)
  20. $oNNV = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[(text(),'Noch nicht veröffentlicht')]") the comma in text(),'Noch' is the problem , use ' = ' as u did in _WD_WaitElement
  21. u can use cmd commend like : echo %windir% to get winpath , then use any remote cmd execution method to run it remotly for any pc in domain like PSexec remote WMIC
  22. Pure Awesomeness : Mycode=385200 Sec ~1H:7M @InnI code = 3 sec Thank you very much .
  23. sry i missed that i edited the code , but same performance
  24. hi community, i built a script to get every pixel on a high quality image (4000*6000 pixel) and alter them if needed , the problem is my code is so slow , any suggestion ? here is the code and some random HQ image #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIHObj.au3> #include <AutoItConstants.au3> _GDIPlus_Startup() $ImagePath="image.jpg" $hBitmap = _GDIPlus_BitmapCreateFromFile($ImagePath) $width = _GDIPlus_ImageGetWidth($hBitmap) $height = _GDIPlus_ImageGetHeight($hBitmap) $Count=0 $total=$width*$height ProgressOn("Filter","Progress Percent", "0%", -1, -1, BitOR($DLG_NOTONTOP, $DLG_MOVEABLE)) for $iX=0 to $width-1 for $iY=0 to $height-1 $iColor = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) ;get current pixel color $iR = BitShift(BitAND($iColor, 0x00FF0000), 16) ;extract red color channel $iG = BitShift(BitAND($iColor, 0x0000FF00), 8) ;extract green color channel $iB = BitAND($iColor, 0x000000FF) if $iR>150 or $iG>150 or $iB> 140 then _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, "0xFFFFFFFF" ) $Count+=1 $percent=($Count/$total)*100 ;~ MsgBox(0,"",$percent&@crlf&$Count&@crlf&$total&@crlf) ProgressSet($percent,$Count) Next Next _GDIPlus_ImageSaveToFile($hBitmap,"Result.jpg") _GDIPlus_BitmapDispose($hBitmap) ProgressOff() _GDIPlus_Shutdown()
  25. using your code i just added some consolewrite&msgbox so we can track what actually happen , assuming the pixel never found so we can simplify code to this :- HotKeySet("{ESC}", "On_Exit") ;quick way out if something goes wrong #include <AutoItConstants.au3> Global $searchforspecficpixel Global $RefreshTimer = TimerInit() While 1 $TimePassed=TimerDiff($RefreshTimer) ConsoleWrite($TimePassed&" Milisecond passed since last TimerInit"&@crlf) If $TimePassed>10000 Then ;refreshes page ;check if 10000 msec passed yet $message1="Bingo;10 sec passed , lets Refresh the page"&@CRLF $message2="now we will reset timer by calling TimerInit again" MsgBox(0,"",$message1&$message2) $RefreshTimer = TimerInit() Else ConsoleWrite("Ten sec not passed yet"&@crlf) EndIf sleep(2000) WEnd Func On_Exit() Exit EndFunc ;==>On_Exit why we use timer init&diff methods ? we can use sleep(10000) but the problem is the script cant do any thing in those 10000 Msec or in other word it will wait 10 sec then rechecking the pixel in your case so by using timer init&diff methods we can keep searching for the pixel in those 10 sec and when 10 sec passed it will just refresh the page and restart the timer from 0 again and so on.
×
×
  • Create New...