-
Posts
11 -
Joined
-
Last visited
Everything posted by Smiley1244
-
Sorry for the slow reply I've progressed this further but I've run into a few issues. No, I'm not recalling the "desktop size", I am recalling the original working area (desktop minus taskbar space). 1. I still haven't found a way to handle multiple monitors so only works with the primary screen. 2. Any displayed UAC prompt (only tested with Windows 7) resets the original working area. Is there a way to detect a UAC prompt being displayed? 3. The WinMinimizeAll, WinMinimizeAllUndo method of resizing maximized windows after changing the working area caused numerous issues. It was screwing up some windows so they were always on top and other weird issues. This might be due to my system being 4 screens from two graphics cards. I'm currently using ************* func _MinMaxedWindows() Local $aWinList = WinList() Local $TopWindow = "" For $i=1 to $aWinList[0][0] If $aWinList[$i][0]<>"Program Manager" And $aWinList[$i][0]<>"Start" And $aWinList[$i][0]<>"" And BitAND(WinGetState($aWinList[$i][1]),32) = 32 Then WinSetState($aWinList[$i][0],"",@SW_MINIMIZE) WinSetState($aWinList[$i][0],"",@SW_MAXIMIZE) EndIf Next WinActivate($TopWindow) EndFunc ************* But it is slow if lots of windows are open Any suggestions would be greatly appreciated.
-
Yes, well no, the original working area.
-
Sorry Guinness when I said similar, I meant I'd built something similar from M23's code that recalls the original values. 'WinList & _WinAPI_RedrawWindow with the flag $RDW_FRAME.' didn't work, but I found a low tech solution . . . WinMinimizeAll() WinMinimizeAllUndo() Which works pretty well Thanks again to you both, I'll read up on the Win_API calls.
-
Hi Guinness, That's similar to the way I'm using M23's code. Do you know is there an easy way to get all existing windows to redraw? I thought it might be '$SPIF_SENDCHANGE' but that doesn't seem to affect the other windows?! Maybe using '_WinAPI_RedrawWindow'? Also is there a way to handle multiply screens? as everything currrently happens only on the primary display? Thank you both for your help on this
-
Yep the works, thanks M23. I've already adapted that to a working example. Thanks for the help. I'm sure you know this already but for anyone reading this, it might be a Windows 7 thing?! You can't hard re-set to the screen resolution as it puts windows behind the windows taskbar. Easy get round is to use keep the original values from _GetDesktopWorkArea. ;Store Original Desktop Sizes _GetDesktopWorkArea($iLeft, $iTop, $iRight, $iBottom) $aOriginalDesktopArea[0] = $iLeft $aOriginalDesktopArea[1] = $iTop $aOriginalDesktopArea[2] = $iRight $aOriginalDesktopArea[3] = $iBottom
-
Thanks M23, I'm very new to dll calling, only used once before. Could you give me a working example of the functions? In the meantime I extracted the relevant code and searching for key phrases I found the following example (posted by mat) that does work but is a lot different to yours (and it doesn't move already maximized windows but that minor). Global Const $SPI_SETWORKAREA = 0x002F Global Const $SPI_GETWORKAREA = 0x0030 Global Const $SPIF_UPDATEINIFILE = 0x0001 Global Const $SPIF_SENDWININICHANGE = 0x0002 Global Const $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE MsgBox (0, _SetWorkArea (-1, 100, -1, -1), @Error) Func _SetWorkArea ($iLeft = -1, $iTop = -1, $iRight = -1, $iBottom = -1) Local $aResult, $rect = DllStructCreate ("int[4]"), $pRect = DllStructGetPtr ($rect) ; Change -1's If $iLeft = -1 Then $iLeft = 0 If $iTop = -1 Then $iTop = 0 If $iRight = -1 Then $iRight = @DesktopWidth + 0 If $iBottom = -1 Then $iBottom = @DesktopHeight + 0 ; Set struct data DllStructSetData ($rect, 1, $iLeft , 1) ;left DllStructSetData ($rect, 1, $iTop , 2) ;top DllStructSetData ($rect, 1, $iRight , 3) ;right DllStructSetData ($rect, 1, $iBottom, 4) ;bottom ; Set the area $aResult = DllCall("user32.dll", _ "int", "SystemParametersInfo", _ "int", $SPI_SETWORKAREA, _ "int", 0, _ "ptr", $pRect, _ "int", $SPIF_SENDCHANGE) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ; ==> _SetWorkArea
-
Hi All, I've tried searching the forums for this but haven't found anything that does what I'm looking for. I'm trying to make a small form that sits at the top of the screen but reserves that screen space. So when a window is dragged or maximized it never covers the form. Just like the taskbar at the bottom (for most people). I can get the monitor(s) resolutions to make the form fit I just can't find a way to reserve the screen space?! Anyone done something similar or can point me in the right direction? Cheers
-
Block or change Combo context menu??
Smiley1244 replied to Smiley1244's topic in AutoIt GUI Help and Support
For anyone that stumbles across this; Here is the code that put together blocks the context menu of a combo box and displays a custom menu instead. I cannot take credit for any of this code but I've looked at so many pages today on this I cannot track back to who did what, I am however resposible for the mashing togther and for that I'm sorry I hope it helps someone #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GUIComboBox.au3> Global $iDLLUser32 = DllOpen("user32.dll");open a handle to user32.dll library Global $hGUI = GUICreate("Disable Edit Context Menu", 300, 200), $msg Global $cEdit1 = GUICtrlCreateCombo("", 8, 74, 262, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$CBS_UPPERCASE)) Global $tInfo, $hEdit1 Global $DummyMenu = GUICtrlCreateDummy() Global $ContextMenu = GUICtrlCreateContextMenu($DummyMenu) Global $CommonMenuItem = GUICtrlCreateMenuItem("Common", $ContextMenu) Global $FileMenuItem = GUICtrlCreateMenuItem("File", $ContextMenu) GUICtrlCreateMenuItem("", $ContextMenu) Global $ExitMenuItem = GUICtrlCreateMenuItem("Exit", $ContextMenu) If _GUICtrlComboBox_GetComboBoxInfo($cEdit1, $tInfo) Then $hEdit1 = DllStructGetData($tInfo, "hEdit") EndIf Global $wProcHandle = DllCallbackRegister("_EditWndProc", "ptr", "hwnd;uint;wparam;lparam") ;subclass the edit control by substituting its window procedure for our own "_EditWndProc" Global $wProcOld = _WinAPI_SetWindowLong($hEdit1, $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;restore the original window procedure callback. ;failure to call this func results in a script crash on exit _WinAPI_SetWindowLong($hEdit1, $GWL_WNDPROC, $wProcOld) ;free the callback function DllCallbackFree($wProcHandle) DllClose($iDLLUser32) GUIDelete($hGUI) Exit Func _EditWndProc($hWnd, $msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam Switch $hWnd Case $hEdit1 Switch $msg Case $WM_CONTEXTMENU ; About to show Context menu ShowMenu($hGUI, $ContextMenu) ;Show our context Return 1 ;Block system context EndSwitch EndSwitch ;pass on all other edit control messages to the controls original window procedure Local $aRet = DllCall($iDLLUser32, "int", "CallWindowProcW", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $msg, "wparam", $wParam, "lparam", $lParam) If @error Then Return 0 Return $aRet[0] EndFunc ;==>_EditWndProc Func ShowMenu($hWnd, $nContextID) Local $hMenu = GUICtrlGetHandle($nContextID) $arPos = MouseGetPos() Local $x = $arPos[0] Local $y = $arPos[1] DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc -
Block or change Combo context menu??
Smiley1244 replied to Smiley1244's topic in AutoIt GUI Help and Support
Thanks Melba, Got there in the end that works great. I can now display my custom menu options by using a dummy ctrl. It's very cut and paste from 3 peoples code but it woks and I can now tidy it up -
Block or change Combo context menu??
Smiley1244 replied to Smiley1244's topic in AutoIt GUI Help and Support
Hi and thanks, Is there no way of stopping it appearing then? I found a way for edit boxes but I am failing utterly to make it work for the input control. #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $iDLLUser32 = DllOpen("user32.dll");open a handle to user32.dll library ;this keeps an open handle to the library instead of opening and closing it with each call to CallWindowProcW() Global $hGUI = GUICreate("Disable Edit Context Menu", 300, 200), $msg Global $cEdit1 = GUICtrlCreateEdit("", 10, 10, 280, 150) Global $hEdit1 = GUICtrlGetHandle($cEdit1) ;register a callback function for the edit control window procedure Global $wProcHandle = DllCallbackRegister("_EditWndProc", "ptr", "hwnd;uint;wparam;lparam") ;subclass the edit control by substituting its window procedure for our own "_EditWndProc" Global $wProcOld = _WinAPI_SetWindowLong($hEdit1, $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;restore the original window procedure callback. ;failure to call this func results in a script crash on exit _WinAPI_SetWindowLong($hEdit1, $GWL_WNDPROC, $wProcOld) ;free the callback function DllCallbackFree($wProcHandle) DllClose($iDLLUser32) GUIDelete($hGUI) Exit ;subclassed edit control window procedure Func _EditWndProc($hWnd, $msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam Switch $hWnd Case $hEdit1 Switch $msg Case $WM_CONTEXTMENU ; block the context menu from running Return 1 EndSwitch EndSwitch ;pass on all other edit control messages to the controls original window procedure Local $aRet = DllCall($iDLLUser32, "int", "CallWindowProcW", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $msg, "wparam", $wParam, "lparam", $lParam) If @error Then Return 0 Return $aRet[0] EndFunc ;==>_EditWndProc -
Hi All, Firstly sorry if this is obvious, I'm teaching myself AutoIT from a self-taught understanding of VBS. I've been searching the forums and google to no avail. I'd like to create a context menu on a combo box (this combo box). $Input1 = GUICtrlCreateCombo("", 8, 74, 262, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$CBS_UPPERCASE)) I have used ; $ContextCombo = GUICtrlCreateContextMenu($Input1) $RightClickCopy = GUICtrlCreateMenuItem("Copy", $ContextCombo) GUICtrlSetOnEvent($RightClickCopy, "RightClickCopy") $RightClickPaste = GUICtrlCreateMenuItem("Paste", $ContextCombo) GUICtrlSetOnEvent($RightClickPaste, "RightClickPaste") Which works and give me the menu but only on the drop down arrow rather than on the whole box. From the text part of the control I get what looks like a system context menu. Can I replace this with my two options or hide the system menu so only the arrow works?