usera Posted March 10, 2011 Share Posted March 10, 2011 Greeting, Looking for a way to disable the red "X" in the right top cornor of the active window. for example I use script to launch "notepad.exe" but disable the "X" close so user can not close the notepad window but wait for a while then the script close it Thanks usera Link to comment Share on other sites More sharing options...
E1M1 Posted March 10, 2011 Share Posted March 10, 2011 Why do you need this I wonder? you can set windows style using _WinAPI_SetWindowLong() edited Link to comment Share on other sites More sharing options...
usera Posted March 10, 2011 Author Share Posted March 10, 2011 Thanks for quick feedback. Could you please little bit details please? usera Link to comment Share on other sites More sharing options...
E1M1 Posted March 10, 2011 Share Posted March 10, 2011 it's 100% doable with help file, you need to set notepad style toosomething that dont have red X. Style I dont remember but when you look at GUICReate from hel... that page has link to possible styles. edited Link to comment Share on other sites More sharing options...
usera Posted March 10, 2011 Author Share Posted March 10, 2011 I can understand that for create a new windows. but how to use it for existing application? for example winword.exe or notepad.exe? Thanks Link to comment Share on other sites More sharing options...
ChrisL Posted March 10, 2011 Share Posted March 10, 2011 (edited) Remove red x... or just disable it with Opt("GUIEventOptions",1)... #include <GUIConstantsEx.au3> Opt("GUIEventOptions",1) GuiCreate("Sample") $button = GuiCtrlCreateButton("Close",10,10) GuiSetState() While 1 $sMsg = GuiGetmsg() Switch $sMsg Case $GUI_EVENT_CLOSE ;Do nothing Case $GUI_EVENT_MINIMIZE GuiSetState(@SW_MINIMIZE) Case $GUI_EVENT_RESTORE GUISetState(@SW_RESTORE) Case $button Exit EndSwitch WEnd Edit:~ While I was writing this I then saw the on an external application bit so this wont be of any use! Edited March 10, 2011 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
usera Posted March 10, 2011 Author Share Posted March 10, 2011 So the idea is just this. I use script to launch "notepad.exe" then wait for it open. Since I use script to open it, So for sure I know all the information about the "notepad.exe" include the windows size, buttons. so from there I disable the red "X" button, that is all. Problem is do Not know how to write the code. usera Link to comment Share on other sites More sharing options...
Ascend4nt Posted March 11, 2011 Share Posted March 11, 2011 Credits to Melba23 for finding this. Change 1 to 0 to re-enable: #include <GuiMenu.au3> $hWnd=WinGetHandle("[CLASS:Notepad]") _GUICtrlMenu_EnableMenuItem(_GUICtrlMenu_GetSystemMenu($hWnd), $SC_CLOSE, 1, False) My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
usera Posted March 11, 2011 Author Share Posted March 11, 2011 Credits to Melba23 for finding this. Change 1 to 0 to re-enable: #include <GuiMenu.au3> $hWnd=WinGetHandle("[CLASS:Notepad]") _GUICtrlMenu_EnableMenuItem(_GUICtrlMenu_GetSystemMenu($hWnd), $SC_CLOSE, 1, False) Thanks for help, but really how to use it ? I am just new. usera Link to comment Share on other sites More sharing options...
usera Posted March 11, 2011 Author Share Posted March 11, 2011 thanks, figured out. Link to comment Share on other sites More sharing options...
usera Posted March 11, 2011 Author Share Posted March 11, 2011 Credits to Melba23 for finding this. Change 1 to 0 to re-enable: #include <GuiMenu.au3> $hWnd=WinGetHandle("[CLASS:Notepad]") _GUICtrlMenu_EnableMenuItem(_GUICtrlMenu_GetSystemMenu($hWnd), $SC_CLOSE, 1, False) thanks for line $hWnd=WinGetHandle("[CLASS:Notepad]") if I use winword.exe. what will replace "Notepad" ? and for winwaitactive("[CLASS:notepad]") same question if I use winword.exe. what will replace "Notepad" ? thanks usera Link to comment Share on other sites More sharing options...
guinness Posted March 11, 2011 Share Posted March 11, 2011 (edited) Use AU3Info.exe in SciTe (look under the Tools Menu) to find the CLASS. I don't use MS Office.Edit: Or try this code >> #include <GUIMenu.au3> Global $PID = Run("Notepad.exe") ; Change to WinWord.exe Sleep(500) Global $hWnd = _WinGetHandleByPID($PID) _GUICtrlMenu_EnableMenuItem(_GUICtrlMenu_GetSystemMenu($hWnd), $SC_CLOSE, 1, False) Func _WinGetHandleByPID($i_pid, $f_array = False, $f_visibleonly = True) If Not IsInt($i_pid) Then $i_pid = ProcessExists($i_pid) Local $a_winlist = WinList() Local $a_retarray[$a_winlist[0][0] + 1], $i_add For $iwin = 1 To $a_winlist[0][0] If WinGetProcess($a_winlist[$iwin][1]) = $i_pid Then If $f_visibleonly Then If BitAND(WinGetState($a_winlist[$iwin][1]), 2) Then If Not $f_array Then Return $a_winlist[$iwin][1] $i_add += 1 $a_retarray[$i_add] = $a_winlist[$iwin][1] EndIf Else If Not $f_array Then Return $a_winlist[$iwin][1] $i_add += 1 $a_retarray[$i_add] = $a_winlist[$iwin][1] EndIf EndIf Next If Not $i_add Then Return SetError(1, 0, 0) ReDim $a_retarray[$i_add + 1] $a_retarray[0] = $i_add Return $a_retarray EndFuncEdit: New version provided by SmOke_N Edited March 11, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 11, 2011 Moderators Share Posted March 11, 2011 Return WinGetHandle(StringSplit(StringTrimRight($sData, 1), Chr(1)))This makes no sense. Are you suggesting that using WinGetHandle() this way actually enumerates through the StringSplit() array and makes each one a hwnd? Your vars are a bit confusing too... maybe this is more to the point?Func _WinGetHandleByPID($i_pid, $f_array = False, $f_visibleonly = True) If Not IsInt($i_pid) Then $i_pid = ProcessExists($i_pid) Local $a_winlist = WinList() Local $a_retarray[$a_winlist[0][0] + 1], $i_add For $iwin = 1 To $a_winlist[0][0] If WinGetProcess($a_winlist[$iwin][1]) = $i_pid Then If $f_visibleonly Then If BitAND(WinGetState($a_winlist[$iwin][1]), 2) Then If Not $f_array Then Return $a_winlist[$iwin][1] $i_add += 1 $a_retarray[$i_add] = $a_winlist[$iwin][1] EndIf Else If Not $f_array Then Return $a_winlist[$iwin][1] $i_add += 1 $a_retarray[$i_add] = $a_winlist[$iwin][1] EndIf EndIf Next If Not $i_add Then Return SetError(1, 0, 0) ReDim $a_retarray[$i_add + 1] $a_retarray[0] = $i_add Return $a_retarray EndFunc 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...
guinness Posted March 11, 2011 Share Posted March 11, 2011 (edited) I found the Function from here >> I was perhaps a little too keen to get the code onto the Forum. Thanks for the new version. With the Variable naming I use the advice from here >> http://www.autoitscript.com/autoit3/udfs/UDF_Standards.htm Edited March 11, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 11, 2011 Moderators Share Posted March 11, 2011 I found the Function from here >> I was perhaps a little too keen to get the code onto the Forum. Thanks for the new version. The stringsplit is fine, but you added WinGetHandle(), remember that StringSplit() returns an array, so essentially, you're getting the handle to nothing the way you modified it. Anyway, that example shows how to return a window title, [n][0] = title, [n][1] = handle, using them appropriately you can avoid WinGetHandle() all together . 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...
guinness Posted March 11, 2011 Share Posted March 11, 2011 I just wiped my eyes and realised you were Returning the StringSplit() Array. I hope I am allowed this one slip up on here I now understand. Thanks. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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