skitt Posted July 4, 2009 Share Posted July 4, 2009 (edited) I have two windows named the same thing. How can i seperate them apart persay, so i can send commands to only one of them. IE:controlsending stuff. i tried winsettitle but obviously that didnt work right since theres two windows of the same name. controlsend(......, "", "")both windows have the same everything. and i know how controlsend works, i just need it to work for a handle, not window title. Edited July 4, 2009 by skitt Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 4, 2009 Share Posted July 4, 2009 I have two windows named the same thing. How can i seperate them apart persay, so i can send commands to only one of them. IE: controlsending stuff. i tried winsettitle but obviously that didnt work right since theres two windows of the same name. controlsend(......, "", "") Just get the handles and use those. The handle stays the same for the life of the window, even if the title changes, and it is completely unique no matter how many similar windows are open. Demo: #include <GuiConstantsEx.au3> Opt("GuiOnEventMode", 1) Global $n1 = 0, $n2 = 0 Global $hGUI_1 = GUICreate("Test GUI", 300, 300, 200, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUICtrlCreateLabel("This window's handle = " & $hGUI_1, 20, 20, 260, 20) Global $ctrlLabel_1 = GUICtrlCreateLabel("n + 1 = 0", 20, 60, 100, 20) GUISetState() Global $hGUI_2 = GUICreate("Test GUI", 300, 300, 400, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUICtrlCreateLabel("This window's handle = " & $hGUI_2, 20, 20, 260, 20) Global $ctrlLabel_2 = GUICtrlCreateLabel("n + 5 = 0", 20, 60, 100, 20) GUISetState() While 1 Sleep(500) $n1 += 1 ControlSetText($hGUI_1, "", $ctrlLabel_1, "n + 1 = " & $n1) $n2 += 5 ControlSetText($hGUI_2, "", $ctrlLabel_2, "n + 5 = " & $n2) WEnd Func _Quit() If @GUI_WinHandle = $hGUI_1 Then MsgBox(64, "Quit", "Closed from GUI 1.", 2) ElseIf @GUI_WinHandle = $hGUI_2 Then MsgBox(64, "Quit", "Closed from GUI 2.", 2) EndIf Exit EndFunc ;==>_Quit Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DCCD Posted July 4, 2009 Share Posted July 4, 2009 what do you mean by IE? two Internet Explorer windows that have almost the same title! [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
skitt Posted July 4, 2009 Author Share Posted July 4, 2009 what im having trouble with though, is putting the handle in for controlsend(). what i have right now is this. (gives an error) Global $hwnd = "0x00000000001E0574" ControlSend($hwnd, "", "", "5") Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 4, 2009 Share Posted July 4, 2009 Do both windows have the same text content? That can be used to identify a particular window as well.Function ControlSend - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
skitt Posted July 4, 2009 Author Share Posted July 4, 2009 (edited) both windows have the same everything. and i know how controlsend works, i just need it to work for a handle, not window title. Edited July 4, 2009 by skitt Link to comment Share on other sites More sharing options...
skitt Posted July 4, 2009 Author Share Posted July 4, 2009 bump for the sake of an easy problem. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 4, 2009 Share Posted July 4, 2009 what im having trouble with though, is putting the handle in for controlsend(). what i have right now is this. (gives an error) Global $hwnd = "0x00000000001E0574" ControlSend($hwnd, "", "", "5") You would normally get the handle with WinGetHandle(), and you can use the INSTANCE parameter if there is more than one. You could get a list of all matches in an array with WinList(). If you really MUST create the handle from a literal (which rarely makes sense because the handle will be different every time the window is created), then you would use HWnd() to create the correct variant type. #include <Array.au3> For $n = 1 To 2 $hwnd = WinGetHandle("[CLASS:Window_Class; TITLE:Window_Title; INSTANCE:" & $n & "]", "") MsgBox(64, "Instance: " & $n, "HWnd = " & $hwnd) Next $avHwnd = WinList("[CLASS:Window_Class; TITLE:Window_Title]", "") _ArrayDisplay($avHwnd, "$avHwnd") $hwnd = HWnd(0x001E0574) MsgBox(64, "Literal", "HWnd = " & $hwnd & ", Type = " & VarGetType($hwnd)) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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