Hey,
ich bastel an einer "Jump To" Registry Schlüssel Funktion...ich leg einen Schlüssel fest und regedit wird mit angegebenen Schlüssel geöffnet. Einziges Problem: ich starte aktuell die regedit.exe im skript, was auch funktioniert, aber jeder Versuch auf die TreeView items zuzugreifen, wenn regedit bereits geöffnet ist schläft fehl.
C
#include <GUIConstants.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
Global $h_item
ShellExecute("regedit.exe")
;~ Local $pid = ProcessExists("regedit.exe")
;~ If $pid Then
;~ $h_tree = WinHandFromPID($pid, "[CLASS:RegEdit_RegEdit]")
;~ WinActivate("[CLASS:RegEdit_RegEdit]", "")
;~ EndIf
WinWaitActive("[CLASS:RegEdit_RegEdit]", "")
;~ WinActivate("[CLASS:RegEdit_RegEdit]", "")
;~ WinSetState("[CLASS:RegEdit_RegEdit]", "", @SW_SHOW) ; activate
;~ WinSetState("[CLASS:RegEdit_RegEdit]", "", @SW_RESTORE) ; activate
;~ WinSetState("[CLASS:RegEdit_RegEdit]", "", @SW_RESTORE) ; activate
$h_tree = WinGetHandle("[CLASS:RegEdit_RegEdit]", "")
;~ $ret = _WinAPI_ShowWindow($h_tree, @SW_RESTORE)
$ctrl = ControlGetHandle($h_tree, "", "[CLASS:SysTreeView32]")
ConsoleWrite("$h_tree: " & $h_tree & @CRLF)
ConsoleWrite("$ctrl: " & $ctrl & @CRLF)
$show = GUICtrlCreateButton("Show", 70, 180, 70, 20)
Show()
;~ While 1
;~ Sleep(200)
;~ WEnd
Func Show()
$result = ""
_SendMessage($ctrl, $WM_SETFOCUS, 0, 0)
If @error Then ConsoleWrite("error" & @CRLF)
$h_item = _SendMessage($ctrl, $TVM_GETNEXTITEM, $TVGN_ROOT, 0)
$split = StringSplit("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "\")
For $i=1 To $split[0]
ConsoleWrite("item bevor findkey: " & $h_item & @CRLF)
$h_item = FindKey($h_item, $split[$i])
If $h_item = 0 Then Return
_SendMessage($ctrl, $TVM_SELECTITEM, 0x0009, $h_item)
; expand tree
_GUICtrlTreeView_Expand($ctrl, $h_item)
Next
MsgBox(0, "dsfsdf", "sdfsf")
Exit
EndFunc
Func FindKey($hItemParent, $sKey)
$h_item = _SendMessage($ctrl, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItemParent)
ConsoleWrite("child : " & $h_item & " key: " & $sKey & " parent: " & $hItemParent & " parent text: " & _GUICtrlTreeView_GetText($ctrl, $hItemParent) & @CRLF)
While $h_item <> 0
Local $sItemText = _GUICtrlTreeView_GetText($ctrl, $h_item)
ConsoleWrite("text : " & $sItemText & @CRLF)
If $sItemText = $sKey Then Return $h_item
$h_item = _SendMessage($ctrl, $TVM_GETNEXTITEM, $TVGN_NEXT, $h_item)
ConsoleWrite("next : " & $h_item & @CRLF)
WEnd
ConsoleWrite("not found" & @CRLF)
Return 0
EndFunc
Alles anzeigen