Leaderboard
Popular Content
Showing content with the highest reputation on 07/27/2018 in all areas
-
DllCall doesn't work has expected (Solved)
FrancescoDiMuro and one other reacted to RTFC for a topic
Thought that code looked familiar. Your string parameter definitions in the cpp are wrong, use LPSTR/LPTSTR/LPCSTR; see an example here. Conversion list is here (and in DllCall Help).2 points -
Error Handling in Code - (Moved)
PramodR reacted to JLogan3o13 for a topic
Moved to the appropriate forum. Moderation Team1 point -
Filecreate shortcut
FrancescoDiMuro reacted to Earthshine for a topic
Francesco, he's trying to create a shortcut, a .lnk file that is linked to an exe of the users choice for your last problem, look at the help file for RunAs so you can run cmd as admin and forget that other nonsense.1 point -
Array extract - removing rows that has a blank field
FrancescoDiMuro reacted to jchd for a topic
I didn't try to make the regexp help any kind of tutorial, just a handy digest of most of the available constructs. I know there are a few errors or inaccuracies left, which I don't have much time to fix. In case Jon someday decides to switch to the now-stable PCRE2 API n some future AutoIt release, functions and help will have to be seriously reworked. Still, PCRE1 in current AutoIt is powerful enough for many purposes. There are a large number of good PCRE resources floating around, like this one: https://www.regular-expressions.info/index.html Always practice while on the learning curve and this is one of the best regex workbench: https://regex101.com/ Leave the flavor as pcre(php) as its compatible with AutoIt PCRE. You can see an live explanation in plain english of the typed regex, you can test substitution (as in StringRegExpReplace) and also debug your expressions or see them work (or fail) step by step.1 point -
Listbox Searching
purushothama reacted to FrancescoDiMuro for a topic
@purushothama I think that a WM_COMMAND is quite enough to do what you're trying to do... Do you know anything about that? Take a look right below ( your script modified ): #include <ButtonConstants.au3> #include <file.au3> #include <GUIListBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("TextExpander", 451, 403, 336, 33) $IP = GUICtrlCreateInput("", 32, 304, 177, 21) ; GUICtrlCreateInput("", 240, 304, 177, 21) $Button1 = GUICtrlCreateButton("OK", 24, 344, 89, 33, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Add Entry", 136, 344, 105, 33) $Edit1 = GUICtrlCreateList("", 16, 8, 409, 279) $Button3 = GUICtrlCreateButton("Close", 352, 344, 65, 33) GUISetState(@SW_SHOW) LoadData () #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func LoadData () Local Const $sFilePath = @ScriptDir & "\Textexpander.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) $sData = fileread($hFileOpen) fileclose($hFileOpen) Global $MyVal = StringSplit($sData,"|") Global $possibles = stringreplace($sdata,@CRLF,'|') GUICtrlSetData($Edit1, $possibles) EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hdlWindowFrom, _ $intControlID_From, _ $intMessageCode, _ $strSearchString = "", _ $intItemIndex = 0 $intControlID_From = BitAND($wParam, 0xFFFF) $intMessageCode = BitShift($wParam, 16) Switch $intControlID_From Case $IP Switch $intMessageCode Case $EN_CHANGE $strSearchString = GUICtrlRead($IP) $intItemIndex = _GUICtrlListBox_FindString($Edit1, $strSearchString) If @error Then ConsoleWrite("Error while searching the string in the ListBox. Error: " & @error & @CRLF) Else _GUICtrlListBox_SetCurSel($Edit1, $intItemIndex) If @error Then ConsoleWrite("Error while selecting the ListBox Item " & $intItemIndex & ".Error: " & @error & @CRLF) EndIf EndIf EndSwitch EndSwitch EndFunc Little suggestion: Use meaningful names for your variables and for your controls1 point -
Array extract - removing rows that has a blank field
FrancescoDiMuro reacted to jchd for a topic
You really should, it's a excellent investment.1 point -
The site uses jQuery, so a standard click doesn't work. Try this -- #include <IE.au3> Local $oIE = _IECreate ("https://www.die-staemme.de/") Local $jQuery = _jQuerify($oIE) Local $Username = _IEGetObjByName($oIE, "username") Local $Password = _IEGetObjByName($oIE, "password") _IEFormElementSetValue ($Username,"your Username") _IEFormElementSetValue ($Password,"your Password") $jQuery(".btn-login").click() ; #FUNCTION# ==================================================================================================================== ; Name ..........: _jQuerify ; Description ...: ; Syntax ........: _jQuerify(Byref $oIE) ; Parameters ....: $oIE - Object variable of an InternetExplorer.Application. ; Return values .: an object variable pointing to the jQuery library ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _jQuerify(ByRef $oIE) Local $msie, $jsEval, $jQuery, $otherlib = False $msie = Execute('$oIE.document.documentMode') If ($msie = "") Or Number($msie) < 11 Then ; an IE version < 11 ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('window.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.parentwindow.eval') Until IsObj($jsEval) Else ; IE version > = 11 ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) EndIf ; if jQuery is not already loaded then load it If $jsEval("typeof jQuery=='undefined'") Then ; check if the '$' (dollar) name is already in use by other library If $jsEval("typeof $=='function'") Then $otherlib = True Local $oScript = $oIE.document.createElement('script'); $oScript.type = 'text/javascript' ; If you want to load jQuery from a disk file use the following statement ; where i.e. jquery-1.9.1.js is the file containing the jQuery source ; (or also use a string variable containing the whole jQuery listing) ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file ; If you want to download jQuery from the web use this statement $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript) Do Sleep(250) Until $jsEval("typeof jQuery == 'function'") EndIf Do Sleep(250) $jQuery = $jsEval("jQuery") Until IsObj($jQuery) If $otherlib Then $jsEval('jQuery.noConflict();') Return $jQuery EndFunc ;==>_jQuerify1 point
-
[Solved] _Word_DocFindReplace() doesn't find and replace in Headers/Footers
Earthshine reacted to water for a topic
Correct. You need to specify the StoryRange to process. To do the find/replace operation everywhere you need to do something like: For $oStoryRange In $oDoc.StoryRanges _Word_DocFindReplace($oDoc, "Find", "ReplaceWith", Default, $oStoryRange) Next1 point -
Hi, I made this function for AutoIt 3.2.8.1, but here is adapted function (+ example) for the latest AutoIt (3.2.10.0): ;Demo for _GUICtrlListView_MoveItems() function. ;Just select one (or more) item, and press one of the buttons (Up or Down). #include <GUIConstants.au3> #include <GuiListView.au3> $GUI = GUICreate('Demo for _GUICtrlListView_MoveItems()', 300, 320) $ListView = GUICtrlCreateListView("Column1|Column2|Column3", 20, 20, 260, 250) GUICtrlSetStyle($ListView, $LVS_SHOWSELALWAYS+$LVS_REPORT, $LVS_EX_CHECKBOXES+$LVS_EX_FULLROWSELECT) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|Item " & $i & " subtext|subtext " & $i, $Listview) GUICtrlSetImage(-1, "shell32.dll", 4, 0) Next GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, -1) $Up_Button = GUICtrlCreateButton("Up", 20, 280, 32, 32, $BS_ICON) GUICtrlSetImage(-1, "netcfgx.dll", 1) $Down_Button = GUICtrlCreateButton("Down", 90, 280, 32, 32, $BS_ICON) GUICtrlSetImage(-1, "netcfgx.dll", -2) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Up_Button _GUICtrlListView_MoveItems($GUI, $ListView, -1) ControlFocus($GUI, "", $ListView) Case $Down_Button _GUICtrlListView_MoveItems($GUI, $ListView, 1) ControlFocus($GUI, "", $ListView) EndSwitch WEnd ;=============================================================================== ; Function Name: _GUICtrlListView_MoveItems() ; Description: Move selected item(s) in ListView Up or Down. ; ; Parameter(s): $hWnd - Window handle of ListView control (can be a Title). ; $vListView - The ID/Handle/Class of ListView control. ; $iDirection - [Optional], define in what direction item(s) will move: ; 1 (default) - item(s) will move Next. ; -1 item(s) will move Back. ; $sIconsFile - Icon file to set image for the items (only for internal usage). ; $iIconID_Checked - Icon ID in $sIconsFile for checked item(s). ; $iIconID_UnChecked - Icon ID in $sIconsFile for Unchecked item(s). ; ; Requirement(s): #include <GuiListView.au3>, AutoIt 3.2.10.0. ; ; Return Value(s): On seccess - Move selected item(s) Next/Back. ; On failure - Return "" (empty string) and set @error as following: ; 1 - No selected item(s). ; 2 - $iDirection is wrong value (not 1 and not -1). ; 3 - Item(s) can not be moved, reached last/first item. ; ; Note(s): * This function work with external ListView Control as well. ; * If you select like 15-20 (or more) items, moving them can take a while :( (second or two). ; ; Author(s): G.Sandler a.k.a CreatoR ;=============================================================================== Func _GUICtrlListView_MoveItems($hWnd, $vListView, $iDirection=1, $sIconsFile="", $iIconID_Checked=0, $iIconID_UnChecked=0) Local $hListView = $vListView If Not IsHWnd($hListView) Then $hListView = ControlGetHandle($hWnd, "", $hListView) Local $aSelected_Indices = _GUICtrlListView_GetSelectedIndices($hListView, 1) If UBound($aSelected_Indices) < 2 Then Return SetError(1, 0, "") If $iDirection <> 1 And $iDirection <> -1 Then Return SetError(2, 0, "") Local $iTotal_Items = ControlListView($hWnd, "", $hListView, "GetItemCount") Local $iTotal_Columns = ControlListView($hWnd, "", $hListView, "GetSubItemCount") Local $iUbound = UBound($aSelected_Indices)-1, $iNum = 1, $iStep = 1 Local $iCurrent_Index, $iUpDown_Index, $sCurrent_ItemText, $sUpDown_ItemText Local $iCurrent_Index, $iCurrent_CheckedState, $iUpDown_CheckedState If ($iDirection = -1 And $aSelected_Indices[1] = 0) Or _ ($iDirection = 1 And $aSelected_Indices[$iUbound] = $iTotal_Items-1) Then Return SetError(3, 0, "") ControlListView($hWnd, "", $hListView, "SelectClear") Local $aOldSelected_IDs[1] Local $iIconsFileExists = FileExists($sIconsFile) If $iIconsFileExists Then For $i = 1 To $iUbound ReDim $aOldSelected_IDs[UBound($aOldSelected_IDs)+1] _GUICtrlListView_SetItemSelected($hListView, $aSelected_Indices[$i], True) $aOldSelected_IDs[$i] = GUICtrlRead($vListView) _GUICtrlListView_SetItemSelected($hListView, $aSelected_Indices[$i], False) Next ControlListView($hWnd, "", $hListView, "SelectClear") EndIf If $iDirection = 1 Then $iNum = $iUbound $iUbound = 1 $iStep = -1 EndIf For $i = $iNum To $iUbound Step $iStep $iCurrent_Index = $aSelected_Indices[$i] $iUpDown_Index = $aSelected_Indices[$i]+1 If $iDirection = -1 Then $iUpDown_Index = $aSelected_Indices[$i]-1 $iCurrent_CheckedState = _GUICtrlListView_GetItemChecked($hListView, $iCurrent_Index) $iUpDown_CheckedState = _GUICtrlListView_GetItemChecked($hListView, $iUpDown_Index) _GUICtrlListView_SetItemSelected($hListView, $iUpDown_Index) For $j = 0 To $iTotal_Columns-1 $sCurrent_ItemText = _GUICtrlListView_GetItemText($hListView, $iCurrent_Index, $j) $sUpDown_ItemText = _GUICtrlListView_GetItemText($hListView, $iUpDown_Index, $j) _GUICtrlListView_SetItemText($hListView, $iUpDown_Index, $sCurrent_ItemText, $j) _GUICtrlListView_SetItemText($hListView, $iCurrent_Index, $sUpDown_ItemText, $j) Next _GUICtrlListView_SetItemChecked($hListView, $iUpDown_Index, $iCurrent_CheckedState) _GUICtrlListView_SetItemChecked($hListView, $iCurrent_Index, $iUpDown_CheckedState) If $iIconsFileExists Then If $iCurrent_CheckedState = 1 Then GUICtrlSetImage(GUICtrlRead($vListView), $sIconsFile, $iIconID_Checked, 0) Else GUICtrlSetImage(GUICtrlRead($vListView), $sIconsFile, $iIconID_UnChecked, 0) EndIf If $iUpDown_CheckedState = 1 Then GUICtrlSetImage($aOldSelected_IDs[$i], $sIconsFile, $iIconID_Checked, 0) Else GUICtrlSetImage($aOldSelected_IDs[$i], $sIconsFile, $iIconID_UnChecked, 0) EndIf EndIf _GUICtrlListView_SetItemSelected($hListView, $iUpDown_Index, 0) Next For $i = 1 To UBound($aSelected_Indices)-1 $iUpDown_Index = $aSelected_Indices[$i]+1 If $iDirection = -1 Then $iUpDown_Index = $aSelected_Indices[$i]-1 _GUICtrlListView_SetItemSelected($hListView, $iUpDown_Index) Next EndFunc P.S I think such function should be in the package with _GuiCtrlListView... functions.1 point