Jump to content

Viszna

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Location
    Northern Poland, around Gdańsk

Recent Profile Visitors

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

Viszna's Achievements

Seeker

Seeker (1/7)

2

Reputation

  1. I'm using UIAWrapper.au3 and sometimes I get this error: "C:\AUTOMATY\UIAWrappers.au3" (1674) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $x = Int($t[1] + ($t[3] / 2)) $x = Int($t[1] + (^ ERROR ->14:05:04 AutoIt3.exe ended.rc:1 The biggest problem is catching the error, the script runs ~10 hours every day. The function is called dozens of times a day. The error occurs 2 a month, but it is irritating because it interrupts the script. Excerpt from UIAWrappers.au3 1668 Local $t 1669 $t = StringSplit(_UIA_getPropertyValue($obj2ActOn, $UIA_BoundingRectanglePropertyId), ";") 1670 ;~ If no parameter detect the middle 1671 If $p1 = 0 Then 1672 ;~ consolewrite(_UIA_getPropertyValue($obj, $UIA_BoundingRectanglePropertyId) & $t[1] & ";" & $t[2] & ";" & $t[3] & ";" & $t[4] & @crlf) 1673 ;~ _winapi_mouse_event($MOUSEEVENTF_ABSOLUTE + $MOUSEEVENTF_MOVE,$t[1],$t[2]) 1674 $x = Int($t[1] + ($t[3] / 2)) 1675 $y = Int($t[2] + $t[4] / 2) 1676 Else 1677 ;~ calculate location relative in the element found 1678 $x = Int($t[1] + $p1) 1679 $y = Int($t[2] + $p2) 1680 EndIf Maybe it's worth adding a verification of the $t variable on line 1670 before further operations on the $t array? I added an error trap - now I'm waiting for it to appear and check what goes to $t.
  2. 2 computers non-stop simultaneously and sometimes 3 computers (only temporarily 1-2 minutes)
  3. Hello, Sorry to just write back, but I was out. I cannot change the database configuration. max_user_connections = 20 ?? look at the screen How I "threw" _ADO_Connection to the beginning of the program, outside the loop, the script is very stable, no errors, much faster. Currently, I call the database several times a second and everything is OK regards Viszna
  4. Hello I have a problem with ADo and more specifically with access to the database. Until now, I have been using a database to read 1 record while the script is running and finally save 1 record. Runs 1-5 times a day and works OK 2-5 minutes pass from _ReadDBO() to _WriteDBO ($sSQL) In simple terms, the program looked like this: ;START script _ReadDBO() ... ... ... _WriteDBO($sSQL) Exit ;END script Func _ReadDBO() _ADO_Connection_Create() _ADO_Connection_OpenConString($oConnection, $MultiBot_sConnectionString) _ADO_Execute($oConnection, $sSQL) _ADO_Connection_Close($oConnection) EndFunc Func _WriteDBO($sSQL) _ADO_Connection_Create() _ADO_Connection_OpenConString($oConnection, $MultiBot_sConnectionString) _ADO_Execute($oConnection, $sSQL) _ADO_Connection_Close($oConnection) EndFunc Now I started using ADO in a script that executes _ReadDBO() and _WriteDBO($sSQL) every 1-2 seconds and the script is run on 5 computers (automation of the business process in the database, downloads the data from the database to be processed and saves the results to database) Problems with access to the database started, message: "User 'userDBO' already has more than 'max_user_connections' active connections" -MySQL base My question: Does the function call: _ADO_Connection_Create () and _ADO_Connection_OpenConString ($oConnection, $MultiBot_sConnectionString) should be at the beginning of the program and should NOT be called with every query to the database? See the example below: ;START script _ADO_Connection_Create() ; move from Func _ADO_Connection_OpenConString($oConnection, $MultiBot_sConnectionString) ; move from Func Do _ReadDBO() ... ... ... _WriteDBO($sSQL) Until 0 _ADO_Connection_Close($oConnection) ; move from Func Exit ;END script Func _ReadDBO() _ADO_Execute($oConnection, $sSQL) EndFunc Func _WriteDBO($sSQL) _ADO_Execute($oConnection, $sSQL) EndFunc I have never encountered such an error message before, even when I was practicing with ADO and calling the base every 1 second. P.S. @mLipok Thank you very much for your contribution to AutoIT - very much respect indeed, and sorry for my "translate.google" English 😉
  5. Hello, I am so sorry that I am writing back so late, but I had a business trip. First of all, thank you very much, junkew and LarsJ solutions work 😀 $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oWindow1 OK --- Find window/control --- $pCondition1 OK $oStatusBar1 OK --- Find window/control --- $pCondition2 OK $oText1 OK --- Element Properties --- NamePropertyId Window = PRO FM PM Reader Tool ~ Edata Polska 01.07 NamePropertyId StatusBar = statusStrip1 NamePropertyId Text = Paragon: 2/55 Zakres: 1-55 B³êdy Transmisji Liczyæ: 0 Name2PropertyId Text = Paragon: 2/55 Zakres: 1-55 B³êdy Transmisji Liczyæ: 0 _UIA_getPropertyValue($oText1, $UIA_NamePropertyId) = Paragon: 2/55 Zakres: 1-55 B³êdy Transmisji Liczyæ: 0 The cause was a bad item reference ;~ $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pText1 ) ; <====== wrong solution $oStatusBar1.FindFirst( $TreeScope_Descendants, $pCondition2, $pText1 ) ; <====== its works I am a beginner in UIA and I will probably make many mistakes. Below is the complete working code to analyze for others with the problem #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder #include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder #include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder #include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "WindowsForms10.Window.8.app.0.378734a", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Children, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "m_status_strip", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pStatusBar1, $oStatusBar1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pStatusBar1 ) $oStatusBar1 = ObjCreateInterface( $pStatusBar1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oStatusBar1 ) Then Return ConsoleWrite( "$oStatusBar1 ERR" & @CRLF ) ConsoleWrite( "$oStatusBar1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pText1, $oText1 ;~ $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pText1 ) ; <====== wrong solution $oStatusBar1.FindFirst( $TreeScope_Descendants, $pCondition2, $pText1 ) ; <====== its works $oText1 = ObjCreateInterface( $pText1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oText1 ) Then Return ConsoleWrite( "$oText1 ERR" & @CRLF ) ConsoleWrite( "$oText1 OK" & @CRLF ) ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $sWG $oWindow1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sWG ) ;its works ConsoleWrite( "NamePropertyId Window = " & $sWG & @CRLF ) Local $sSB $oStatusBar1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sSB ) ;its works ConsoleWrite( "NamePropertyId StatusBar = " & $sSB & @CRLF ) Local $sName1 $oText1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName1 ) ; first method ConsoleWrite( "NamePropertyId Text = " & $sName1 & @CRLF ) Local $sName2 $oText1.GetCurrentPropertyValue( $UIA_LegacyIAccessibleNamePropertyId, $sName2 ) ; friend method ConsoleWrite( "Name2PropertyId Text = " & $sName2 & @CRLF ) local $tName= _UIA_getPropertyValue($oText1, $UIA_NamePropertyId) ; third method ConsoleWrite( "_UIA_getPropertyValue($oText1, $UIA_NamePropertyId) = " & $tName & @CRLF) EndFunc Func _UIA_GetPropertyValue($oElement, $iPropertyID) Local $vRetVal If Not _UIA_IsElement($oElement) Then Return SetError(1, 0, 0) EndIf $oElement.GetCurrentPropertyValue($iPropertyID, $vRetVal) Return $vRetVal EndFunc ;==>_UIA_GetPropertyValue Func _UIA_IsElement($control) Return IsObj($control) ; derp, TODO: check name? EndFunc ;==>_UIA_IsElement Once again, THANK YOU VERY MUCH - it will make my work a lot easier Best regards
  6. Hello. I want to automate the application "PM&FM Tool dla kas FAREX" (https://www.edatapolska.pl/fm/upload/programy/KASY-ONLINE/FM_and_PM_Tool.zip) I need to read text from the "Status bar" window I am using the function GetCurrentPropertyValue but as a result is Null 😪 ONLY this item is Null, other elements correctly (Window, StatusBar -look code and comments and return console SciTe) All code below #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "WindowsForms10.Window.8.app.0.378734a", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Children, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "m_status_strip", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pStatusBar1, $oStatusBar1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition1, $pStatusBar1 ) $oStatusBar1 = ObjCreateInterface( $pStatusBar1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oStatusBar1 ) Then Return ConsoleWrite( "$oStatusBar1 ERR" & @CRLF ) ConsoleWrite( "$oStatusBar1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pText1, $oText1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pText1 ) $oText1 = ObjCreateInterface( $pText1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oText1 ) Then Return ConsoleWrite( "$oText1 ERR" & @CRLF ) ConsoleWrite( "$oText1 OK" & @CRLF ) ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $sWG $oWindow1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sWG ) ;its works ConsoleWrite( "NamePropertyId Window = " & $sWG & @CRLF ) Local $sSB $oStatusBar1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sSB ) ;its works ConsoleWrite( "NamePropertyId StatusBar = " & $sSB & @CRLF ) Local $sName1 $oText1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName1 ) ; NOT WORK return empty string !!! ConsoleWrite( "NamePropertyId Text = " & $sName1 & @CRLF ) EndFunc SciTe console >"C:\Users\viszn\OneDrive\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Users\viszn\OneDrive\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\viszn\OneDrive\_PROJEKTY\AutoIT\UIA\UIASpy_2020-10-15\smietnik.au3" /UserParams +>15:48:36 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000415 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0415) CodePage: 65001 utf8.auto.check:4 +> SciTEDir => C:\Users\viszn\OneDrive\AutoIt3\SciTE UserDir => C:\Users\viszn\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\viszn\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 from:C:\Users\viszn\OneDrive\AutoIt3 input:C:\Users\viszn\OneDrive\_PROJEKTY\AutoIT\UIA\UIASpy_2020-10-15\smietnik.au3 +>15:48:36 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Users\viszn\OneDrive\AutoIt3\autoit3_x64.exe "C:\Users\viszn\OneDrive\_PROJEKTY\AutoIT\UIA\UIASpy_2020-10-15\smietnik.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oWindow1 OK --- Find window/control --- $pCondition1 OK $oStatusBar1 OK --- Find window/control --- $pCondition2 OK $oText1 OK --- Element Properties --- NamePropertyId Window = PRO FM PM Reader Tool ~ Edata Polska 01.07 NamePropertyId StatusBar = statusStrip1 NamePropertyId Text = +>15:48:36 AutoIt3.exe ended.rc:0 +>15:48:37 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.436 How do I get text: "Paragon: 2/55 Zakres: 1-55 Błędy Transmisji Liczyć: 0"? I need this to know what the current preview document is. I attach UIASpy screenshots of all elements of the application, maybe there is another way to read this text? Thank you in advance for your help
  7. Thank you very much for the information @LarsJ I thought there would be a problem, I already started working with Tesseract, but I wanted to check with specialists UIA
  8. Hi I have a question: Is it possible to get the message content from the window? The content of the message is nowhere to be seen (I checked every element and properties) I have an application to handle in which many windows are displayed in this way, and I MUST download the content of the message for verification.
  9. Hello Recently, there was a need to develop an SMS gateway. The machine is supposed to send notifications to employees, the number of sms sent is not much 10-50 a month, so it makes no sense to buy a subscription to the www-sms API. The machine is based on a USB-GSM modem: LC SIM800C V3 (aliexp.. price 3-8$) I used UDF: ComUDF.au3 Thank you mLipok for your work! Below is the program code with an example WARNING! The program is written very extensively (not optimized) - it was created with a novice programmer as part of exercises. But it makes it very understandable (lots of comments) There are ONLY functions here: - modem initialization - sending SMS - deleting received sms (no possibility of reading) Maybe someone will be useful for further experiments with AT commands to communicate with the modem. The biggest challenge for me was the dependence of AT commands in different modem operation modes (instruction AT command for chip SIM800 ONLY 380 pages !) LCSIM800CV3.au3 #include "ComUDF.au3" #include <Array.au3> #include <Timers.au3> Global Const $SMS_NOPL = 0 ; send sms not POLISH characters set the SMS mode "GSM" look AT command AT+CSCS Global Const $SMS_PL = 1 ; send sms with POLISH characters set the SMS mode "HEX" look AT command AT+CSCS ; Write setting from PC with modem USB Global $LCSIM800CV3_sComPort = 'COM3' ; a com port with USB modem, e.g. COM1 Global $LCSIM800CV3_sPortSettings = ' baud=9600 data=8' ; speed settings (for default values see _COM_OpenPort) Global $LCSIM800CV3_hComPort Local $LCSIM800CV3_aPortsList = _COM_ListPorts() ; an array with COM ports ;_ArrayDisplay($LCSIM800CV3_aPortsList) ; displays the ports found in OS _Example() ; example function ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Example ; Description ...: Declaring an array with data to send an SMS (various phone number formats) ; Sending SMS in "HEX" mode ; Sending SMS in "GSM" mode ; Syntax ........: _Example() ; Parameters ....: None ; Return values .: None ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Example() ;MODIFY number phone vvvvvvv and vvvvvvvv Local $aTest[2][2] = [['123456789','Test pl liter: ęóąśłżźćń'],['+48123456789','Test PL liter: ĘÓĄŚŁŻŹĆŃ']] ConsoleWrite('==START send sms mode "HEX" with diacritical character==' & @CRLF) $Return = _SendSMSFromArray($aTest, $SMS_PL) $Error = @error $Extended = @extended If $Error Then ConsoleWrite('$Error: ' & $Error & @CRLF) ConsoleWrite('$Extended: ' & $Extended & @CRLF) ConsoleWrite('$Return: ' & $Return & @CRLF) Else _ArrayDisplay($Return, '$SMS_PL') EndIf ConsoleWrite('==END send sms mode "HEX" with diacritical character==' & @CRLF) ConsoleWrite('==START send sms mode "GSM" only basic alphabet==' & @CRLF) $Return = _SendSMSFromArray($aTest, $SMS_NOPL) $Error = @error $Extended = @extended If $Error Then ConsoleWrite('$Error: ' & $Error & @CRLF) ConsoleWrite('$Extended: ' & $Extended & @CRLF) ConsoleWrite('$Return: ' & $Return & @CRLF) Else _ArrayDisplay($Return, '$SMS_NOPL') EndIf ConsoleWrite('==END send sms mode "GSM" only basic alphabet==' & @CRLF) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SendSMSFromArray ; Description ...: Complete SMS sending function (opening the COM port; modem initialization; ; sending a text message; closing the COM port) ; Syntax ........: _SendSMSFromArray($aTableSMS, $PL) ; Parameters ....: $aTableSMS - an 2D array [NumberPhone_1][TextSMS_1] ; [NumberPhone_n][TextSMS_n] ; $PL - $SMS_NOPL (0) NO PL char send normal text "GSM" ; - $SMS_PL (1) PL char send mode "HEX" ; Return values .: success - input array and add col with status ; [NumberPhone_1][TextSMS_1][status_send _1] ; [NumberPhone_n][TextSMS_n][status_send _n] ; fail - set @error and description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SendSMSFromArray($aTableSMS, $PL) Local $Return, $Error, $Extended, $i $Return = _InitModem($PL) $Error = @error $Extended = @extended If $Error Then _COM_ClosePort($LCSIM800CV3_hComPort) Return SetError(1, 1, '[_SendSMSFromArray] ' & $Return) EndIf _DelAllSMS() _ArrayColInsert($aTableSMS, 2) ; add col to status sending sms For $i=0 to UBound($aTableSMS, $UBOUND_ROWS)-1 $Return = _SendSMS($aTableSMS[$i][0], $aTableSMS[$i][1], $PL) $Error = @error $Extended = @extended If $Error Then $aTableSMS[$i][2] = $Return Else $aTableSMS[$i][2] = 'OK' EndIf Next _COM_ClosePort($LCSIM800CV3_hComPort) Return $aTableSMS EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _InitModem ; Description ...: Open port COM, verify modem reposnse, send command setting SMS mode ; Syntax ........: _InitModem($PL) ; Parameters ....: $PL - 0 no PL character - SMS mode "GSM" ; 1 PL character - SMS mode "HEX" ; Return values .: success - 1 ; failure - set @error and return description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _InitModem($PL) Local $Return, $Error, $Extended $Return = _COM_OpenPort($LCSIM800CV3_sComPort & $LCSIM800CV3_sPortSettings) $Error = @error If $Error Then Return SetError(1, 1, '[_Init] error open port: ' & $LCSIM800CV3_sComPort & $LCSIM800CV3_sPortSettings) EndIf $LCSIM800CV3_hComPort = $Return $Return = __SendToModem('AT') ; ping modem If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT command returned: ' & $Return) EndIf $Return = __SendToModem('ATE0') ; disable "echo" 0= send "AT" received: "OK"; 1= send "AT" received: "AT @CR OK" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - ATE0 command returned: ' & $Return) EndIf $Return = __SendToModem('AT+CMGF=1') ; format wiadomości SMS (0 - PDU, 1 - Text) If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CMGF=1 command returned: ' & $Return) EndIf If $PL=$SMS_NOPL Then $Return = __SendToModem('AT+CSCS="GSM"') ; set mode "GSM" all character is normal text If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSCS=""GSM"" command returned: ' & $Return) EndIf $Return = __SendToModem('AT+CSMP=17,167,0,0') ; additional settings to "GSM" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSMP=17,167,0,0 command returned: ' & $Return) EndIf ElseIf $PL=$SMS_PL Then $Return = __SendToModem('AT+CSCS="HEX"') ; set mode "HEX" all character is hex 4digit If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSCS=""HEX"" command returned: ' & $Return) EndIf $Return = __SendToModem('AT+CSMP=17,167,0,8') ; additional settings to "HEX" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSMP=17,167,0,8 command returned: ' & $Return) EndIf Else Return SetError(1, 2, '[_Init] incorrect parameter $PL:' & $PL) EndIf Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DelAllSMS ; Description ...: Deletes all received sms ; Syntax ........: _DelAllSMS() ; Parameters ....: None ; Return values .: success - 1 ; failure - set @error and return description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _DelAllSMS() $Return = __SendToModem('AT+CMGDA="DEL ALL"') ; send command AT delete all sms and receives text "OK" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 1, '[_DelAllSMS] SMS erase error - AT+CMGDA="DEL ALL" command returned: ' & $Return) EndIf Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SendSMS ; Description ...: Send sms. Restriction of sending to the country POLAND (+48) ; Syntax ........: _SendSMS($sPhoneNumber, $sSMS, $PL) ; Parameters ....: $sPhoneNumber - a string value. ; $sSMS - a string value. ; $PL - 0=no PL character - SMS mode "GSM"; 1=PL character - SMS mode "HEX" ; Return values .: success - 1 ; failure - set @error and return description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SendSMS($sPhoneNumber, $sSMS, $PL) Local $Return, $Error, $Extended ;verifying and modifying of the telephone number $sPhoneNumber = StringRegExpReplace($sPhoneNumber, "\D", '') If Not StringLen($sPhoneNumber) = 9 Or Not StringLen($sPhoneNumber) = 11 Then ;Number MUST 9 or 11 digit Return SetError(1, 9, '[_SendSMS] wrong phone number: ' & $sPhoneNumber) EndIf ;START ONLY country +48 ;NOTE this section allows you to send text messages only to the area code PL ;CHANGE 48 with your country code or delete this part If StringLen($sPhoneNumber) = 9 Then $sPhoneNumber = '+48' & $sPhoneNumber ; ElseIf StringLen($sPhoneNumber) = 11 Then If StringLeft($sPhoneNumber, 2) <> '48' Then Return SetError(1, 9, '[_SendSMS] wrong phone area code: ' & $sPhoneNumber) Else $sPhoneNumber = '+' & $sPhoneNumber EndIf EndIf ;END ONLY country +48 ;verifying and modifying of the text sms If StringLen($sSMS) > 250 Then Return SetError(1, 10, '[_SendSMS] the content of the SMS exceeds 250 characters: ' & StringLen($sSMS)) EndIf ;sending SMS ;step 1 -send phone number & <CR> $Return = __SendToModem('AT+CMGS="' & $sPhoneNumber & '"') ; send command AT & number and receives char ">" If StringInStr($Return, '>') = 0 Then Return SetError(1, 1, '[_SendSMS] modem communication error - command AT+CMGS="' & $sPhoneNumber & '": ' & $Return) EndIf ;step 2 - send text sms & <ESC> / Ctrl+Z If $PL=$SMS_PL Then ; convert to HEX with PL char $sSMS = Hex(StringToBinary($sSMS, $SB_UTF16BE)) ElseIf $PL=$SMS_NOPL Then ; $SMS_NOPL $sSMS = __ReplacePLChar($sSMS) ; if "GSM" then normal text and replace ą=>a etc. Else Return SetError(1, 1, '[_SendSMS] incorrect parameter $PL:' & $PL) EndIf $Return = __SendToModem($sSMS, Chr(26)) ;send text and Ctrl-Z If StringInStr($Return, 'ERROR') > 0 Then Return SetError(1, 2, '[_SendSMS] modem communication error - command AT+CSCS="GSM" returned: ' & $Return) ElseIf StringInStr($Return, '+CMGS:') > 0 And StringInStr($Return, 'OK') > 0 Then Return 1 Else Return SetError(1, 3, '[_SendSMS] communication error with modem - unknown answer: ' & $Return) EndIf EndFunc Func __SendToModem($sText, $sEnter=Chr(13)) Local $Return, $Error, $hTimerStart If $sEnter <> Chr(13) And $sEnter <> Chr(26) Then Return SetError(1, 10, '[__SendToModem] argument value not allowed $sEnter: ' & $sEnter) EndIf $Return = _COM_SendString($LCSIM800CV3_hComPort, $sText & $sEnter) $Error = @error If $Error Then Return SetError(1, 1, '[__SendToModem][_COM_SendString] it returned an error: ' & $Error) EndIf Sleep(500) ; wait 500ms to allow the receive buffer to fill up $hTimerStart = _Timer_Init() Do Do Sleep(100) $Return = _COM_GetInputcount($LCSIM800CV3_hComPort) $Error = @error If $Error Then Return SetError(1, 1, '[__SendToModem][_COM_GetInputcount] it returned an error: ' & $Error) EndIf $iCount = $Return If _Timer_Diff($hTimerStart) > 61*1000 Then ;WARNING! Must be> 60 sec - instruction from modem: "Max response time send sms: 60s" Return SetError(1, 1, '[__SendToModem][_COM_GetInputcount] no answer from modem for 60 seconds') EndIf Until $iCount > 0 $Return = _COM_ReadString($LCSIM800CV3_hComPort, $iCount) $Error = @error If $Error Then Return SetError(1, 1, '[__SendToModem][_COM_ReadString] it returned an error: ' & $Error) EndIf Until StringInStr($Return, '+CMTI: "')=0 ; we omit modem responses informing about receiving an SMS Return $Return EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __ReplacePLChar ; Description ...: Replace polish characters to NO polish ; Syntax ........: __ReplacePLChar($sText) ; Parameters ....: $sText - a string value. ; Return values .: String no polish character ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __ReplacePLChar($sText) $sText = StringReplace($sText, 'Ą', 'A', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ą', 'a', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ć', 'C', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ć', 'c', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ę', 'E', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ę', 'e', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ł', 'L', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ł', 'l', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ń', 'N', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ń', 'n', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ó', 'O', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ó', 'o', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ś', 'S', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ś', 's', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ź', 'Z', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ź', 'z', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ż', 'Z', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ż', 'z', 0, $STR_CASESENSE) Return $sText EndFunc
  10. Welcome My problem is the same objects . I have an intranet page where I have to click on the next links in the table. The identification of the link objects is not different. UIA always finds the first object in which to indicate the next link? The table that I serve has 200 rows. I can not put screenshots (confidential data). To show what the problem I have created, the test.html and Simple UIA Spy code test.html How do you click View in the Piotr line? #include-once #include<UIAWrappers.au3> Global $WindowChromePID $sLink = @ScriptDir & "\test.html" If FileExists("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe") Then $WindowChromePID = Run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --force-renderer-accessibility " & $sLink) ElseIf FileExists("C:\Program Files\Google\Chrome\Application\chrome.exe") Then $WindowChromePID = Run("C:\Program Files\Google\Chrome\Application\chrome.exe --force-renderer-accessibility " & $sLink) Else MsgBox(8192+16, "Error","Chrome.exe not found") EndIf Sleep(5000) _UIA_setVar("oP1","Title:=test.html - Google Chrome;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1") ;test.html - Google Chrome _UIA_setVar("oP2","Title:=;controltype:=UIA_DocumentControlTypeId;class:=Chrome_RenderWidgetHostHWND") ; _UIA_setVar("oP3","Title:=;controltype:=UIA_TableControlTypeId;class:=") ; _UIA_setVar("oP4","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP5","Title:=View;controltype:=UIA_DataItemControlTypeId;class:=") ;View _UIA_setVar("oP6","Title:=View;controltype:=UIA_HyperlinkControlTypeId;class:=") ;View ;~ $oUIElement=_UIA_getObjectByFindAll("View.mainwindow", "title:=View;ControlType:=UIA_TextControlTypeId", $treescope_subtree) _UIA_setVar("oUIElement","Title:=View;controltype:=UIA_TextControlTypeId;class:=") ;ControlType:=UIA_TextControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles _UIA_Action("oP1","highlight") ;~ _UIA_Action("oP1","setfocus") _UIA_Action("oP2","highlight") ;~ _UIA_Action("oP2","setfocus") _UIA_Action("oP3","highlight") ;~ _UIA_Action("oP3","setfocus") _UIA_Action("oP4","highlight") ;~ _UIA_Action("oP4","setfocus") _UIA_Action("oP5","highlight") ;~ _UIA_Action("oP5","setfocus") _UIA_Action("oP6","highlight") ;~ _UIA_Action("oP6","setfocus") ;~ _UIA_action("oUIElement","highlight") _UIA_action("oUIElement","click") Screen from MS Inspect
  11. Hello. I create a function that saves the log to an html file. File html are included picture (conversion to Base64) Everything works OK. But I do the actions: screenshot to the png file (smaller than bmp) per disk ( _ScreenCapture_Capture(@ScriptDir & "\screenshot.png") ) convert image from disk to base64 I need help to optimize the script: - screenshot to memory (do not save to disk) - convert this object to png in memory - invoking the conversion of png image from memory to base64 The first step _ScreenCapture_Capture("") create handle to an HBITMAP in memory How to convert image in memory to png? How to use Func _ConvertToBase64 I attach my code #include <ScreenCapture.au3> #include <Date.au3> Global $RaportFileName = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC & ".html" $text = "This is first line text" & @CRLF &"and this is next line" _Raport($text, 1) FileWrite(@ScriptDir & "\" & $RaportFileName, "</pre></html>") ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Raport ; Description ...: ; Syntax ........: _Raport($sText1[, $Screen = 0]) ; Parameters ....: $sText1 - a string value. ; $Screen - [optional] an unknown value. Default is 0. ; 0 - Default - do not screenshot ; 1 - added screenshot full desktop ; Return values .: None ; Author ........: Your Name ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Raport($sText1, $Screen=0) Local $sText = "" Local $sHead = "" ; Define HTML file header and style $sHead = '<html>' & @CRLF & '<head><meta charset="utf-8"></head>' & @CRLF $sHead = $sHead & '<style>img{border:3px solid #FF0000;}</style>' & @CRLF $sHead = $sHead & '<style>pre{font-family: monospace;}</style>' & @CRLF $sHead = $sHead & '<style>pre{font-size: large;}</style>' & @CRLF $sHead = $sHead & '<pre>' & @CRLF If NOT FileExists(@ScriptDir & "\" & $RaportFileName) Then ; If file Raport not exist then create FileOpen(@ScriptDir & "\" & $RaportFileName, 258) FileWrite(@ScriptDir & "\" & $RaportFileName, $sHead) EndIf If StringInStr($sText1, @CRLF) > 0 Then ; @CRLF (ENTER) change the @CRLF and 11 space (indentation on width "[GG:MM:SS] ") $sText1 = StringReplace($sText1, @CRLF, @CRLF & '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;') EndIf $sText = $sText & $sText1 If $Screen <> 0 Then _ScreenCapture_Capture(@ScriptDir & "\screenshot.png") $sText = $sText & @CRLF & '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' & '<img src="data:image/png;base64,' & _ConvertToBase64(@ScriptDir & "\screenshot.png") & '"/>' EndIf FileWrite(@ScriptDir & "\" & $RaportFileName, "[" & _NowTime(5) & "]&nbsp;" & $sText & "<br><br>"&@CRLF) ; write to file Raport EndFunc Func _ConvertToBase64($fFile) ;Xroot 2011 ;ClipPut("") ;$FN=@ScriptDir & "\screenshot.png" $FN=$fFile $dat=FileRead(FileOpen($FN,16)) $objXML=ObjCreate("MSXML2.DOMDocument") $objNode=$objXML.createElement("b64") $objNode.dataType="bin.base64" $objNode.nodeTypedValue=$dat ClipPut("") $Wynik = "" ;ClipPut($objNode.Text) $Wynik = $objNode.Text Return $Wynik EndFunc P.S. Excuse me my not good English.
  12. In PostgreSQL syntax Select * from "TEST" result ############################### ADO.au3 v.2.1.15 BETA (1286) : ==> COM Error intercepted ! $oADO_Error.description is: B£¥D: relacja "TEST" nie istnieje; Error while executing the query $oADO_Error.windescription: Wyst¹pi³ wyj¹tek. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 1286 $oADO_Error.source is: Microsoft OLE DB Provider for ODBC Drivers $oADO_Error.helpfile is: $oADO_Error.helpcontext is: 0 ############################### The server PostgreSQL works like this look results select in psql.exe bazaviszna=# select * from "TEST"; BŁĄD: relacja "TEST" nie istnieje LINIA 1: select * from "TEST"; ^ bazaviszna=# select * from TEST; id | url | name | description | rel ----+-----------------------------------+---------------------+-------------+----- 1 | http://www.postgresqltutorial.com | PostgreSQL Tutorial | | (1 wiersz) bazaviszna=# select * from "TEST 123"; pesel | nr_zam -------------+---------------------------------------------------- abc | 1234 (1 wiersz) bazaviszna=# select * from TEST 123; BŁĄD: błąd składni w lub blisko "123" LINIA 1: select * from TEST 123; ^ Solution Remember to use " " in tablename 2 words and space Remember to NOT use " " in tablename 1 word
  13. Hey I'm just testing ADO.au3 Database server: MS Windows 10 / 64bit Database: PostgreSQL 11 Version: PostgreSQL 11.1, compiled by Visual C++ build 1914, 64-bit In the ADO_EXAMPLE.au3 file in Func _Example_PostgreSQL () I observed an interesting problem. If tablename is 1 word the name then can not be used " _Example_2_RecordsetDisplay($sConnectionString, 'Select * from "TEST"') - INCORRECT _Example_2_RecordsetDisplay($sConnectionString, 'Select * from TEST') - correct If tablename is 2 words + space the name then MUST be used " _Example_2_RecordsetDisplay($sConnectionString, 'Select * from "TEST 123"') -correct _Example_2_RecordsetDisplay($sConnectionString, 'Select * from TEST 123') - INCORRECT In the ADO_EXAMPLE.au3 file in Func _Example_PostgreSQL () lines 193 need to be improved _Example_1_RecordsetToConsole($sConnectionString, 'Select * from SOME_TABLE') Console from examples +++++++++++++++++++++++++++++++++++++++++++++++++ tablename 1 word, Select * from "TEST" ############################### ADO.au3 v.2.1.15 BETA (1286) : ==> COM Error intercepted ! $oADO_Error.description is: B£¥D: relacja "TEST" nie istnieje; Error while executing the query $oADO_Error.windescription: Wyst¹pi³ wyj¹tek. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 1286 $oADO_Error.source is: Microsoft OLE DB Provider for ODBC Drivers $oADO_Error.helpfile is: $oADO_Error.helpcontext is: 0 ############################### +++++++++++++++++++++++++++++++++++++++++++++++++ tablename 1 word, Select * from TEST ================================================================== 1 http://www.postgresqltutorial.com PostgreSQL Tutorial +++++++++++++++++++++++++++++++++++++++++++++++++ tablename 2 words, Select * from "TEST 123" ================================================================== abc 1234 +++++++++++++++++++++++++++++++++++++++++++++++++ tablename 2 words, Select * from TEST 123 ############################### ADO.au3 v.2.1.15 BETA (1286) : ==> COM Error intercepted ! $oADO_Error.description is: B£¥D: b³¹d sk³adni w lub blisko "123"; Error while executing the query $oADO_Error.windescription: Wyst¹pi³ wyj¹tek. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 1286 $oADO_Error.source is: Microsoft OLE DB Provider for ODBC Drivers $oADO_Error.helpfile is: $oADO_Error.helpcontext is: 0 ###############################
  14. @BigDaddyOnice splash -cool solution for informing the user about the action but it works badly if Windows taskbar is left, right or top desktop (small problem I know only 1 person works with Windows taskbar top desktop )
  15. Hi I automated putty (application UNIX). Each screen change is copying to the clipboard and further operations on the string You need to find out how to configure PuTTs, and then it's easy to function below: - takes the entire screen to the clipboard - get from clipboard to the string - completes each line up to 80 characters - returns the string My configuring PuTTY (80 columns x 24 rows) ;REMEMBER ! before calling the function ; WinActivate ( "title" [, "text"] ) PuTTY window!!! ; how do you do a lot of screen ; it works faster SendKeepActive ( "title" [, "text"] ) Func _Screen() Send("!{SPACE}o") Sleep(300) $PobranyEkran = "" $PobranyEkran = ClipGet() If StringLen($PobranyEkran) < 5 Then ; If it is shorter than 5 characters, copy again Send("!{SPACE}o") Sleep(300) $PobranyEkran = ClipGet() EndIf ;For easy operations on the string ;each line is completed with the same length of 80 characters Dim $a_PobranyEkran [0] $a_PobranyEkran = StringSplit($PobranyEkran,@CRLF,3) ReDim $a_PobranyEkran[24] $PobranyEkran = "" For $i=0 to 23 $a_PobranyEkran[$i] = $a_PobranyEkran[$i] & " " $a_PobranyEkran[$i] = StringLeft($a_PobranyEkran[$i],80) & @CRLF $PobranyEkran = $PobranyEkran & $a_PobranyEkran[$i] Next Return $PobranyEkran EndFunc ;==>_Screen
×
×
  • Create New...