Leaderboard
Popular Content
Showing content with the highest reputation on 05/05/2021 in all areas
-
WebDriver UDF - Help & Support (III)
ThomasBennett reacted to Danp2 for a topic
$_WD_ERROR_Timeout is an enum that happens to corelate to the number 7. So you were receiving $_WD_ERROR_Timeout, but you just didn't know it. ๐1 point -
String Seach with Multiple Scenarios
PnD reacted to JockoDundee for a topic
Just to be clear, I'm not necessarily advocating for stringbetween, I only used it to mix it up Had I been a first responder, I may have reg'ed myself. Rather, I'm speaking about the business logic, in that, IF accuracy is paramount, then maybe you can find another filter, for instance line# Range etc. But since you're ok with it, then happy data mining!1 point -
[Solved] How to write special characters to SciTE Editor? - (Moved)
DannyJ reacted to argumentum for a topic
Test() Func Test() FileWriteLine(@TempDir & "\Test__ " & Chr(0xE2) & " " & Chr(0xE3) & " " & Chr(0xE4) & ".txt", Chr(0xE2) & " " & Chr(0xE3) & " " & Chr(0xE4)) Local $sCommand = @ComSpec & " /c powershell.exe ""Get-ChildItem -Path " & @TempDir & " | Format-List -Property *"" " Local $iPid = Run($sCommand, "", @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) ConsoleWrite(__WinAPI_OemToCharA($sOutput)) ;~ ConsoleWrite(__WinAPI_OemToChar($sOutput)) EndFunc ;==>Test Func __WinAPI_OemToChar($sStr) ; these are turned into helper functions. Local $sRet = __WinAPI_OemToChar_Internal_1($sStr, "OemToChar") Return SetError(@error, @extended, $sRet) EndFunc ;==>__WinAPI_OemToChar Func __WinAPI_OemToCharA($sStr) ; these are turned into helper functions. Local $sRet = __WinAPI_OemToChar_Internal_1($sStr, "OemToCharA") Return SetError(@error, @extended, $sRet) EndFunc ;==>__WinAPI_OemToCharA Func __WinAPI_OemToChar_Internal_1($sStr, $OemToCharType = "OemToChar", $sRet = "") Do ; $sRet = "" is to save me the local declaration, but may not be kosher. $sRet &= __WinAPI_OemToChar_Internal_2(StringLeft($sStr, 1024 * 64), $OemToCharType) If @error Then Return SetError(@error, @extended, $sRet) $sStr = StringTrimLeft($sStr, 1024 * 64) Until Not StringLen($sStr) Return $sRet EndFunc ;==>__WinAPI_OemToChar_Internal_1 Func __WinAPI_OemToChar_Internal_2($sStr, $OemToCharType = "OemToChar") Local $aRet = DllCall('user32.dll', 'bool', $OemToCharType, 'str', $sStr, 'str', '') If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc ;==>__WinAPI_OemToChar_Internal_2 ...the above does the chunking I meant, and brings flexibility for OemToChar, OemToCharA and OemToCharW. ( not that I know any better of what's what, but it does the chunking )1 point -
[Solved] How to write special characters to SciTE Editor? - (Moved)
DannyJ reacted to argumentum for a topic
ConsoleWrite(_WinAPI_WideCharToMultiByte($sOutput, 2)) ; +>20:24:52 AutoIt3.exe ended.rc:0 now that returned what I expected, but is "2" = "The current system Macintosh code page". Why Macintosh ?. Macintosh like in Apple ?. PS: "รข รฃ รค" is not returned as such under any format (OemToChar or WideCharToMultiByte)1 point -
On-place OEM to Char (that is OEM [some legacy DOS codepage] to ANSI [some non-DOS single-byte codepage]) won't convert the upper part of any DOS codepage correctly. All of them contain characters (e.g. borders โโโฉโฆ or blocks โโโโโโ and several more) that are not in ANSI. Only OEM to multibyte (UTF8) then multibyte to UCS2 (subset of UTF16) can convert everything verbatim at the cost of twice as much string bytelength. (No offence to anyone intended here)1 point
-
WebDriver UDF - Help & Support (III)
ThomasBennett reacted to Danp2 for a topic
@ThomasBennett I would have written the loop like this -- While True $nResult = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='popups-loading']//div[contains(text(),'Loading...')]") If $nResult = 1 And @error = $_WD_ERROR_Timeout Then ExitLoop EndIf WEnd Obviously, this doesn't handle any other type of error that may occur and I didn't set @error like you did. Yes, you could use _WD_ExecuteScript to retrieve the text, but a more traditional method would be like this -- $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//thead[@class='tableHeader-processed']//div[@class='collection-paging-info']") ; Either of the following should work $sValue1 = _WD_ElementAction($sSession, $sElement, 'property', 'value') $sValue2 = _WD_ElementAction($sSession, $sElement, 'value')1 point -
Test() Func Test() Local $sCommand = "powershell.exe Get-ChildItem | Format-List -Property *" Local $iPid = Run($sCommand, @WindowsDir, @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) MsgBox ($MB_SYSTEMMODAL, "", StringLen($sOutput)) ConsoleWrite(_WinAPI_OemToCharEx($sOutput)) EndFunc Func _WinAPI_OemToCharEx($sStr) Local $aRet = DllCall('user32.dll', 'bool', 'OemToCharA', 'str', $sStr, 'str', $sStr) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc ;==>_WinAPI_OemToChar That seems to resolve the problem. msdn says : @argumentum I see you were quite brisk to denounce the ticket...1 point
-
[Solved] How to write special characters to SciTE Editor? - (Moved)
DannyJ reacted to argumentum for a topic
Test() Func Test() Local $sCommand = @ComSpec & " /c powershell.exe ""Get-ChildItem -Path " & @TempDir & " | Format-List -Property *"" " Local $iPid = Run($sCommand, "", @SW_SHOW, $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPid) ;~ ConsoleWrite(__WinAPI_OemToCharA($sOutput)) ; !>14:32:58 AutoIt3.exe ended.rc:-1073741819 ;~ ConsoleWrite(__WinAPI_OemToChar($sOutput)) ; !>14:34:21 AutoIt3.exe ended.rc:-1073740940 ConsoleWrite($sOutput) ; +>14:34:44 AutoIt3.exe ended.rc:0 EndFunc Func __WinAPI_OemToCharA($sStr) Local $aRet = DllCall('user32.dll', 'bool', 'OemToCharA', 'str', $sStr, 'str', '') If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc ;==>_WinAPI_OemToCharA Func __WinAPI_OemToChar($sStr) Local $aRet = DllCall('user32.dll', 'bool', 'OemToChar', 'str', $sStr, 'str', '') If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc ;==>_WinAPI_OemToChar it does not solve the issue, with a StringLen() of 1563641 point -
[SOLVED] HDN_TRACK notification in listview?
pixelsearch reacted to Nine for a topic
Slightly modified your script, now working : #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $hHeader, $idDummy, $tItem = DllStructCreate($tagHDITEM) $tItem.Mask = $HDI_WIDTH Example() Func Example() ; Create GUI GUICreate("ListView header", 420, 122) $idDummy = GUICtrlCreateDummy() ; Create ListView Local $idListView = GUICtrlCreateListView("", 10, 10, 400, 104, $GUI_SS_DEFAULT_LISTVIEW - $LVS_SINGLESEL) _GUICtrlListView_SetExtendedListViewStyle($idListView, $LVS_EX_DOUBLEBUFFER + $LVS_EX_FULLROWSELECT) ; Add columns to ListView _GUICtrlListView_AddColumn($idListView, "Column 1", 94) _GUICtrlListView_AddColumn($idListView, "Column 2", 94) _GUICtrlListView_AddColumn($idListView, "Column 3", 94) _GUICtrlListView_AddColumn($idListView, "Column 4", 94) ; Get ListView Header $hHeader = _GUICtrlListView_GetHeader($idListView) ; Remove the $HDS_FULLDRAG style from the ListView Header to get $HDN_TRACKW notifications ;_WinAPI_SetWindowLong( $hHeader, $GWL_STYLE, _WinAPI_GetWindowLong( $hHeader, $GWL_STYLE ) - $HDS_FULLDRAG ) ; AutoIt 3.3.14.5 issue DllCall("user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $hHeader, "int", $GWL_STYLE, "long_ptr", _ DllCall("user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $hHeader, "int", $GWL_STYLE)[0] - $HDS_FULLDRAG) ; Fill ListView Local $iRows = 10 For $i = 0 To $iRows - 1 GUICtrlCreateListViewItem($i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView) Next GUIRegisterMsg($WM_NOTIFY, ListViewFunc) GUISetState(@SW_SHOW) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idDummy _SendMessage($hHeader, $HDM_GETITEMW, GUICtrlRead($idDummy), $tItem, 0, "wparam", "struct*") ConsoleWrite("New with on column " & GUICtrlRead($idDummy) & " = " & $tItem.XY & @CRLF) EndSwitch WEnd EndFunc ;==>Example ; ListView message handler function Func ListViewFunc($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHEADER, $lParam) If $tNMHDR.hWndFrom = $hHeader Then Switch $tNMHDR.Code Case $HDN_BEGINTRACKW ConsoleWrite("HDN_BEGINTRACKW" & @CRLF) Case $HDN_TRACKW ConsoleWrite("HDN_TRACKW" & @CRLF) Case $HDN_ENDTRACKW ConsoleWrite("HDN_ENDTRACKW " & $tNMHDR.Item & @CRLF) GUICtrlSendToDummy($idDummy, $tNMHDR.Item) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>ListViewFunc1 point -
[SOLVED] HDN_TRACK notification in listview?
pixelsearch reacted to LarsJ for a topic
You have to remove the $HDS_FULLDRAG style from the ListView Header to get $HDN_TRACKW notifications: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIRegisterMsg20.au3" Example() Func Example() ; Create GUI GUICreate( "ListView header", 420, 122 ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 400, 104, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL ) _GUICtrlListView_SetExtendedListViewStyle( $idListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) ; Add columns to ListView _GUICtrlListView_AddColumn( $idListView, "Column 1", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 2", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 3", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 4", 94 ) ; Get ListView Header Local $hHeader = _GUICtrlListView_GetHeader( $idListView ) ; Remove the $HDS_FULLDRAG style from the ListView Header to get $HDN_TRACKW notifications ;_WinAPI_SetWindowLong( $hHeader, $GWL_STYLE, _WinAPI_GetWindowLong( $hHeader, $GWL_STYLE ) - $HDS_FULLDRAG ) ; AutoIt 3.3.14.5 issue DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $hHeader, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $hHeader, "int", $GWL_STYLE )[0] - $HDS_FULLDRAG ) ; Fill ListView Local $iRows = 10 For $i = 0 To $iRows - 1 GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView ) Next ; Subclass ListView GUIRegisterMsg20( $idListView, $WM_NOTIFY, ListViewFunc ) ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete() EndFunc ; ListView message handler function Func ListViewFunc( $hWnd, $iMsg, $wParam, $lParam ) Switch DllStructGetData( DllStructCreate( $tagNMHDR, $lParam ), "Code" ) Case $HDN_BEGINTRACKW ConsoleWrite( "HDN_BEGINTRACKW" & @CRLF ) Case $HDN_TRACKW ConsoleWrite( "HDN_TRACKW" & @CRLF ) Case $HDN_ENDTRACKW ConsoleWrite( "HDN_ENDTRACKW" & @CRLF ) EndSwitch #forceref $hWnd, $iMsg, $wParam EndFunc1 point -
Please explain the DllStructCreate(Struct, Pointer) syntax!
pixelsearch reacted to AndyG for a topic
Hi, the "struct" reserves some memory, and the "pointer" points to the first adress of this memory. Here an (not season related^^) example which demonstrates the usage of the so called "memory" (which belongs to NOTHING! (meaning the datatypes) ) ;create struct $struct =dllstructcreate("int;float[4];dword") ;fill struct with data dllstructsetdata($struct,1,123456);int dllstructsetdata($struct,2,4.80114160043301e+030,1);float dllstructsetdata($struct,2,3.68584191575527e+024,2);float dllstructsetdata($struct,2,7.71403089381636e+031,3);float dllstructsetdata($struct,2,8.24605444209785e-019,4);float dllstructsetdata($struct,3,0xDEADBEEF);dword ;read some data from struct at offset 4 $struct2=dllstructcreate("char[16]",dllstructgetptr($struct)+4) msgbox(0,":o)",dllstructgetdata($struct2,1))1 point -
Please explain the DllStructCreate(Struct, Pointer) syntax!
pixelsearch reacted to Bilgus for a topic
basically you are giving a reference to an already created data structure you are just defining what it contains to AutoIt below is an entirely contrived example but it gives you the idea, typically the pointer would be returned from an API function $tInit = DllStructCreate("BYTE[8]") DllStructSetData($tInit, 1, 0xFF, 1) DllStructSetData($tInit, 1, 0xEE, 2) DllStructSetData($tInit, 1, 0xDD, 3) DllStructSetData($tInit, 1, 0xCC, 4) DllStructSetData($tInit, 1, 0x11, 5) DllStructSetData($tInit, 1, 0x22, 6) DllStructSetData($tInit, 1, 0x33, 7) DllStructSetData($tInit, 1, 0x44, 8) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit)) ; Using a pointer $tInit For $i = 1 To 4 ; Show Contents ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ; Setting the data here affects the original data DllStructSetData($tInitPtr, 1, 0xBB, 1) DllStructSetData($tInitPtr, 1, 0xAA, 2) DllStructSetData($tInitPtr, 1, 0x99, 3) DllStructSetData($tInitPtr, 1, 0x88, 4) ConsoleWrite(@CRLF) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInit, 1, $i)) & @CRLF) Next ;lets start at second element (DllStructGetPtr($tInit) + 0 ) is initial (first) element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 1) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ;lets start at third element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 2) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next ;lets start at fourth element ConsoleWrite(@CRLF) $tInitPtr = DllStructCreate("BYTE[4]", DllStructGetPtr($tInit) + 3) For $i = 1 To 4 ConsoleWrite("0x" & Hex(DllStructGetData($tInitPtr, 1, $i)) & @CRLF) Next1 point -
Hi. $RegExNonStandard="(?i)([^a-z0-9-_])" $Artist="Sean O’Daniels" $NameClean=StringRegExpReplace($Artist,$RegExNonStandard,"_") MsgBox(0,"Done",$Artist & @CRLF & $NameClean) Regards, Rudi.1 point
-
Try it:$UserEnters = ' 1(2E[u]ro)p e' MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace($UserEnters, '[^a-zA-Z]|\W', ''))1 point