Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Change Close Button to WinHide


  • Please log in to reply
5 replies to this topic
JimW
  • Members
  • 13 posts
  • Last active: Jul 22 2014 11:27 AM
  • Joined: 16 Sep 2011

I need the top right red X close button to WinHide instead of close.
I never want PhpStorm to close except via Alt+F4 or File > Exit.

The below script works for hover but can still be clicked, which causes and unwanted close.

#NoTrayIcon
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance
SetTitleMatchMode 2
#Persistent
DetectHiddenWindows, Off
IfWinActive, - PhpStorm PS
CoordMode Mouse, Screen
HTCLOSE := 20
WM_NCHITTEST := 0x0084
SetTimer Watch, 100
return
Watch:
IfWinActive, - PhpStorm PS
MouseGetPos x, y
SendMessage %WM_NCHITTEST% , 0, (y << 16) + x , ,ahk_class SunAwtFrame ; ahk_class for PhpStorm
if (ErrorLevel = HTCLOSE)
{
Sleep, 1000 ; Prevent unwanted hiding with mouse cursor drive by.
WinHide, - PhpStorm PS
}
return

Any code samples would be greatly appreciated.

Windows 8 Pro
PhpStorm

Thank You



GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013

 

The below script works for hover but can still be clicked

 

You could disable LButton in this situation and at this Mouse Pos.



JimW
  • Members
  • 13 posts
  • Last active: Jul 22 2014 11:27 AM
  • Joined: 16 Sep 2011

Correction:

 

I need it to WinHide on Click, not hover.

 

Thanks



GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode 2
Process, Priority, , High
SetBatchLines -1
#Persistent
CoordMode Mouse, Screen
HTCLOSE := 20
WM_NCHITTEST := 0x0084
SetTimer Watch, 0
LButton = 1
return


Watch:
IfWinActive, - PhpStorm
{
MouseGetPos x, y
if  GetKeyState("LButton")
SendMessage %WM_NCHITTEST% , 0, (y << 16) + x , ,ahk_class SunAwtFrame ; ahk_class for PhpStorm
if (ErrorLevel = HTCLOSE)
{
LButton = 0
   WinHide, - PhpStorm
  LButton = 1
     return
}
}
return



#If LButton = 0

LButton::
WinHide, - PhpStorm
return

#If


vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011

No need to constantly recheck the position by using timer or send messages

Here is an example with notepad that hides the notepad window if you click on the X button(you need to recalculate the values)

#IfWinActive,AHK_class Notepad
LButton::
CoordMode,Mouse,Window
MouseGetPos,X,Y
WinGetPos,,,W,,A
ToolTip,% X "x" Y
If ((X > W - 35) & (Y < 30))
WinHide,A
Else
{
Send,{LButton Down}
KeyWait,LButton
Send,{LButton Up}
}
Return


JimW
  • Members
  • 13 posts
  • Last active: Jul 22 2014 11:27 AM
  • Joined: 16 Sep 2011

Thanks guys