Sobiech Posted September 12, 2009 Posted September 12, 2009 Hi all expandcollapse popupOpt("MouseCoordMode",2) $INI = @ScriptDir & "\bot.ini" $Window = IniRead($INI, "Nvm", "D2 Window", "") $D2WHERE = IniRead($INI, "Nvm", "D2 Path", "") _MouseClickPlus($Window,"right",524,230, 1) Sleep(1500) ControlSend($Window, "", "", "{Enter}") Sleep(120) ControlSend($Window, "", "", "this is a line of text in the notepad window") ;=============================================================================== ; ; Function Name: _MouseClickPlus() ; Version added: 0.1 ; Description: Sends a click to window, not entirely accurate, but works ; minimized. ; Parameter(s): $Window = Title of the window to send click to ; $Button = "left" or "right" mouse button ; $X = X coordinate ; $Y = Y coordinate ; $Clicks = Number of clicks to send ; Remarks: You MUST be in "MouseCoordMode" 0 to use this without bugs. ; Author(s): Insolence <insolence_9@yahoo.com> ; ;=============================================================================== Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1) Local $MK_LBUTTON = 0x0001 Local $WM_LBUTTONDOWN = 0x0201 Local $WM_LBUTTONUP = 0x0202 Local $MK_RBUTTON = 0x0002 Local $WM_RBUTTONDOWN = 0x0204 Local $WM_RBUTTONUP = 0x0205 Local $WM_MOUSEMOVE = 0x0200 Local $i = 0 Select Case $Button = "left" $Button = $MK_LBUTTON $ButtonDown = $WM_LBUTTONDOWN $ButtonUp = $WM_LBUTTONUP Case $Button = "right" $Button = $MK_RBUTTON $ButtonDown = $WM_RBUTTONDOWN $ButtonUp = $WM_RBUTTONUP EndSelect If $X = "" OR $Y = "" Then $MouseCoord = MouseGetPos() $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf For $i = 1 to $Clicks DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $WM_MOUSEMOVE, _ "int", 0, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonDown, _ "int", $Button, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonUp, _ "int", $Button, _ "long", _MakeLong($X, $Y)) Next EndFunc Func _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc The problem is with "ControlSend($Window, "", "", "this is a line of text in the notepad window")" <--- program work without errors but the text is gone This doesnt work like "ControlSend($Window, "", "", "{Enter}")" or "_MouseClickPlus($Window,"right",524,230, 1)" who work very good Can someone tell me why it doesnt work and where is the problem? This world is crazy
Hawkwing Posted September 12, 2009 Posted September 12, 2009 Try ControlSend($Window, "", 15, "this is a line of text in the notepad window") btw, you can get controlid's with the autoit window info tool. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 Try ControlSend($Window, "", 15, "this is a line of text in the notepad window") btw, you can get controlid's with the autoit window info tool. >>>> Window <<<< Title: Diablo II Class: Diablo II Position: 260, 252 Size: 806, 625 Style: 0x14C00000 ExStyle: 0x00040100 Handle: 0x001003CA >>>> Control <<<< Class: Instance: ClassnameNN: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: 0x001703AC >>>> Mouse <<<< Position: 275, 269 Cursor ID: 2 Color: 0x484848 >>>> StatusBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<< Still doesnt work This world is crazy
Hawkwing Posted September 12, 2009 Posted September 12, 2009 Um, I meant for you to try it with notepad window, cause that seemed to be the problem you were having. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 Um, I meant for you to try it with notepad window, cause that seemed to be the problem you were having.^^I want use "controlsend" to game windowbtw thx for idea This world is crazy
Hawkwing Posted September 12, 2009 Posted September 12, 2009 You might be able to use the handle of the control instead of the id, but I'm not sure. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 You might be able to use the handle of the control instead of the id, but I'm not sure.I tried, but fail This world is crazy
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 (edited) Bump expandcollapse popupOpt("MouseCoordMode",2) Opt("WinTitleMatchMode",3) Opt("TrayAutoPause", 0) Opt("SendKeyDelay", 25) Opt("SendAttachMode", 1) HotKeySet("{F1}", "start") HotKeySet("{F2}", "quit") $INI = @ScriptDir & "\Nvm.ini" $Window = IniRead($INI, "Nvm", "Diablo II Window", "") $D2WHERE = IniRead($INI, "Nvm", "Diablo II Path", "") $hwnd = WinGetHandle($Window) While 1 Sleep(100) WEnd Func start() _MouseClickPlus($Window,"right",524,230, 1) Sleep(1500) ControlSend("", "", $hwnd, "{Enter}") Sleep(120) ControlSend("", "", $hwnd, "lol") Sleep(120) ControlSend("", "", $hwnd, "{Enter}") EndFunc Func Quit() Exit EndFunc ;=============================================================================== ; ; Function Name: _MouseClickPlus() ; Version added: 0.1 ; Description: Sends a click to window, not entirely accurate, but works ; minimized. ; Parameter(s): $Window = Title of the window to send click to ; $Button = "left" or "right" mouse button ; $X = X coordinate ; $Y = Y coordinate ; $Clicks = Number of clicks to send ; Remarks: You MUST be in "MouseCoordMode" 0 to use this without bugs. ; Author(s): Insolence <insolence_9@yahoo.com> ; ;=============================================================================== Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1) Local $MK_LBUTTON = 0x0001 Local $WM_LBUTTONDOWN = 0x0201 Local $WM_LBUTTONUP = 0x0202 Local $MK_RBUTTON = 0x0002 Local $WM_RBUTTONDOWN = 0x0204 Local $WM_RBUTTONUP = 0x0205 Local $WM_MOUSEMOVE = 0x0200 Local $i = 0 Select Case $Button = "left" $Button = $MK_LBUTTON $ButtonDown = $WM_LBUTTONDOWN $ButtonUp = $WM_LBUTTONUP Case $Button = "right" $Button = $MK_RBUTTON $ButtonDown = $WM_RBUTTONDOWN $ButtonUp = $WM_RBUTTONUP EndSelect If $X = "" OR $Y = "" Then $MouseCoord = MouseGetPos() $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf For $i = 1 to $Clicks DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $WM_MOUSEMOVE, _ "int", 0, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonDown, _ "int", $Button, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonUp, _ "int", $Button, _ "long", _MakeLong($X, $Y)) Next EndFunc Func _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc ControlSend work only with {enter} but dont write "lol" (only if game is minimized, if the game is active then it works fine) Edited September 12, 2009 by Sobiech This world is crazy
Hawkwing Posted September 12, 2009 Posted September 12, 2009 Yeah, I've noticed that controlclick won't work with minimized windows. Just make a traymenu with an option to "minimize" the Diablo II window and then have it hide/unhide it instead of using normal minimizing. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 Just make a traymenu with an option to "minimize" the Diablo II window and then have it hide/unhide it instead of using normal minimizing.how?WinGetState?WinSetState? This world is crazy
Hawkwing Posted September 12, 2009 Posted September 12, 2009 HotKeySet("{esc}", "hideshow") $state = "show" $window = GUICreate("") GUISetState() While 1 Sleep(100) WEnd Func hideshow() If $state = "show" Then WinSetState($window, "", @SW_HIDE) $state = "hide" Else WinSetState($window, "", @SW_SHOW) $state = "show" EndIf EndFunc I used a hotkey because it was faster to write, but if your going to want it in the background it would probably be better to use a traymenu. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 HotKeySet("{esc}", "hideshow") $state = "show" $window = GUICreate("") GUISetState() While 1 Sleep(100) WEnd Func hideshow() If $state = "show" Then WinSetState($window, "", @SW_HIDE) $state = "hide" Else WinSetState($window, "", @SW_SHOW) $state = "show" EndIf EndFunc I used a hotkey because it was faster to write, but if your going to want it in the background it would probably be better to use a traymenu. K sounds good but i must have active GUI window to do this trick if i activate something else than GUI Window then bot stopped work This world is crazy
Hawkwing Posted September 12, 2009 Posted September 12, 2009 Better explanation please. This works fine for me. HotKeySet("{esc}", "hideshow") $state = "show" $window = WinGetHandle("Why ControlSend doesnt work - AutoIt Forums - Google Chrome") While 1 Sleep(100) WEnd Func hideshow() If $state = "show" Then WinSetState($window, "", @SW_HIDE) $state = "hide" Else WinSetState($window, "", @SW_SHOW) $state = "show" EndIf EndFunc The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
Sobiech Posted September 12, 2009 Author Posted September 12, 2009 (edited) Better explanation please. This works fine for me. HotKeySet("{esc}", "hideshow") $state = "show" $window = WinGetHandle("Why ControlSend doesnt work - AutoIt Forums - Google Chrome") While 1 Sleep(100) WEnd Func hideshow() If $state = "show" Then WinSetState($window, "", @SW_HIDE) $state = "hide" Else WinSetState($window, "", @SW_SHOW) $state = "show" EndIf EndFunc LOL Work, my fail Big THX 4 you for your help and time who left for me Edited September 12, 2009 by Sobiech This world is crazy
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