Flamingwolf Posted November 17, 2007 Share Posted November 17, 2007 I recently started a project to help with botting in a game called MonkeyStory. I wanted to use ControlSend so that I could bot minimized, and it worked perfectly. A while later my friend asked me to get it working for another game, and so I made it so you could customize the window title/control ID/what to send/delay to send it at. As I suspected, it also worked great. My next goal was to have a hotkey set to grab the current control ID so that it would be easier to grab instead of having to open up Au3Info.exe every time I wanted to use it on a different program. I can't however find anything anywhere on how to grab the current control ID/ClassnameNN. If anyone has any suggestions they would be greatly appreciated. =] Link to comment Share on other sites More sharing options...
Nahuel Posted November 17, 2007 Share Posted November 17, 2007 (edited) Take a look at this great script:expandcollapse popup#include <misc.au3> #include <Array.au3> HotKeySet('{ESC}', '_Exit') Global $WinText, $OldMouse[2], $NewMouse[2], $Windows, $x, $MyWin, $MyCoords While 1 $NewMouse = MouseGetPos() If $NewMouse[0] <> $OldMouse[0] Or $NewMouse[1] <> $OldMouse[1] Then ToolTip(_GetWin()) Sleep(100) WEnd Func _GetWin() Local $Coords ToolTip("") $Mouse = MouseGetPos() $OldMouse = $Mouse $Windows = _WinList() ;_ArrayDisplay($Windows, "") For $x = 1 To UBound($Windows)-1 $Coords = WinGetPos($Windows[$x][0], "") If $Coords = -4 Then ExitLoop If IsArray($Coords) Then If $Mouse[0] >= $Coords[0] And $Mouse[0] <= ($Coords[0]+$Coords[2]) And $Mouse[1] >= $Coords[1] And $Mouse[1] <= ($Coords[1]+$Coords[3]) Then ExitLoop EndIf Next If $x = UBound($Windows) Then $x -= 1 $MyWin = $Windows[$x][0] $Control = _MouseGetCtrlInfo() $Return = $Windows[$x][0] & @CRLF & $Control Return $Return EndFunc Func _WinList() Local $WinListArray[1][2] $var = WinList() For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then Redim $WinListArray[UBound($WinListArray) + 1][2] $WinListArray[UBound($WinListArray)-1][0] = $var[$i][0] $WinListArray[UBound($WinListArray)-1][1] = $var[$i][1] EndIf Next Return $WinListArray EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Func _Exit() Exit EndFunc Func _MouseGetCtrlInfo() ; get ID, Classe and Text of a control Global $hWin = WinGetHandle($MyWin) Global $sClassList = WinGetClassList($hWin) Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF) Local $aMPos = MouseGetPos() ;_ArrayDisplay($sSplitClass, "") $MyCoords = ClientToScreen($hWin) For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1 Local $nCount = 0 If $sSplitClass[$iCount] = "WorkerW" Then ContinueLoop While 1 $nCount += 1 $aCPos = ControlGetPos($hWin, '', $sSplitClass[$iCount] & $nCount) If @error Then ExitLoop $hCtrlWnd = ControlGetHandle ($hWin, "", $sSplitClass[$iCount] & $nCount) If IsArray($aCPos) Then If $aMPos[0] >= ($MyCoords[0]+$aCPos[0]) And $aMPos[0] <= ($MyCoords[0]+$aCPos[0] + $aCPos[2]) _ And $aMPos[1] >= ($MyCoords[1]+$aCPos[1]) And $aMPos[1] <= ($MyCoords[1]+$aCPos[1] + $aCPos[3]) Then $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd) If @error Then Return "Err" $Text = ControlGetText($hWin, '', $sSplitClass[$iCount] & $nCount) If StringInStr($Text, @LF) Then $Text = "demasiado largo" If IsArray($aReturn) Then Return 'ControlID: ' & $aReturn[0] & @CRLF & 'ClassNameNN: ' & $sSplitClass[$iCount] & $nCount & @CRLF & "Text: " & $Text EndIf EndIf WEnd Next ;_ArrayDisplay($sSplitClass, "") Return "No Ctrl" EndFunc Func ClientToScreen($hWnd) ; get client area of a win relative to the screan Local $Point, $aRes[2] Local $cX, $cY $Point = DllStructCreate("int;int") DllStructSetData($Point, 1, $cX) DllStructSetData($Point, 1, $cY) DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($Point)) $aRes[0] = DllStructGetData($Point, 1) $aRes[1] = DllStructGetData($Point, 2) Return $aRes EndFuncI forgot who made it. Gimme a few minutes and I'll find the author so you can give him some credit -edit-It was Smoke_N and grham apparently:http://www.autoitscript.com/forum/index.ph...st&p=413756 Edited November 17, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 17, 2007 Moderators Share Posted November 17, 2007 Take a look at this great script: expandcollapse popup#include <misc.au3> #include <Array.au3> HotKeySet('{ESC}', '_Exit') Global $WinText, $OldMouse[2], $NewMouse[2], $Windows, $x, $MyWin, $MyCoords While 1 $NewMouse = MouseGetPos() If $NewMouse[0] <> $OldMouse[0] Or $NewMouse[1] <> $OldMouse[1] Then ToolTip(_GetWin()) Sleep(100) WEnd Func _GetWin() Local $Coords ToolTip("") $Mouse = MouseGetPos() $OldMouse = $Mouse $Windows = _WinList() ;_ArrayDisplay($Windows, "") For $x = 1 To UBound($Windows)-1 $Coords = WinGetPos($Windows[$x][0], "") If $Coords = -4 Then ExitLoop If IsArray($Coords) Then If $Mouse[0] >= $Coords[0] And $Mouse[0] <= ($Coords[0]+$Coords[2]) And $Mouse[1] >= $Coords[1] And $Mouse[1] <= ($Coords[1]+$Coords[3]) Then ExitLoop EndIf Next If $x = UBound($Windows) Then $x -= 1 $MyWin = $Windows[$x][0] $Control = _MouseGetCtrlInfo() $Return = $Windows[$x][0] & @CRLF & $Control Return $Return EndFunc Func _WinList() Local $WinListArray[1][2] $var = WinList() For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then Redim $WinListArray[UBound($WinListArray) + 1][2] $WinListArray[UBound($WinListArray)-1][0] = $var[$i][0] $WinListArray[UBound($WinListArray)-1][1] = $var[$i][1] EndIf Next Return $WinListArray EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Func _Exit() Exit EndFunc Func _MouseGetCtrlInfo() ; get ID, Classe and Text of a control Global $hWin = WinGetHandle($MyWin) Global $sClassList = WinGetClassList($hWin) Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF) Local $aMPos = MouseGetPos() ;_ArrayDisplay($sSplitClass, "") $MyCoords = ClientToScreen($hWin) For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1 Local $nCount = 0 If $sSplitClass[$iCount] = "WorkerW" Then ContinueLoop While 1 $nCount += 1 $aCPos = ControlGetPos($hWin, '', $sSplitClass[$iCount] & $nCount) If @error Then ExitLoop $hCtrlWnd = ControlGetHandle ($hWin, "", $sSplitClass[$iCount] & $nCount) If IsArray($aCPos) Then If $aMPos[0] >= ($MyCoords[0]+$aCPos[0]) And $aMPos[0] <= ($MyCoords[0]+$aCPos[0] + $aCPos[2]) _ And $aMPos[1] >= ($MyCoords[1]+$aCPos[1]) And $aMPos[1] <= ($MyCoords[1]+$aCPos[1] + $aCPos[3]) Then $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd) If @error Then Return "Err" $Text = ControlGetText($hWin, '', $sSplitClass[$iCount] & $nCount) If StringInStr($Text, @LF) Then $Text = "demasiado largo" If IsArray($aReturn) Then Return 'ControlID: ' & $aReturn[0] & @CRLF & 'ClassNameNN: ' & $sSplitClass[$iCount] & $nCount & @CRLF & "Text: " & $Text EndIf EndIf WEnd Next ;_ArrayDisplay($sSplitClass, "") Return "No Ctrl" EndFunc Func ClientToScreen($hWnd) ; get client area of a win relative to the screan Local $Point, $aRes[2] Local $cX, $cY $Point = DllStructCreate("int;int") DllStructSetData($Point, 1, $cX) DllStructSetData($Point, 1, $cY) DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($Point)) $aRes[0] = DllStructGetData($Point, 1) $aRes[1] = DllStructGetData($Point, 2) Return $aRes EndFunc I forgot who made it. Gimme a few minutes and I'll find the author so you can give him some credit -edit- It was grham apparently: http://www.autoitscript.com/forum/index.ph...st&p=413756Looks like he tore apart a few of my functions. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nahuel Posted November 17, 2007 Share Posted November 17, 2007 Oh, sorry. I had no idea... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 17, 2007 Moderators Share Posted November 17, 2007 Oh, sorry. I had no idea...No worries, I just noticed my coding style, then I saw it not so much my style lol. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
grham Posted November 19, 2007 Share Posted November 19, 2007 No worries, I just noticed my coding style, then I saw it not so much my style lol.but I mentioned you (and another user) as an author of ((mayor?)a part ?) in that thread.I only adapted it a little to my needs and now a little more (using it for drag and drop on an iconin the explorer).OK Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 19, 2007 Moderators Share Posted November 19, 2007 but I mentioned you (and another user) as an author of ((mayor?)a part ?) in that thread.I only adapted it a little to my needs and now a little more (using it for drag and drop on an iconin the explorer).OK No worries as I said... I'm sure many do it to everyone... I wouldn't have posted (the code) it if I really cared. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now