Leaderboard
Popular Content
Showing content with the highest reputation on 09/12/2019 in all areas
-
As the WebDriver UDF - Help & Support thread has grown too big, I started a new one. The prior thread can be found here.1 point
-
I don't know what cemigrdr.exe is or does, but if you send the text to notepad, nothing gets slow after 4 or 5 lines. Opt("SendKeyDelay", 0) ConsoleWrite("Start the Notepad process" & @CRLF) ; Run Notepad with the window maximized. Local $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED) ; Wait 10 seconds for the Notepad window to appear. WinWait("[CLASS:Notepad]", "", 10) Send("cd c:\rdr") Send("{ENTER}") send("xyz.txt (former : name of cemigrdr.exe") send("{ENTER}") send("{ENTER}") send("C") send("C") send("G") send("0") send("{ENTER}") send("500") send("{ENTER}") send("d") send("wild") send("{ENTER}") send("20190001") send("159") send("{ENTER}") send("E2{ENTER}9{ENTER}11280{ENTER}090011600{ENTER}37{ENTER}{ENTER}") send("E2{ENTER}10{ENTER}{ENTER}{ENTER}090281600{ENTER}84{ENTER}{ENTER}") send("E2{ENTER}E3{ENTER}{ENTER}{ENTER}090392000{ENTER}124{ENTER}{ENTER}") send("E3{ENTER}E2{ENTER}213620{ENTER}") send("E3{ENTER}12{ENTER}11360800121E092431600{ENTER}24{ENTER}{ENTER}") send("E3{ENTER}13{ENTER}{ENTER}0409236{ENTER}1600{ENTER}41{ENTER}{ENTER}") send("E3{ENTER}14{ENTER}{ENTER}0309215{ENTER}2600{ENTER}48{ENTER}{ENTER}") send("E3{ENTER}15{ENTER}{ENTER}0309101{ENTER}3600{ENTER}55{ENTER}{ENTER}") send("E3{ENTER}16{ENTER}{ENTER}2609010{ENTER}3600{ENTER}61{ENTER}{ENTER}") send("E3{ENTER}17{ENTER}{ENTER}2609014{ENTER}3600{ENTER}57{ENTER}{ENTER}") send("E3{ENTER}18{ENTER}{ENTER}0409106{ENTER}4800{ENTER}104{ENTER}{ENTER}") ; Wait for 5 seconds. Sleep(5000) ; Close the Notepad process using the PID returned by Run. ProcessClose($iPID) ConsoleWrite("Notepad process closed" & @CRLF) Can you explain the functionality of cemigrdr.exe ?1 point
-
WebDriver UDF - Help & Support
nooneclose reacted to Danp2 for a topic
@nooneclose The simple answer is that you're doing it wrong. 🙄 Look at the last section of the DemoElements function in wd_demo.au3 for the proper technique.1 point -
Collecting data from rid
Mitya reacted to seadoggie01 for a topic
From his video, it looks like the program is written in .Net code (WinForms I think). The Events table that he wants to automate doesn't have individual IDs for each line. I think that the table is a DataGrid, but it's been a while since I used tables in .Net Mitya: I think you'll need to look into UI Automation to be able to automate this. After the basics, this link may come in handy: https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-support-for-the-datagrid-control-type I'm not familiar with UI Automation, but there are plenty of people here who are!1 point -
@nooneclose Obviously, we are having some communication issues. Let me try again. The webdriver console gets launched in _WD_Startup(). Therefore, either of the following method should work to control the console's visibility -- 1) Set the variable $_WD_DEBUG equal to $_WD_DEBUG_None. This should occur after the #include, but before calling _WD_Startup(). This should launch the console in a hidden state. 2) Anytime after calling _WD_Startup(), you can use _WD_ConsoleVisible() to either hide or show the console Make sense now?1 point
-
Here a script that may help you (and others) to find the shortcuts stored in different locations (you will also find Ctrl+Shift+U -> see 4.). Global $sPrefix = StringTrimRight(@AutoItExe, 11) Global $sAu3Prop, $sGlobalProp, $sUserProp, $sFile, $aMatch, $sResult ; 1. Read shortcuts from au3.properties : $sAu3Prop = $sPrefix & 'SciTE\properties\au3.properties' $sResult = '' ConsoleWrite ('-------- Shortcuts from au3.properties ---------- ' & @CRLF) $sFile = FileRead($sAu3Prop) For $i = 0 To 49 $aMatch = StringRegExp($sFile, 'command\.shortcut\.' & $i & '\.\$\(au3\)=(.+)', 1) If IsArray($aMatch) Then $sResult &= $aMatch[0] & '|' $aMatch = StringRegExp($sFile, 'command\.name\.' & $i & '\.\$\(au3\)=(.+)', 1) $sResult &= $aMatch[0] & @CRLF EndIf Next ConsoleWrite($sResult & @CRLF) ; 2. Read shortcuts from SciTEGlobal.properties : $sGlobalProp = $sPrefix & 'SciTE\SciTEGlobal.properties' $sResult = '' ConsoleWrite ('-------- Shortcuts from SciTEGlobal.properties ---------- ' & @CRLF) $sFile = FileRead($sGlobalProp) $aMatch = StringRegExp($sFile, '(?m)user\.shortcuts=([^# ]+)', 1) If IsArray($aMatch) Then $sResult = StringRegExpReplace(StringRegExpReplace($aMatch[0], '\|?\\', ''), '\|$', '') EndIf ConsoleWrite($sResult & @CRLF) ; 3. Read shortcuts from SciTEUser.properties : ; Info : ; A modified version of the SciTEUser.properties may be located in another folder, ; i.e. @LocalAppDataDir\SciTE\SciTEUser.properties ;~ $sUserProp = $sPrefix & 'SciTE\SciTEUser.properties' $sUserProp = @LocalAppDataDir & '\AutoIt v3\SciTE\SciTEUser.properties' ; $sResult = '' ConsoleWrite ('-------- Shortcuts from SciTEUser.properties ---------- ' & @CRLF) $sFile = FileRead($sUserProp) If @error Then ConsoleWrite ('! File not found : ' & $sUserProp & @CRLF) Else $aMatch = StringRegExp($sFile, '(?m)user\.shortcuts=([^# ]+)', 1) If IsArray($aMatch) Then $sResult = StringRegExpReplace(StringRegExpReplace($aMatch[0], '\|?\\', ''), '\|$', '') ConsoleWrite($sResult & @CRLF) Else ConsoleWrite ('! No shortcuts found. Use another folder' & @CRLF & @CRLF) $sResult = '' EndIf EndIf ; 4. From the SciTERes.rc (just a list) : (Menu | Action | Shortcut) ConsoleWrite ('-------- Shortcuts from SciTERes.rc ---------- ' & @CRLF) ConsoleWrite ('File | New | Ctrl+N' & @CRLF) ConsoleWrite ('File | Open... | Ctrl+O' & @CRLF) ConsoleWrite ('File | Open Selected Filename | Ctrl+Shift+O' & @CRLF) ConsoleWrite ('File | Revert | Ctrl+R' & @CRLF) ConsoleWrite ('File | Close | Ctrl+W' & @CRLF) ConsoleWrite ('File | Save | Ctrl+S' & @CRLF) ConsoleWrite ('File | Save As... | Ctrl+Shift+S' & @CRLF) ConsoleWrite ('File | Save a Copy... | Ctrl+Shift+P' & @CRLF) ConsoleWrite ('Export | Print... | Ctrl+P' & @CRLF) ConsoleWrite ('Edit | Undo | Ctrl+Z' & @CRLF) ConsoleWrite ('Edit | Redo | Ctrl+Y' & @CRLF) ConsoleWrite ('Edit | Cut | Ctrl+X' & @CRLF) ConsoleWrite ('Edit | Copy | Ctrl+C' & @CRLF) ConsoleWrite ('Edit | Paste | Ctrl+V' & @CRLF) ConsoleWrite ('Edit | Duplicate | Ctrl+D' & @CRLF) ConsoleWrite ('Edit | Select All | Ctrl+A' & @CRLF) ConsoleWrite ('Edit | Match Brace | Ctrl+E' & @CRLF) ConsoleWrite ('Edit | Select to Brace | Ctrl+Shift+E' & @CRLF) ConsoleWrite ('Edit | Show Calltip | Ctrl+Shift+Space' & @CRLF) ConsoleWrite ('Edit | Complete Symbol | Ctrl+I' & @CRLF) ConsoleWrite ('Edit | Complete Word | Ctrl+Enter' & @CRLF) ConsoleWrite ('Edit | Expand Abbreviation | Ctrl+B' & @CRLF) ConsoleWrite ('Edit | Insert Abbreviation | Ctrl+Shift+R' & @CRLF) ConsoleWrite ('Edit | Block Comment or Uncomment | Ctrl+Q' & @CRLF) ConsoleWrite ('Edit | Box Comment | Ctrl+Shift+B' & @CRLF) ConsoleWrite ('Edit | Stream Comment | Ctrl+Shift+Q' & @CRLF) ConsoleWrite ('Edit | Make Selection Uppercase | Ctrl+Shift+U' & @CRLF) ConsoleWrite ('Edit | Make Selection Lowercase | Ctrl+U' & @CRLF) ConsoleWrite ('Search | Find... | Ctrl+F' & @CRLF) ConsoleWrite ('Search | Find Previous | Shift+F3' & @CRLF) ConsoleWrite ('Search | Find in Files... | Ctrl+Shift+F' & @CRLF) ConsoleWrite ('Search | Replace... | Ctrl+H' & @CRLF) ConsoleWrite ('Search | Incremental Search... | Ctrl+Alt+I' & @CRLF) ConsoleWrite ('Search | Selection Add Next | Ctrl+Shift+D' & @CRLF) ConsoleWrite ('Search | Go to... | Ctrl+G' & @CRLF) ConsoleWrite ('Search | Previous Bookmark | Shift+F2' & @CRLF) ConsoleWrite ('Search | Toggle Bookmark | Ctrl+F2' & @CRLF) ConsoleWrite ('View | Whitespace | Ctrl+Shift+8' & @CRLF) ConsoleWrite ('View | End of Line | Ctrl+Shift+9' & @CRLF) ConsoleWrite ('View | Parameters | Shift+F8' & @CRLF) ConsoleWrite ('Tools | Compile | Ctrl+F7' & @CRLF) ConsoleWrite ('Tools | Clean | Shift+F7' & @CRLF) ConsoleWrite ('Tools | Stop Executing | Ctrl+Break' & @CRLF) ConsoleWrite ('Tools | Previous Message | Shift+F4' & @CRLF) ConsoleWrite ('Tools | Clear Output | Shift+F5' & @CRLF) ConsoleWrite ('Tools | Switch Pane | Ctrl+F6' & @CRLF) ConsoleWrite ('Line End Characters | Change Indentation Settings... | Ctrl+Shift+I' & @CRLF) ConsoleWrite ('Line End Characters | Use Monospaced Font | Ctrl+F11' & @CRLF) ConsoleWrite ('Buffers | Previous | Shift+F6' & @CRLF) BTW : Credits should go to @BugFix I have only summarized the information from the german site into one script and added small enhancements .1 point
-
Anyone need help on a project?
jaberwacky reacted to TheSaint for a topic
Coding is indeed a great distraction, can give you a break as you get lost in the intricacies of code. I consider it my savior. Often a break or distraction is all you need to start your recovery journey. And I find coding is a much easier addiction to deal with afterward. Welcome back (belated I know) and may your journey continue to improve ... hope it has done since you first posted.1 point -
1 point
-
Any way to drag and drop multiple files at once?
pixelsearch reacted to guinness for a topic
Here, you will need WinAPIEx.au3 #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> Global $__aGUIDropFiles = 0, $__hGUI = 0 Example() Func Example() $__hGUI = GUICreate('WM_DROPFILES', 400, 200, Default, Default, Default, $WS_EX_ACCEPTFILES) Local Const $iDrop = GUICtrlCreateLabel('', 0, 0, 400, 200) GUICtrlSetBkColor($iDrop, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState($iDrop, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW, $__hGUI) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED For $i = 1 To $__aGUIDropFiles[0] MsgBox($MB_SYSTEMMODAL, '', $__aGUIDropFiles[$i]) Next EndSwitch WEnd GUIDelete($__hGUI) EndFunc ;==>Example Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam Switch $iMsg Case $WM_DROPFILES Local Const $aReturn = _WinAPI_DragQueryFileEx($wParam) If UBound($aReturn) Then $__aGUIDropFiles = $aReturn Else Local Const $aError[1] = [0] $__aGUIDropFiles = $aError EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES1 point -
Treeview drag & drop reorder and edit example
Letraindusoir reacted to Siao for a topic
Make sure you have v3.2.9.5 or later... Full drag and drop reordering of items, both with images and no images. Item will be moved to InsertMark position or into drop highlighted item. Label edit (either mouse or keyboard Enter/Esc). Keyboard Delete to delete selected item. Keyboard Insert to insert new item after selected item. #include <GuiTreeView.au3> Opt("GUICloseOnESC", 0) Opt("GUIOnEventMode", 1) $sTitle = "Treeview Drag & Drop Editing" ;Required global constants: Global $bTreeDrag = False, $bTreeEdit = False, $hDragItem, $hTreeDragImage, $fWhere $hGui = GUICreate($sTitle, 400, 300, -1, -1, -1, -1) $label = GUICtrlCreateLabel("Drag and drop separate items or branches to move them." & _ @LF & "To start edit selected item, LMB on item or press Enter." & _ @LF & "To end editing, LMB outside item (apply) or Esc (cancel) / Enter (apply)." & _ @LF & "To insert new item press Insert, to delete existing item press Delete.", 30, 10, 340, 60) $cTree = GUICtrlCreateTreeView(50,75,300,200,$TVS_HASBUTTONS+$TVS_HASLINES+$TVS_LINESATROOT+$TVS_EDITLABELS+$TVS_CHECKBOXES) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $cTreeItemsStart = GUICtrlCreateDummy() $cTreeItem_1 = GUICtrlCreateTreeViewItem("item 1", $cTree) $cTreeItem_1a = GUICtrlCreateTreeViewItem("item 1a", $cTreeItem_1) $cTreeItem_1b = GUICtrlCreateTreeViewItem("item 1b", $cTreeItem_1) $cTreeItem_2 = GUICtrlCreateTreeViewItem("item 2", $cTree) $cTreeItem_2a = GUICtrlCreateTreeViewItem("item 2a", $cTreeItem_2) $cTreeItem_3 = GUICtrlCreateTreeViewItem("item 3", $cTree) $cTreeItem_3a = GUICtrlCreateTreeViewItem("item 3a", $cTreeItem_3) $cTreeItem_3a1 = GUICtrlCreateTreeViewItem("item 3a1", $cTreeItem_3a) $cTreeItem_4 = GUICtrlCreateTreeViewItem("item 4", $cTree) $cTreeItemsEnd = GUICtrlCreateDummy() ;treeview with images test: ;~ $hImgList = _GUIImageList_Create (16, 16) ;~ For $ii = 1 To $cTreeItemsEnd-$cTreeItemsStart ;~ _GUIImageList_AddIcon ($hImgList, "shell32.dll", 60+$ii*2) ;~ Next ;~ _GUICtrlTreeView_SetNormalImageList(GUICtrlGetHandle($cTree), $hImgList) ;~ $a = 0 ;~ For $i = $cTreeItemsStart+1 To $cTreeItemsEnd-1 ;~ _GUICtrlTreeView_SetImageIndex($cTree, _GUICtrlTreeView_GetItemHandle($cTree, $i), $a) ;~ _GUICtrlTreeView_SetSelectedImageIndex($cTree, _GUICtrlTreeView_GetItemHandle($cTree, $i), $a) ;~ $a += 1 ;~ Next $label2 = GUICtrlCreateLabel("", 50, 280, 300, 15) GUISetOnEvent($GUI_EVENT_CLOSE, "SysEvents") GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "SysEvents") GUISetOnEvent($GUI_EVENT_PRIMARYUP, "SysEvents") GUIRegisterMsg($WM_NOTIFY, "On_WM_NOTIFY") GUISetState() While 1 Sleep(200) ;add Enter, Esc, Delete and Insert key functionality to treeview edit: TreeKeyboardFunc($cTree) WEnd Func SysEvents() Local $hTree = GUICtrlGetHandle($cTree) Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP If $bTreeDrag Then _WinAPI_InvalidateRect($hTree) $bTreeDrag = False _GUIImageList_Destroy($hTreeDragImage) ;delete drag image _SendMessage($hTree, $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget _SendMessage($hTree, $TVM_SETINSERTMARK, 0, 0) ;remove InsertMark If (TreeItemFromPoint($hTree) = $hDragItem) Then ContinueCase ;move item: $hItem = TreeItemCopy($hTree, $hDragItem, TreeItemFromPoint($hTree), $fWhere) If $hItem <> 0 Then _GUICtrlTreeView_SelectItem($hTree, $hItem) _GUICtrlTreeView_Delete($hTree, $hDragItem) EndIf EndIf Case $GUI_EVENT_MOUSEMOVE If $bTreeDrag = False Then ContinueCase $aHwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1)) ;cancel drag in progress and cleanup if moved outside treeview: If ($aHwnd[0] <> $hTree) Then $bTreeDrag = False _WinAPI_InvalidateRect($hTree) _GUIImageList_Destroy($hTreeDragImage) ;delete drag image _SendMessage($hTree, $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget _SendMessage($hTree, $TVM_SETINSERTMARK, 0, 0) ;remove InsertMark ContinueCase EndIf $hItemHover = TreeItemFromPoint($hTree) If $hItemHover = 0 Then ;meh Else $aRect = _GUICtrlTreeView_DisplayRect($hTree, $hItemHover) $iTreeY = _WinAPI_GetMousePosY(True, $hTree) Switch $iTreeY Case $aRect[1] To $aRect[1]+Int(($aRect[3]-$aRect[1])/4) _SendMessage($hTree, $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget _SendMessage($hTree, $TVM_SETINSERTMARK, 0, $hItemHover) ;add InsertMark before item $fWhere = -1 Case 1+$aRect[1]+Int(($aRect[3]-$aRect[1])/3) To $aRect[1]+Int(($aRect[3]-$aRect[1])*2/3) _SendMessage($hTree, $TVM_SETINSERTMARK, 0, 0) ;remove InsertMark _SendMessage($hTree, $TVM_SELECTITEM, $TVGN_DROPHILITE, $hItemHover) ;add DropTarget $fWhere = 0 Case 1+$aRect[1]+Int(($aRect[3]-$aRect[1])*2/3) To $aRect[3] _SendMessage($hTree, $TVM_SELECTITEM, $TVGN_DROPHILITE, 0) ;remove DropTarget _SendMessage($hTree, $TVM_SETINSERTMARK, 1, $hItemHover) ;add InsertMark after item $fWhere = 1 EndSwitch EndIf DrawDragImage($hTree, $hTreeDragImage) EndSwitch EndFunc ; TreeItemFromPoint() ; Returns handle of tree item under mouse: Func TreeItemFromPoint($hWnd) Local $tMPos = _WinAPI_GetMousePos(True, $hWnd) Return _GUICtrlTreeView_HitTestItem($hWnd, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) EndFunc ; TreeItemCopy() ; Copies tree item $hItemSource and all its children to an item $hItemTarget, depending on $fDirection ; $fDirection: ; -1 = before $hItemTarget ; 0 = inside $hItemTarget ; 1 = after $hItemTarget Func TreeItemCopy($hWnd, $hItemSource, $hItemTarget, $fDirection) ;making sure parent can't be dropped onto one of its descendants: $hTest = $hItemTarget Do $hTest = _GUICtrlTreeView_GetParentHandle($hWnd, $hTest) If $hTest = $hItemSource Then Return 0 Until $hTest = 0 ;create new item at determined position $sText = _GUICtrlTreeView_GetText($hWnd, $hItemSource) $hParent = _GUICtrlTreeView_GetParentHandle($hWnd, $hItemTarget) Switch $fDirection Case -1 $hPrev = _GUICtrlTreeView_GetPrevSibling($hWnd, $hItemTarget) If $hPrev = 0 Then $hNew = _GUICtrlTreeView_AddFirst($hWnd, $hItemTarget, $sText) Else $hNew = _GUICtrlTreeView_InsertItem($hWnd, $sText, $hParent, $hPrev) EndIf Case 0 $hNew = _GUICtrlTreeView_InsertItem($hWnd, $sText, $hItemTarget) Case 1 $hNew = _GUICtrlTreeView_InsertItem($hWnd, $sText, $hParent, $hItemTarget) Case Else Return 0 EndSwitch ;save item state and checkbox image if there is such _GUICtrlTreeView_SetState($hWnd, $hNew, _GUICtrlTreeView_GetState($hWnd, $hItemSource)) If _GUICtrlTreeView_GetStateImageList($hWnd) <> 0 Then _GUICtrlTreeView_SetStateImageIndex($hWnd, $hNew, _GUICtrlTreeView_GetStateImageIndex($hWnd, $hItemSource)) EndIf ;save icon/selected image indexes If _GUICtrlTreeView_GetNormalImageList($hWnd) <> 0 Then _GUICtrlTreeView_SetImageIndex($hWnd, $hNew, _GUICtrlTreeView_GetImageIndex($hWnd, $hItemSource)) _GUICtrlTreeView_SetSelectedImageIndex($hWnd, $hNew, _GUICtrlTreeView_GetSelectedImageIndex($hWnd, $hItemSource)) EndIf ;recurse through descendants: $iChildCount = _GUICtrlTreeView_GetChildCount($hWnd, $hItemSource) If $iChildCount > 0 Then For $i = 0 To $iChildCount-1 $hRecSource = _GUICtrlTreeView_GetItemByIndex($hWnd, $hItemSource, $i) TreeItemCopy($hWnd, $hRecSource, $hNew, 0) Next EndIf Return $hNew EndFunc Func On_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) ;wparam = cid, lparam = pnmh If $wParam = $cTree Then Local $tNMHDR = DllStructCreate("hwnd hTree;uint;int code", $lParam) Local $code = DllStructGetData($tNMHDR, "code") Local $hTree = HWnd(DllStructGetData($tNMHDR, "hTree")) Switch $code Case $TVN_BEGINDRAG, $TVN_BEGINDRAGW $bTreeDrag = True $hDragItem = TreeItemFromPoint($hTree) ;~ _GUICtrlTreeView_SelectItem($hTree, $hDragItem) _GUICtrlTreeView_SetSelected($hTree, _GUICtrlTreeView_GetSelection($hTree), False) $hTreeDragImage = TreeCreateDragImage($hTree, $hDragItem) DrawDragImage($hTree, $hTreeDragImage) Case $TVN_BEGINLABELEDIT, $TVN_BEGINLABELEDITW $bTreeEdit = True ;~ $hTreeEdit = _SendMessage($hTree, $TVM_GETEDITCONTROL, 0, 0) Case $TVN_ENDLABELEDITW, $TVN_ENDLABELEDITW $bTreeEdit = False Return 1 Case $TVN_SELCHANGED, $TVN_SELCHANGEDW ;~ ;Local $hSel = _GUICtrlTreeView_GetSelection($hTree) ;~ Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $lParam) ;~ Local $hSel = DllStructGetData($tNMTREEVIEW, "NewhItem") ;~ Local $sTxt = "Currently selected: " & _GUICtrlTreeView_GetText($hTree, $hSel) & " (item handle " & $hSel & ")" ;~ GUICtrlSetData($label2, $sTxt) Case Else EndSwitch ; EndIf EndFunc Func KeyPressed($iHexKey) Local $aRet = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", $iHexKey) ;~ If BitAND($aRet[0], 0x8000) Or BitAND($aRet[0], 1) Then Return 1 If BitAND($aRet[0], 1) Then Return 1 Return 0 EndFunc Func TreeKeyboardFunc($cID) Local $hWnd = GUICtrlGetHandle($cID) If $bTreeDrag Then Return If $bTreeEdit Then If KeyPressed(0x0d) Then _SendMessage($hWnd, $TVM_ENDEDITLABELNOW, 0, 0) ;enter If KeyPressed(0x1b) Then _SendMessage($hWnd, $TVM_ENDEDITLABELNOW, 1, 0) ;esc EndIf Local $aRet = DllCall('user32.dll', 'hwnd', 'GetFocus') If $aRet[0] = $hWnd Then If KeyPressed(0x2d) Then _GUICtrlTreeView_Add($hWnd, _GUICtrlTreeView_GetSelection($hWnd), "New Item") ;insert If KeyPressed(0x2e) Then _GUICtrlTreeView_Delete($hWnd, _GUICtrlTreeView_GetSelection($hWnd)) ;delete If KeyPressed(0x0d) Then _SendMessage($hWnd, $TVM_EDITLABEL, 0, _GUICtrlTreeView_GetSelection($hWnd)) ;enter EndIf EndFunc Func TreeCreateDragImage($hWnd, $hItem) ;if treeview has imagelist, use image from it If _GUICtrlTreeView_GetNormalImageList($hWnd) <> 0 Then Return _GUICtrlTreeView_CreateDragImage($hWnd, $hItem) ;if not, create a bitmap of dragitem's text rectangle and put it into imagelist. Local $aItemRect = _GUICtrlTreeView_DisplayRect($hWnd, $hItem, True) Local $iImgW = $aItemRect[2]-$aItemRect[0] Local $iImgH = $aItemRect[3]-$aItemRect[1] Local $hTreeDC = _WinAPI_GetDC($hWnd) Local $hMemDC = _WinAPI_CreateCompatibleDC($hTreeDC) Local $hMemBmp = _WinAPI_CreateCompatibleBitmap($hTreeDC, $iImgW, $iImgH) Local $hMemBmpOld = _WinAPI_SelectObject($hMemDC, $hMemBmp) _WinAPI_BitBlt($hMemDC, 0, 0, $iImgW, $iImgH, $hTreeDC, $aItemRect[0], $aItemRect[1], $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hMemBmpOld) _WinAPI_ReleaseDC($hWnd, $hTreeDC) _WinAPI_DeleteDC($hMemDC) Local $hImgList = _GUIImageList_Create($iImgW, $iImgH, 6) _GUIImageList_Add($hImgList, $hMemBmp) _WinAPI_DeleteObject($hMemBmp) Return $hImgList EndFunc ; Draw drag image ; by Gary Frost (gafrost) (?) Func DrawDragImage(ByRef $hControl, ByRef $aDrag) Local $tPoint, $hDC $hDC = _WinAPI_GetWindowDC($hControl) $tPoint = _WinAPI_GetMousePos(True, $hControl) _WinAPI_InvalidateRect($hControl) _GUIImageList_Draw($aDrag, 0, $hDC, DllStructGetData($tPoint, "X")-10, DllStructGetData($tPoint, "Y")-8) _WinAPI_ReleaseDC($hControl, $hDC) EndFunc ;==>DrawDragImage1 point