hi
Ich hab mich vor kurzem mal mit pee unterhalten, dass es doch relativ leicht sein müsste, ein Tool zu schreiben, dass die Controls eines Fensters alle auflistet um sie dann in einem Scriptgenerator weiter zu verarbeiten...herausgekommen ist das hier:
Spoiler anzeigen
;(C) bei mir
#include<GuiListView.au3>
#include<WindowsConstants.au3>
#include<GUIConstantsEx.au3>
#include<Array.au3>
#include<ArrayMore.au3>
Opt("Guioneventmode",1)
Global $title
Global $text
#region maingui
$Form1_1 = GUICreate("mir ist kein name eingefallen", 677, 581, 185, 111)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit",$Form1_1)
$List1 = GUICtrlCreateListView("ClassnameNN |Text ", 16, 24, 641, 240)
$Label1 = GUICtrlCreateLabel("Fenstertitel:", 16, 296, 58, 17)
$Input1 = GUICtrlCreateInput("", 80, 296, 121, 21)
$Label2 = GUICtrlCreateLabel("Text(optional):", 216, 296, 71, 17)
$Input2 = GUICtrlCreateInput("", 296, 296, 121, 21)
$Button1 = GUICtrlCreateButton("Suchen", 440, 296, 75, 25, 0)
GUICtrlSetOnEvent($Button1,"_search")
$Group1 = GUICtrlCreateGroup("Controls", 8, 8, 657, 265)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Suche", 8, 280, 529, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Edit1 = GUICtrlCreateEdit("", 16, 360, 513, 201)
$Group3 = GUICtrlCreateGroup("Code", 8, 344, 529, 225)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Radio1 = GUICtrlCreateRadio("Controlclick", 560, 296, 81, 17)
GUICtrlSetOnEvent($Radio1,"_conclick_gui")
$Radio2 = GUICtrlCreateRadio("Controlsend", 560, 320, 81, 17)
GUICtrlSetOnEvent($Radio2,"_consend_gui")
$Radio3 = GUICtrlCreateRadio("Controlsettext", 560, 344, 89, 17)
GUICtrlSetOnEvent($Radio3,"_consettext_gui")
$Radio4 = GUICtrlCreateRadio("Controlshow", 560, 368, 81, 17)
GUICtrlSetOnEvent($Radio4,"_conshow")
$Radio5 = GUICtrlCreateRadio("Controlhide", 560, 392, 81, 17)
GUICtrlSetOnEvent($Radio5,"_conhide")
$Radio6 = GUICtrlCreateRadio("Controlenable", 560, 416, 89, 17)
GUICtrlSetOnEvent($Radio6,"_conenable")
$Radio7 = GUICtrlCreateRadio("Controldisable", 560, 440, 89, 17)
GUICtrlSetOnEvent($Radio7,"_condisable")
$Radio8 = GUICtrlCreateRadio("Controlfocus", 560, 464, 81, 17)
GUICtrlSetOnEvent($Radio8,"_confocus")
$Radio9 = GUICtrlCreateRadio("Controlcommand", 560, 488, 97, 17)
GUICtrlSetOnEvent($Radio9,"_concommand_gui")
$Radio10 = GUICtrlCreateRadio("Controlmove", 560, 512, 81, 17)
GUICtrlSetOnEvent($Radio10,"_conmove_gui")
$Button2 = GUICtrlCreateButton("Control markieren",560,536,98,25)
$Group4 = GUICtrlCreateGroup("Action", 552, 280, 113, 289)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW,$Form1_1)
#endregion maingui
#region conclickgui
$conclick_gui = GUICreate("Controlclick", 116, 173, 193, 125,Default,$ws_ex_toolwindow,$Form1_1)
GUISetOnEvent($GUI_EVENT_CLOSE,"_conclick_abbr",$conclick_gui)
GUICtrlCreateLabel("Clickart:", 8, 8, 42, 17)
$conclick_left = GUICtrlCreateRadio("Left", 8, 32, 113, 17)
$conclick_middle = GUICtrlCreateRadio("middle", 8, 56, 113, 17)
$conclick_right = GUICtrlCreateRadio("right", 8, 80, 113, 17)
GUICtrlCreateLabel("Anzahl:", 8, 112, 39, 17)
$conclick_anzahl = GUICtrlCreateInput("", 48, 112, 25, 21)
$conclick_ok = GUICtrlCreateButton("OK", 8, 144, 35, 25, 0)
GUICtrlSetOnEvent($conclick_ok,"_conclick_ok")
$conclick_abbr = GUICtrlCreateButton("Abbrechen", 48, 144, 59, 25, 0)
GUICtrlSetOnEvent($conclick_abbr,"_conclick_abbr")
#endregion conclickgui
#region consendgui
$consend_gui = GUICreate("Controlsend", 116, 173, 193, 125,Default,$ws_ex_toolwindow,$Form1_1)
GUISetOnEvent($GUI_EVENT_CLOSE,"_consend_abbr",$consend_gui)
GUICtrlCreateLabel("Sendstring:", 8, 8, 57, 17)
$consend_string = GUICtrlCreateEdit("", 8, 32, 97, 109)
$consend_ok = GUICtrlCreateButton("OK", 8, 144, 35, 25, 0)
GUICtrlSetOnEvent($consend_ok,"_consend_ok")
$consend_abbr = GUICtrlCreateButton("Abbrechen", 48, 144, 59, 25, 0)
GUICtrlSetOnEvent($consend_abbr,"_consend_abbr")
#endregion consendgui
#region consettextgui
$consettext_gui = GUICreate("Controlsettext", 116, 173, 193, 125,Default,$ws_ex_toolwindow,$Form1_1)
GUISetOnEvent($GUI_EVENT_CLOSE,"_consettext_abbr",$consettext_gui)
GUICtrlCreateLabel("Sendstring:", 8, 8, 57, 17)
$consettext_string = GUICtrlCreateEdit("", 8, 32, 97, 109)
$consettext_ok = GUICtrlCreateButton("OK", 8, 144, 35, 25, 0)
GUICtrlSetOnEvent($consettext_ok,"_consettext_ok")
$consettext_abbr = GUICtrlCreateButton("Abbrechen", 48, 144, 59, 25, 0)
GUICtrlSetOnEvent($consettext_abbr,"_consettext_abbr")
#endregion consettextgui
#region concommandgui
#endregion concommandgui
#region conmovegui
$conmove_gui = GUICreate("Controlmove",116, 173, 193, 125,Default,$ws_ex_toolwindow,$Form1_1)
GUISetOnEvent($GUI_EVENT_CLOSE,"_conmove_abbr",$conmove_gui)
GUICtrlCreateLabel("x:", 8, 8, 18, 17)
GUICtrlCreateLabel("y:", 8, 40, 22, 17)
GUICtrlCreateLabel("width:", 8, 72, 32, 17)
GUICtrlCreateLabel("height:", 8, 104, 30, 17)
$conmove_x = GUICtrlCreateInput("", 56, 8, 41, 21)
$conmove_y = GUICtrlCreateInput("", 56, 40, 41, 21)
$conmove_width = GUICtrlCreateInput("", 56, 72, 41, 21)
$conmove_height = GUICtrlCreateInput("", 56, 104, 41, 21)
$conmove_ok = GUICtrlCreateButton("OK", 8, 144, 35, 25, 0)
GUICtrlSetOnEvent($conmove_ok,"_conmove_ok")
$conmove_abbr = GUICtrlCreateButton("Abbrechen", 48, 144, 59, 25, 0)
GUICtrlSetOnEvent($conmove_abbr,"_conmove_abbr")
#endregion conmovegui
While 1
Sleep(1000000000000)
;idle
WEnd
Func _search()
$title = GUICtrlRead($Input1)
$text = GUICtrlRead($Input2)
$controls = _listcontrols($title,$text)
If $controls = 0 And @error = 1 Then
MsgBox(16,"Error","Dieses Fenster existiert nicht.")
Return
EndIf
If $controls = 0 And @error = 2 Then
MsgBox(16,"Error","Dieses Fenster bentzt keine Standartcontrols. Es kann nicht Ferngesteuert werden.")
Return
EndIf
For $i = 1 To $controls[0]
GUICtrlCreateListViewItem($controls[$i]&"|"&ControlGetText($title,$text,$controls[$i]),$list1)
Next
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"WinWait('"&$title&"','"&$text&"')"&@CRLF)
EndFunc
Func _listcontrols($title,$text="")
If Not WinExists($title,$text) Then Return SetError(1,Default,0)
$class = WinGetClassList($title,$text)
$class = StringSplit($class,@LF)
If Not IsArray($class) Then Return SetError(2,Default,0)
_Array2DDblDel($class)
Local $ret[1];[2]
For $i = 1 To UBound($class)-1
$count = 1
While True
If IsHWnd(ControlGetHandle($title,$text,$class[$i]&$count)) Then
_ArrayAdd($ret,$class[$i]&$count);ControlGetText($title,$text,$class[$i]&$count))
Else
ExitLoop
EndIf
$count = $count +1
WEnd
Next
$ret[0] = UBound($ret) -1
Return $ret
EndFunc
Func _exit()
Exit
EndFunc
#region conclick
Func _conclick_gui()
GUISetState(@SW_SHOW,$conclick_gui)
EndFunc
Func _conclick_ok()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
Select
Case GUICtrlRead($conclick_left) = 1
$method = "left"
Case GUICtrlRead($conclick_middle) = 1
$method = "middle"
Case GUICtrlRead($conclick_right) = 1
$method = "right"
Case Else
$method = "left"
EndSelect
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlClick('"&$title&"','"&$text&"','"&$ClassnameNN[1]&"','"&$method&"','"&GUICtrlRead($conclick_anzahl)&")"&@CRLF)
GUISetState(@SW_HIDE,$conclick_gui)
ControlClick($title,$text,$ClassnameNN[1],$method,GUICtrlRead($conclick_anzahl))
EndFunc
Func _conclick_abbr()
GUISetState(@SW_HIDE,$conclick_gui)
EndFunc
#endregion conclick
#region consend
Func _consend_gui()
GUISetState(@SW_SHOW,$consend_gui)
EndFunc
Func _consend_ok()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
$sendstring = StringReplace(StringReplace(GUICtrlRead($consettext_string,$consettext_gui),@CRLF,"'&@CRLF&'"),"&&","&")
If StringRight($sendstring,1) = "&" Then
$sendstring = StringTrimRight($sendstring,1)
EndIf
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlSend("&$title&"','"&$text&"','"&$ClassnameNN[1]&"','"&$sendstring&"')"&@CRLF)
GUISetState(@SW_HIDE,$consend_gui)
ControlSend($title,$text,$ClassnameNN[1],$sendstring)
EndFunc
Func _consend_abbr()
GUISetState(@SW_HIDE,$consend_gui)
EndFunc
#endregion consend
#region consend
Func _consettext_gui()
GUISetState(@SW_SHOW,$consettext_gui)
EndFunc
Func _consettext_ok()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
$sendstring = StringReplace(StringReplace(GUICtrlRead($consettext_string,$consettext_gui),@CRLF,"'&@CRLF&'"),"&&","&")
If StringRight($sendstring,1) = "&" Then
$sendstring = StringTrimRight($sendstring,1)
EndIf
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlSetText("&$title&"','"&$text&"','"&$ClassnameNN[1]&"','"&$sendstring&"')"&@CRLF)
GUISetState(@SW_HIDE,$consettext_gui)
ControlSetText($title,$text,$ClassnameNN[1],$sendstring)
EndFunc
Func _consettext_abbr()
GUISetState(@SW_HIDE,$consettext_gui)
EndFunc
#endregion consend
#region ein paar cons^^
Func _conshow()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlShow("&$title&"','"&$text&"','"&$ClassnameNN[1]&"')"&@CRLF)
ControlShow($title,$text,$ClassnameNN[1])
EndFunc
Func _conhide()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlHide("&$title&"','"&$text&"','"&$ClassnameNN[1]&"')"&@CRLF)
ControlHide($title,$text,$ClassnameNN[1])
EndFunc
Func _conenable()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlEnable("&$title&"','"&$text&"','"&$ClassnameNN[1]&"')"&@CRLF)
ControlEnable($title,$text,$ClassnameNN[1])
EndFunc
Func _condisable()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlDisable("&$title&"','"&$text&"','"&$ClassnameNN[1]&"')"&@CRLF)
ControlDisable($title,$text,$ClassnameNN[1])
EndFunc
Func _confocus()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlFocus("&$title&"','"&$text&"','"&$ClassnameNN[1]&"')"&@CRLF)
ControlFocus($title,$text,$ClassnameNN[1])
EndFunc
#endregion ein paar cons^^
#region concommand
Func _concommand_gui()
EndFunc
#endregion concommand
#region conmove
Func _conmove_gui()
GUISetState(@SW_SHOW,$conmove_gui)
EndFunc
Func _conmove_ok()
$ClassnameNN = StringSplit(GUICtrlRead(GUICtrlRead($List1),2),"|")
GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&"ControlMove("&$title&"','"&$text&"','"&$ClassnameNN[1]&"',"&$conmove_x&","&$conmove_y&","&$conmove_width&","&$conmove_height&")"&@CRLF)
ControlMove($title,$text,$ClassnameNN[1],$conmove_x,$conmove_y,$conmove_width,$conmove_height)
GUISetState(@SW_HIDE,$conmove_gui)
EndFunc
Func _conmove_abbr()
GUISetState(@SW_HIDE,$conmove_gui)
EndFunc
#endregion concommand
Die Anwendung ist sehr einfach...
1. man gibt den Titel und optional nochden text eines Fensters ein.
2. man klickt auf 'suchen'
3. man wählt eine Controlfunktion aus(controlcommand geht noch nicht)
4. entweder es plopt ein kleines Fenster auf oder, wenn der Befehl keine zusätzlichen parameter mehr braucht, wird der befehl direkt ausgeführt und in das Editfeld geschreiben.
Und so kann man sich ganz einfach einen Installerinstaller selbst bauen
grez
Ps: 'markieren'geht auch nochnicht^^