DW1 Posted October 17, 2007 Share Posted October 17, 2007 I don't know why this isn't adding the button to notepad... #include<ANYGUI.au3> $PID = Run("notepad.exe") $HWND = WinGetHandle("Untitled") _GuiTarget ($HWND, 1) $button = _TargetaddButton ("button", 0, 0, 100, 100) GUISetState(@SW_SHOW) _EndTarget () While ProcessExists( $PID ) Sleep(10) WEnd AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted October 17, 2007 Author Share Posted October 17, 2007 *BUMP* (sorry) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2007 Share Posted October 17, 2007 This works.... expandcollapse popup#include <Array.au3> #include <ANYGUIv2.8.au3> #include <guiconstants.au3> #Include <GuiTab.au3> Opt ("WinTitleMatchMode", 3) Opt ("WinWaitDelay", 0) Opt ("GUIOnEventMode", 1) Const $MF_BYCOMMAND = 0x0 Const $MF_BYPOSITION = 0x400 Const $MF_REMOVE = 0x1000 $pid = Run("notepad.exe") WinWait("Untitled - Notepad") WinWaitActive("Untitled - Notepad") $hWnd = _GuiTarget ("Untitled - Notepad", 1) ; ************************* ; _RemoveSystemMenus($hWnd) _RemoveMenus($hWnd) ; ************************* $child = _TargetaddChild ("", 0, 0, 5000, 20, $hWnd) $newtab = GUICtrlCreateButton("+", 0, 0, 20, 20, $BS_ICON + $BS_FLAT) $closetab = GUICtrlCreateButton("X", 25, 0, 20, 20, $BS_ICON + $BS_FLAT) $tab = GUICtrlCreateTab(50, 0, 5000, 20) $tabs = _ArrayCreate (GUICtrlCreateTabItem("Untitled")) GUICtrlCreateTabItem("") GUICtrlSetImage($newtab, "shell32.dll", 225, 0) GUICtrlSetImage($closetab, "shell32.dll", 131, 0) GUICtrlSetOnEvent($newtab, "onNewTab") GUICtrlSetOnEvent($closetab, "onCloseTab") GUISetState(@SW_SHOW) While WinExists($hWnd) $size = WinGetClientSize($hWnd) If WinExists($hWnd) Then ControlMove($hWnd, "", 15, 0, 20, $size[0], $size[1] - 43) ControlMove($hWnd, "", "SysTabControl321", 25, 0, $size[0] - 50, 20) ControlMove($hWnd, "", "Button2", $size[0] - 20, 0, 20, 20) EndIf Sleep(100) WEnd Func onNewTab() _ArrayAdd($tabs, GUICtrlCreateTabItem("Untitled")) GUICtrlCreateTabItem("") EndFunc ;==>onNewTab Func onCloseTab() $curr = _GUICtrlTabGetCurSel ($tab) $num = _GUICtrlTabGetItemCount ($tab) If $curr < $num - 1 Then _GUICtrlTabDeleteItem ($tab, $curr) _ArrayDelete($tabs, $curr) _GUICtrlTabSetCurSel ($tab, $curr) ElseIf $num > 1 Then _GUICtrlTabDeleteItem ($tab, $curr) _ArrayDelete($tabs, $curr) _GUICtrlTabSetCurSel ($tab, $num - 2) Else _ArrayAdd($tabs, GUICtrlCreateTabItem("Untitled")) GUICtrlCreateTabItem("") _GUICtrlTabSetCurSel ($tab, 1) _GUICtrlTabDeleteItem ($tab, 0) _ArrayDelete($tabs, 0) EndIf EndFunc ;==>onCloseTab Func _RemoveMenus($hWnd) $ret = DllCall("user32.dll", "int", "GetMenu", "hwnd", $hWnd) $h_menu = $ret[0] $ret = DllCall("user32.dll", "int", "GetMenuItemCount", "int", $h_menu) $m_count = $ret[0] For $x = $m_count - 1 To 0 Step - 1 $ret = DllCall("user32.dll", "int", "DeleteMenu", "int", $h_menu, "int", $x, "int", $MF_BYPOSITION) Next DllCall("user32.dll", "int", "DrawMenuBar", "hwnd", $hWnd) EndFunc ;==>_RemoveMenus Func _RemoveSystemMenus($hWnd) $ret = DllCall("user32.dll", "int", "GetSystemMenu", "hwnd", $hWnd, "int", 0) $h_menu = $ret[0] $ret = DllCall("user32.dll", "int", "GetMenuItemCount", "int", $h_menu) $m_count = $ret[0] For $x = $m_count - 1 To 0 Step - 1 $ret = DllCall("user32.dll", "int", "DeleteMenu", "int", $h_menu, "int", $x, "int", $MF_BYPOSITION) Next EndFunc ;==>_RemoveSystemMenus 8) Link to comment Share on other sites More sharing options...
DW1 Posted October 17, 2007 Author Share Posted October 17, 2007 Thanks, but I wanted to know why the code I posted IS NOT working AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2007 Share Posted October 17, 2007 At times, I need to look at what works to see why mine doesn't #include<ANYGUI.au3> $PID = Run("notepad.exe") WinWaitActive("") $hWnd = _GuiTarget ("Untitled - Notepad", 1) $child = _TargetaddChild ("", 0, 0, 5000, 60, $hWnd) $button2 = _TargetaddButton ("button", 0, 0, 100, 100) GUISetState(@SW_SHOW) _EndTarget () While WinExists($hWnd) $size = WinGetClientSize($hWnd) If WinExists($hWnd) Then ControlMove($hWnd, "", 15, 0, 100, $size[0], $size[1] - 100) ControlMove($hWnd, "", "SysTabControl321", 25, 0, $size[0] - 50, 20) ControlMove($hWnd, "", "Button2", $size[0] - 20, 0, 20, 20) EndIf Sleep(100) WEnd...Your Welcome!8) Link to comment Share on other sites More sharing options...
DW1 Posted October 17, 2007 Author Share Posted October 17, 2007 Thank you so much Valuater, I didn't mean to come off ungrateful. I now see where I went wrong. Thanks AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Valuater Posted October 18, 2007 Share Posted October 18, 2007 I had to do this to get a responce from the button #include<ANYGUI.au3> Opt ("GUIOnEventMode", 1) $PID = Run("notepad.exe") WinWaitActive("") $hWnd = _GuiTarget ("Untitled - Notepad", 1) $child = _TargetaddChild ("", 0, 0, 5000, 100, $hWnd) $button2 = GUICtrlCreateButton ("button", 0, 0, 100, 100) GUICtrlSetOnEvent($button2, "Eventer") GUISetState(@SW_SHOW) _EndTarget () While WinExists($hWnd) $size = WinGetClientSize($hWnd) If WinExists($hWnd) Then ControlMove($hWnd, "", 15, 0, 100, $size[0], $size[1] - 100) ControlMove($hWnd, "", "Button2", $size[0] - 20, 0, 20, 20) EndIf Sleep(100) WEnd Func Eventer() MsgBox(0x0,"", "test", 3) EndFunc 8) 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