Leaderboard
Popular Content
Showing content with the highest reputation on 07/01/2020 in all areas
-
Hey guys! Here are some informations on how to automate AS400 tasks with AutoIT. AS400 are mainframes made by IBM and used mainly in professional workplaces. First you need to launch an IBM Iseries console to the AS400. It looks like this: As it is a regular window, you can use the "AutoIT Window Info" tool and functions like "ControlSetText", "ControlClick" to automate the login process. Notice that the name of the window (in the top left of the above screenshot) is "Session A". This is because it is the first Iseries window that is opened on the client computer. If you do not close it and open another one, the next one will be named "Session B". The third one "Session C"... Once you're logged into the Iseries console interface, the OS400 login window shows up: Use this code to create an autoIT object linked to the iseries console: global $oOIA = ObjCreate("PCOMM.autECLOIA") $oOIA.SetconnectionByName("A") global $oPS = ObjCreate("PCOMM.autECLPS") $oPS.SetConnectionByName("A") The letter "A" is a reference to the name of the session displayed in the iseries console window, as explained before. Change it to another letter if you have multiples iseries console windows opened at the same time. Then there are 3 main functions that you can use to interact with the interface: $oOIA.WaitForInputReady() ;waits for the interface to be ready for input. $oPS.SetCursorPos(6, 53) ;put the cursor of the interface to position X = 6, Y = 53 $oPS.SendKeys("hello world[enter]") ;write the text "hello world" where the cursor of the interface is then press the enter/return key $result = $oPS.SearchText("banana") ;search for the text "banana" on the interface screen. Returns "True" if found, "False" if not. The function "WaitForInputReady" is badfully not very reliable. For better results, use the fuction "SearchText" in a while loop to wait for a specific text to appear on the interface if you want to be sure that the interface is ready for input. With these 3 functions you can pretty much do anything you would do manually on an Iseries console. Special keys for the "SendKeys" function can be found using the virtual keyboard included in the iseries console software. Enjoy Original post (credit to @DangerousDan and @bwochinski) for helping me understand the above stuff ^^):1 point
-
need help to create a treeview linked with array
MesterPerfect reacted to Nine for a topic
What is up with you two ?1 point -
need help to create a treeview linked with array
MesterPerfect reacted to nacerbaaziz for a topic
@junkew did you read his question?1 point -
Try current Beta which should have a fix for that.1 point
-
The proposed patch works nicely and is pretty strait forward, it just needs a small change to get rid of a warning..... hope Neil accepts it.1 point
-
It's taken some time to go through various test. Thanks for your patience. The primary purpose for this function was to be able to get the final output volume of a stream, after DSP processing. This includes VST's. On a recording stream, this doesn't seem to be an issue. But on a playing stream, it's quite a different thing. When _BASS_ChannelGetLevel() is used to get levels on a play stream, it's not doing it at the final output of the stream. It's doing it at some hardcoded FX Pin earlier in it. Not really sure why the BASS developers did this, but there is a way to get that reading at the final output according to this post: http://www.un4seen.com/forum/?topic=18949.0 So, I tested various ways to accomplish getting that reading. I found that setting a Volume FX at low priority works. Afterwards, I needed to work out a few things in the main script to accommodate the new function. It turned out very well. I'm very happy with it. Okay, let's talk about what works and what doesn't. Nine, I couldn't get your code to work on a 32bit machine, using AutoIt 3.3.8.1 (32bit). I needed it to be compatible back to that version. It probably works fine on a 64bit machine using a more up-to-date version of AutoIt. I was having other problems in 32bit mode, with obtaining the levels using the object method. It would soft crash saying: "variable must be of type object" After I changed the Danyfirex code and UEZ code to DllStructGetData() -- they both worked. I used code lines from both of them to put together what was suitable for me on the project I'm working on, and added some of my own. Here is the result: ; #CUSTOM FUNCTION# =================================================================================================== ; .......Name.: _BASS_ChannelGetLevelEx($hStream, $fLength, $iFlag) ; Description.: Gets the volume level on a play or record stream and is more flexible than _BASS_ChannelGetLevel(). ; DLL Version.: BASS.DLL v2.4.15.0 ; ............: ; .Parameters.: $hStream - The handle returned by _BASS_RecordStart, _BASS_StreamCreateFile, RecordStart from BASS_CB.dll ; ............: $fLength - The amount of data to inspect to calculate the level, in seconds. Default = 20ms, Maximum = 1sec. ; ............: $iFlag - BASS_LEVEL_MONO = 1, BASS_LEVEL_STEREO = 2 (Default), BASS_LEVEL_RMS = 4, BASS_LEVEL_VOLPAN = 8 ; ............: ; ....Returns.: Success - Returns the volume level 0 to 100+ (this level is not clipped, so it could exceed 100 easily) ; ............: Failure - sets @error ; ............: ; .....Author.: ripdad (June 30, 2020) Thanks to Danyfirex and UEZ for their help in the making of this function. ; ...Modified.: ; ............: ; ....Remarks.: To get final output volume level for a stream, you must place an FX with priority = 0 on the stream. ; ............: See: _BASS_ChannelSetVolumeFX() and _BASS_FXSetVolumeParameters() ; ............: ; .......Link.: http://www.un4seen.com/doc/#bass/BASS_ChannelGetLevelEx.html ; ....Related.: _BASS_ChannelGetLevel ;====================================================================================================================== Func _BASS_ChannelGetLevelEx($hStream, $fLength = 0.02, $iFlag = 2) Local $tLevels = DllStructCreate('float fLeftLevel;float fRightLevel') Local $aResult = DllCall($_ghBassDll, 'bool', 'BASS_ChannelGetLevelEx', 'dword', $hStream, 'struct*', $tLevels, 'float', $fLength, 'dword', $iFlag) If @error Then Return SetError(1, 1, 0) If $aResult[0] = 0 Then Return SetError(_BASS_ErrorGetCode(), 0, 0) Local $nLeftLevel = Round(DllStructGetData($tLevels, 'fLeftLevel') * 100) Local $nRightLevel = Round(DllStructGetData($tLevels, 'fRightLevel') * 100) If $iFlag = 1 Then $nRightLevel = $nLeftLevel Return StringFormat('%02i%02i', $nLeftLevel, $nRightLevel) EndFunc To access the return from this function: $LeftCH = StringLeft($iLevels, 2) and $RightCH = StringRight($iLevels, 2) I want to thank everyone who pitched in on this effort. I appreciate it very much.1 point
-
For someone who is obviously so new to scripting, I don't understand your requirement that the comparison of the valid values be a one-liner. I would think that it is more important to learn the different ways that it can be done, regardless of the number of lines. The example below, using Nine's suggestion to use an array for your valid values, does the reading of the value and the comparison for valid values all in one line (Go1). Go2 & Go3 show other ways to do the same thing. #include <GUIConstantsEx.au3> #include <Constants.au3> #include <Array.au3> Const $aValues = ["1012", "1221", "1411"] Global $Form1 = GUICreate("Form1", 376, 197, 192, 124) Global $Input1 = GUICtrlCreateInput("", 80, 64, 193, 21) Global $Go = GUICtrlCreateButton("GO", 80, 120, 113, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Go Go1() ;Using _ArraySearch ;Go2() ;Using If ;Go3() ;Using Switch EndSwitch WEnd Func Go1() If _ArraySearch($aValues, GUICtrlRead($input1)) <> -1 Then MsgBox(0,'','YES') Else MsgBox(0,'','NO') EndIf EndFunc Func Go2() Local $sInput = GUICtrlRead($input1) If $sInput = "1012" Or $sInput = "1221" Or $sInput = "1411" Then MsgBox(0,'','YES') Else MsgBox(0,'','NO') EndIf EndFunc Func Go3() Switch GUICtrlRead($input1) Case "1012", "1221", "1411" MsgBox(0,'','YES') Case Else MsgBox(0,'','NO') EndSwitch EndFunc1 point
-
You need 2 scripts. The first will generate the binary passwords. The second (the one you have written) will use the encrypted password. I have put the 2 scripts into a single one for simplicity. #include <Crypt.au3> _Crypt_Startup() ;script 1 (script to generate encrypt password) Local $password = InputBox("Encryption", "Enter password") If @error Then Exit Local $result = _Encrypt("password", $password) MsgBox($MB_SYSTEMMODAL, "", $result) ; ClipBoard now contains the binary password : paste it into your script or save it into a file or registry ;script 2 (script to use encrypted password) Local $sPasswordCT = ClipGet() ; replace ClipGet with the binary string or read it from a file or registry Local $sJoinDomainPassword = _Decrypt("password", $sPasswordCT) MsgBox(0, "Password", "Admin password: " & $sJoinDomainPassword) _Crypt_Shutdown() Func _Decrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $sDecrypted = BinaryToString(_Crypt_DecryptData(Binary($sData), $hKey, $CALG_USERKEY)) _Crypt_DestroyKey($hKey) Return $sDecrypted EndFunc ;==>_Decrypt Func _Encrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $sEncrypted = _Crypt_EncryptData($sData, $hKey, $CALG_USERKEY) _Crypt_DestroyKey($hKey) ClipPut($sEncrypted) Return $sEncrypted EndFunc ;==>_Encrypt1 point
-
@Andreik somehow this problem has never left me. I didn't want to use a loop to check step by step the best fit for the text. #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sString, $iFontSize Local $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2 $hGUI = GUICreate("GDI+", $iW, $iH) ;, 0, 0, 0x80000000) GUISetState(@SW_SHOW) $sString = 'Take this kiss upon the brow!' & @CRLF $sString &= 'And, in parting from you now,' & @CRLF $sString &= 'Thus much let me avow--' & @CRLF $sString &= 'You are not wrong, who deem' & @CRLF $sString &= 'That my days have been a dream;' & @CRLF $sString &= 'Yet if hope has flown away,' & @CRLF $sString &= 'In a night, or in a day,' & @CRLF $sString &= 'In a vision, or in none,' & @CRLF $sString &= 'Is it therefore the less gone?' & @CRLF $sString &= 'All that we see or seem' & @CRLF $sString &= 'Is but a dream within a dream.' _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $tLayout = _GDIPlus_RectFCreate(20, 20, $iW - 40, $iH - 40) $iFontSize = Measure($sString, $iW - 40, $iH - 40) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iFontSize = ' & $iFontSize & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize ) ; <<< Adjust font size _GDIPlus_GraphicsClear($hGraphic) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush) $hPen = _GDIPlus_PenCreate(0xFF00F000) _GDIPlus_GraphicsDrawRect($hGraphic, $tLayout.x, $tLayout.y, $tLayout.width, $tLayout.height, $hPen) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_PenDispose($hPen) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Func Measure($sString, $iW, $iH, $sFont = "Arial", $iStyle = 0, $iFormat = 0) Local Const $hFormat = _GDIPlus_StringFormatCreate($iFormat) Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local Const $iFontSize = 1 Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iStyle) Local Const $hGraphics = _GDIPlus_GraphicsCreateFromHDC(_WinAPI_GetWindowDC(0)) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) Local Const $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphics) If ($iH / $aInfo[0].height) * $aInfo[0].width > $iW Then Return ($iW / $aInfo[0].width) Return ($iH / $aInfo[0].height) EndFunc I made several test and it worked properly so far. Can you check please again? Thx.1 point
-
Hi Danp2, Thank you very much on the inputs. Really informative and helped me a lot. I will play around on the functions you suggested. Thank you!1 point
-
For elements, take a look at _WD_ElementAction, which you can use to retrieve the properties and attributes of an element you previously located with _WD_FindElement. For the entire page, there's _WD_GetSource, but I'm not sure that will give you what you want.1 point
-
Hi Danp2, I would like to learn both if you have the function that I can check into. Thank you in advance.1 point
-
Yes, but you'll need to be be more specific. Do you want to retrieve the innertext of the entire page or from a single element?1 point
-
Hi Dan, It is working perfectly now! Thank you very much! You're the Man Bro! I have another query, if you have a function that will do web scraping of innertext from a web page. Thank you.1 point
-
Here is my ErrorLog.au3 UDF which I use every day. ErrorLog.au3 UDF is for log program activities and errors, to different output with possibility to switch output function instantly. UDF: #include-once #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel ; #AutoIt3Wrapper_Run_Debug_Mode=Y Global $__g_bUDF_ERRORLOG_FORCE_DEBUG = False Global $__g_sUDF_ERRORLOG_PREFIX = '--> ' Global $__g_sUDF_ERRORLOG_PREFIX_SUCCESS = '+ ' Global $__g_sUDF_ERRORLOG_PREFIX_EXTENDED = '- ' Global $__g_sUDF_ERRORLOG_PREFIX_ERROR = '! ' #Region ErrorLog.au3 - UDF Header ; #INDEX# ======================================================================================================================= ; Title .........: ErrorLog.au3 UDF - A logging Library ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: ErrorLog.au3 UDF is for log program activities and errors, to different output with possibility to switch output function instantly ; Author(s) .....: mLipok ; Modified ......: ; URL ...........: https://www.autoitscript.com/forum/topic/195882-errorlogau3-a-logging-library/ ; =============================================================================================================================== #cs UDF ChangeLog 2018/10/11 v1.0 * Added: UDF #INDEX# - mLipok * Added: UDF ChangeLog - mLipok * Added: Function: _Log_Errors_Reset() - mLipok * Renamed: Function: _Log_Errors() >> _Log_OnError() - mLipok * Changed: Function: better documentation in function headers - mLipok * Added: ErrorLog__Example.au3 - _Log_Example_1() , _Log_Example_2(), _Log_Example_3() - mLipok 2018/10/12 v1.1 * Added: Function: __Log_Wrapper() - a wrapper which put report to the output function - mLipok * Changed: Function: _Log_SetOutputFunction(Default) - return only function in any other case fires @error - mLipok * Refactored: Function: _Log() - mLipok * Refactored: Function: _Log_OnError() - mLipok * Added: GLOBAL: $__g_bUDF_ERRORLOG_FORCE_DEBUG - mLipok * Added: GLOBAL: $__g_sUDF_ERRORLOG_PREFIX_EXTENDED - mLipok * Added: GLOBAL: $__g_sUDF_ERRORLOG_PREFIX_SUCCESS - mLipok * Changed: GLOBAL: $__g_sUDF_ERRORLOG_ERROR_PREFIX >> $__g_sUDF_ERRORLOG_PREFIX_ERROR - mLipok * Added: Function: _Log_OnSuccess() - Log report to the output function but only if @error was not fired - mLipok * Added: Function: _Log_OnExtended() - Log report to the output function but only if @extended is set and @error was not fired - mLipok * Added: Function: _Log_Debug() - Log report to the output function but only if _Log_SetDebugMode(True) was used - mLipok * Added: Function: _Log_SetDebugMode() - Set the _Log_Debug() ON/OFF - mLipok * Changed: Function: much better documentation in function headers - mLipok * Added: UDF: #Region <> #EndRegion - mLipok * Added: UDF: #Tidy_Parameters=/sort_funcs /reel * Added: ErrorLog__Example.au3 - $__g_bUDF_ERRORLOG_FORCE_DEBUG - _Log_SetDebugMode() - mLipok * Added: ErrorLog__Example.au3 - _Log_Debug() - mLipok @LAST CHANGE LOG #ce UDF ChangeLog #EndRegion ErrorLog.au3 - UDF Header #Region ErrorLog.au3 - Functions ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log ; Description ...: Log report to the output function ; Syntax ........: _Log($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log($sText = '', $iError = @error, $iExtended = @extended) __Log_Wrapper( _ (($iError Or $iExtended) ? ($__g_sUDF_ERRORLOG_PREFIX_ERROR & '[ ' & $iError & ' / ' & $iExtended & ' ] : ') : ($__g_sUDF_ERRORLOG_PREFIX)) _ & $sText _ ) Return SetError($iError, $iExtended) EndFunc ;==>_Log ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Change ; Description ...: Log report to the output function but only if @error or @extended occurs OR if reported data has changed ; Syntax ........: _Log_Change([$sText = ''[, $iError = @error[, $iExtended = @extended]]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. ; $iExtended - [optional] an integer value. Default is @extended. ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if there is no change and no message, or if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Change($sText = '', $iError = @error, $iExtended = @extended) Local Static $sText_static = '' Local Static $iError_static = 0 Local Static $iExtended_static = 0 If $sText <> '' Or $iError Or $iExtended And _ ($sText_static <> $sText Or $iError_static <> $iError Or $iExtended_static <> $iExtended) _ Then _Log($sText, $iError, $iExtended) $sText_static = $sText $iError_static = $iError $iExtended_static = $iExtended EndIf Return SetError($iError, $iExtended) EndFunc ;==>_Log_Change ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Debug ; Description ...: Log report to the output function but only if _Log_SetDebugMode(True) was used ; Syntax ........: _Log_Debug($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Debug($sText, $iScriptLineNumber = @ScriptLineNumber, $iError = @error, $iExtended = @extended) If $__g_bUDF_ERRORLOG_FORCE_DEBUG == True Then __Log_Wrapper('@@ Debug(' & $iScriptLineNumber & ') : [ ' & $iError & ' / ' & $iExtended & ' ] : ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_Debug ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Errors_Reset ; Description ...: Resetting @error and @extended to 0 ; Syntax ........: _Log_Errors_Reset() ; Parameters ....: None ; Return values .: None - and set @error and @extended to 0 ; Author ........: mLipok ; Modified ......: ; Remarks .......: this is only wrapper for SetError(0, 0) ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Errors_Reset() Return SetError(0, 0) EndFunc ;==>_Log_Errors_Reset ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Errors_ReStore ; Description ...: Restore previously stored @error and @extended ; Syntax ........: _Log_Errors_ReStore() ; Parameters ....: None ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log_Errors_Store ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Errors_ReStore() _Log_Errors_Store(Default, Default) Return SetError(@error, @extended) EndFunc ;==>_Log_Errors_ReStore ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Errors_Store ; Description ...: Store @error and @extended ; Syntax ........: _Log_Errors_Store([$iError = @error[, $iExtended = @extended]]) ; Parameters ....: $iError - [optional] an integer value. Default is @error. ; $iExtended - [optional] an integer value. Default is @extended. ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log_Errors_ReStore ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Errors_Store($iError = @error, $iExtended = @extended) Local Static $iError_static = 0, $iExtended_static = 0 If $iError = Default And $iExtended = Default Then $iError = $iError_static $iExtended = $iExtended_static $iError_static = 0 $iExtended_static = 0 Return SetError($iError, $iExtended) EndIf $iError_static = $iError $iExtended_static = $iExtended Return SetError($iError, $iExtended) EndFunc ;==>_Log_Errors_Store ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_OnError ; Description ...: Log report to the output function but only if @error occurs ; Syntax ........: _Log_OnError($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_OnError($sText, $iError = @error, $iExtended = @extended) If $iError Then __Log_Wrapper($__g_sUDF_ERRORLOG_PREFIX_ERROR & '@error=' & $iError & ' @extended=' & $iExtended & ' :: ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_OnError ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_OnExtended ; Description ...: Log report to the output function but only if @extended is set and @error was not fired - mLipok ; Syntax ........: _Log_OnExtended($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_OnExtended($sText, $iError = @error, $iExtended = @extended) If $iExtended And $iError = 0 Then __Log_Wrapper($__g_sUDF_ERRORLOG_PREFIX_EXTENDED & '[ ' & $iError & ' / ' & $iExtended & ' ] : ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_OnExtended ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_OnSuccess ; Description ...: Log report to the output function but only if @error was not fired ; Syntax ........: _Log_OnSuccess($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_OnSuccess($sText, $iError = @error, $iExtended = @extended) If $iError = 0 Then __Log_Wrapper($__g_sUDF_ERRORLOG_PREFIX_SUCCESS & '[ ' & $iError & ' / ' & $iExtended & ' ] : ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_OnSuccess ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_SetDebugMode ; Description ...: Set the _Log_Debug() ON/OFF ; Syntax ........: _Log_SetOutputFunction($bForceDebug) ; Parameters ....: $bForceDebug - a boolean value. True=ON, False=OFF for _Log_Debug() ; Return values .: none or set @error to 1 ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log_Debug ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_SetDebugMode($bForceDebug) If Not IsBool($bForceDebug) Then Return SetError(1) $__g_bUDF_ERRORLOG_FORCE_DEBUG = $bForceDebug EndFunc ;==>_Log_SetDebugMode ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_SetOutputFunction ; Description ...: Set the function to which Log reports should be passed ; Syntax ........: _Log_SetOutputFunction([$fnFunction = Default]) ; Parameters ....: $fnFunction - [optional] a floating point value. Default is Default. ; Return values .: $fnFunction_static - saved output function, in any other case fires @error ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_SetOutputFunction($fnFunction = Default) Local Static $fnFunction_static = Null If $fnFunction = Default And IsFunc($fnFunction_static) Then Return $fnFunction_static If Not IsFunc($fnFunction) Then Return SetError(1) $fnFunction_static = $fnFunction Return $fnFunction_static EndFunc ;==>_Log_SetOutputFunction #EndRegion ErrorLog.au3 - Functions #Region ErrorLog.au3 - Internal Functions ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __Log_Wrapper ; Description ...: a wrapper which put report to the output function ; Syntax ........: __Log_Wrapper($sText) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; Return values .: None or set @error = 1 in case _Log_SetOutputFunction() was not used or used not properly ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log, _Log_OnError, _Log_OnExtended, _Log_OnSuccess, _Log_Change ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __Log_Wrapper($sText) Local $fnFunction = _Log_SetOutputFunction() If @error Then Return SetError(1) $fnFunction($sText) EndFunc ;==>__Log_Wrapper #EndRegion ErrorLog.au3 - Internal Functions EXAMPLE: #include <WinAPIProc.au3> #include-once #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #AutoIt3Wrapper_Run_Debug_Mode=Y ; #Tidy_Parameters=/sort_funcs /reel #include <Debug.au3> #include "ErrorLog.au3" If Not @Compiled Then $__g_bUDF_ERRORLOG_FORCE_DEBUG = True ; Pre set function to where log report is passed _Log_SetOutputFunction(ConsoleWrite) _Log_Debug("EXAMPLE 1: START" & @CRLF, @ScriptLineNumber) _Log_Example_1() ; check again for @error If @error Then MsgBox($MB_ICONERROR, 'Example 1: Error Occured', _ 'File Reading Problem.' & @CRLF & _ '@error = ' & @error & @CRLF & _ '@extended = ' & @extended _ ) _Log_Debug("EXAMPLE 2: START" & @CRLF, @ScriptLineNumber) _Log_Example_2() _Log_Debug("EXAMPLE 3: START", @ScriptLineNumber) _Log_Example_3() _Log_SetOutputFunction(_ConsoleWrite_Wrapper) _Log_Debug("EXAMPLES: END", @ScriptLineNumber) Func _Log_Example_1() ; sending description to log output _Log('Example 1: We are trying to read file.' & @CR) ; fire @error FileRead('FILE PATH WHICH NOT EXIST') ; report @error but do not change it - store it and back it again _Log_OnError('Example 1: File Reading Problem.' & @CR) Return SetError(@error, @extended) EndFunc ;==>_Log_Example_1 Func _Log_Example_2() ; set function to where log reports will be passed _Log_SetOutputFunction(_ConsoleWrite_Wrapper) ; sending description to log output _Log('Example 2: We are trying to read file.') For $iAttempt_idx = 1 To 15 _log('Example 2: $iAttempt_idx = ' & $iAttempt_idx) ; fire @error If $iAttempt_idx < 14 Then FileRead('FILE PATH WHICH NOT EXIST') ; next line will log only in step #12 and #13 - as only to step #13 , errors ocurrs If $iAttempt_idx > 11 Then _Log_OnError('Example 2: File Reading error' & @CR) ; fake @error to show what _Log_Change() will do when @error is changing If $iAttempt_idx = 5 Then SetError(2) ; fake @exteneded to show what _Log_Change() will do when @exteneded is changing If $iAttempt_idx = 10 Then SetError(@error, 2) ; string change If $iAttempt_idx > 13 Then _Log_Change('Some other log data') ; report to log output but only first unique occurance _Log_Change('Example 2: File Reading Problem.' & @CR) _Log_Errors_Reset() ; if you do not reset then @error and @extended could be followed to next loop. Next EndFunc ;==>_Log_Example_2 Func _Log_Example_3() ; set function to where log reports will be passed _Log_SetOutputFunction(_ConsoleWrite_Wrapper) ; sending description to log output _Log('Example 3: We are trying to read file.') For $iAttempt_idx = 1 To 15 ; If $iAttempt_idx = 9 change output function - from this moment log reports will be passed to _DebugOut() instead _ConsoleWrite_Wrapper() If $iAttempt_idx = 9 Then _DebugSetup("Example 3: ErrorLog.au3 - output") _Log_SetOutputFunction(_DebugOut) EndIf _log('Example 3: $iAttempt_idx = ' & $iAttempt_idx) ; fire @error If $iAttempt_idx < 14 Then FileRead('FILE PATH WHICH NOT EXIST') ; next line will log only in step #12 and #13 - as only to step #13 , errors ocurrs If $iAttempt_idx > 11 Then _Log_OnError('Example 3: File Reading error') ; fake @error to show what _Log_Change() will do when @error is changing If $iAttempt_idx = 5 Then SetError(2) ; fake @exteneded to show what _Log_Change() will do when @exteneded is changing If $iAttempt_idx = 10 Then SetError(@error, 2) ; string change If $iAttempt_idx > 13 Then _Log_Change('Example 3: Some other log data') ; report to log output but only first unique occurance _Log_Change('Example 3: File Reading Problem.' & @CR) _Log_Errors_Reset() ; if you do not reset then @error and @extended could be followed to next loop. Next EndFunc ;==>_Log_Example_3 Func _ConsoleWrite_Wrapper($sData) ConsoleWrite($sData & @CRLF) EndFunc ;==>_ConsoleWrite_Wrapper REMARKS: Documentation in function headers is currently complete1 point
-
Can you try this code ? It lists all controls in the specified window an uses _GUIScrollBars_GetScrollInfo for each control. It works for me with notepad, but not tested with anoter app. #include <GuiScrollBars.au3> If _WinDetectScrollbar("[Class:Notepad]") Then MsgBox(0, "", "The specified window has a scrollbar") Func _WinDetectScrollbar($sTitle, $sText = "") Local $iCount, $iInstance, $hControl Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) Local $sClassList = WinGetClassList($sTitle, $sText) If $sClassList = "" Then Return 0 Local $aClasses = StringRegExp($sClassList, "(?m)(^\N+$)(?!(?:\R(?1))*\R\1)", 3) For $i = 0 To UBound($aClasses) - 1 StringRegExpReplace($sClassList, "\Q" & $aClasses[$i] & "\E\R", "") $iCount = @extended For $iInstance = 1 To $iCount $hControl = ControlGetHandle($sTitle, $sText, "[CLASS:" & $aClasses[$i] & "; INSTANCE:" & $iInstance& "]") DllStructSetData($tSCROLLINFO, "cbSize", DllStructGetSize($tSCROLLINFO)) DllStructSetData($tSCROLLINFO, "fMask", $SIF_ALL) _GUIScrollBars_GetScrollInfo($hControl, $SB_HORZ, $tSCROLLINFO) If DllStructGetData($tSCROLLINFO, "nMax") >= DllStructGetData($tSCROLLINFO, "nPage") Then Return 1 _GUIScrollBars_GetScrollInfo($hControl, $SB_VERT, $tSCROLLINFO) If DllStructGetData($tSCROLLINFO, "nMax") >= DllStructGetData($tSCROLLINFO, "nPage") Then Return 1 Next Next Return 0 EndFunc1 point
-
need help to create a treeview linked with array
MesterPerfect reacted to junkew for a topic
I hope your next posts will give more insight in your searching skills https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateTreeView.htm0 points