WinSet: Can't add/remove styles if N is a Constant

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SAbboushi
Posts: 252
Joined: 08 Dec 2014, 22:13

WinSet: Can't add/remove styles if N is a Constant

19 Apr 2018, 01:08

Code: Select all

#INCLUDE D:\Documents\AutoHotkey\Constants\Constants_Windows.ahk

;WinSet Style,  -0x00020000L, ahk_id 0x40F50 ; Works fine
;WinSet Style,  +0x00020000L, ahk_id 0x40F50 ; Works fine
;WinSet Style,  -WS_MINIMIZEBOX, ahk_id 0x40F50 ; Doesn't work
WinSet Style,  WS_MINIMIZEBOX, ahk_id 0x40F50 ; Works
Wondering whether there is a workaround or something I'm missing... or is this a feature request?
SAbboushi
Posts: 252
Joined: 08 Dec 2014, 22:13

Re: WinSet: Can't add/remove styles if N is a Constant

19 Apr 2018, 16:07

Nobody? It seems to defeat the purpose of setting up Constants if I can't prefix them with "+" and "-"...?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: WinSet: Can't add/remove styles if N is a Constant

19 Apr 2018, 16:36

the following works for me

Code: Select all

WS_MINIMIZEBOX := "0x00020000L"

a::
{
	MouseGetPos, , , hwndUnderCursor
	MsgBox, % hwndUnderCursor
return
}

x::
{
	WinSet, Style, -0x00020000L, % ("ahk_id" . hwndUnderCursor) ;works
	MsgBox, % "ErrLvl: " . ErrorLevel
return
}

c::
{
	WinSet, Style, +0x00020000L, % ("ahk_id" . hwndUnderCursor) ;works
	MsgBox, % "ErrLvl: " . ErrorLevel
return
}

v::
{
	WinSet, Style, % ("-" . WS_MINIMIZEBOX), % ("ahk_id" . hwndUnderCursor) ;works
	MsgBox, % "ErrLvl: " . ErrorLevel
return
}

b::
{
	WinSet, Style, % ("+" . WS_MINIMIZEBOX), % ("ahk_id" . hwndUnderCursor) ;works
	MsgBox, % "ErrLvl: " . ErrorLevel
return
}

z::ExitApp
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: WinSet: Can't add/remove styles if N is a Constant

19 Apr 2018, 17:55

- Here's some code. Cheers.

Code: Select all

q::
WS_MINIMIZEBOX := 0x20000
WinGet, hWnd, ID, A
WinSet Style,  % -WS_MINIMIZEBOX, % "ahk_id " hWnd
return

w::
WS_MINIMIZEBOX := 0x20000
WinGet, hWnd, ID, A
WinSet Style,  % "+" WS_MINIMIZEBOX, % "ahk_id " hWnd
return

;e:: ;not recommended (this removes almost all of the window styles, making the window unusable)
WS_MINIMIZEBOX := 0x20000
WinGet, hWnd, ID, A
WinSet Style, % WS_MINIMIZEBOX, % "ahk_id " hWnd
return

;r:: ;set windows to have the same style as this one
;(i.e. fix windows you messed up above)
WinGet, vWinStyle, Style, A
DetectHiddenWindows, On
WinGet, vWinList, List, ahk_class Notepad
Loop, % vWinList
{
	hWnd := vWinList%A_Index%
	WinSet, Style, % vWinStyle, % "ahk_id " hWnd
}
MsgBox, % "done"
return
- @swagfag, I would have thought that this wouldn't work: "0x00020000L", because of the 'L'.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: WinSet: Can't add/remove styles if N is a Constant

19 Apr 2018, 18:00

probably need to do
-%WS_MINIMIZEBOX%

it's a variable, not a constant. just because it's in a separate file doesn't make it a constant :) (and ahk doesn't have them, afaik)
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
SAbboushi
Posts: 252
Joined: 08 Dec 2014, 22:13

Re: WinSet: Can't add/remove styles if N is a Constant

19 Apr 2018, 19:35

Thanks folks - much appreciated!

>>it's a variable, not a constant. just because it's in a separate file doesn't make it a constant :) (and ahk doesn't have them, afaik)
My bad: It's a Global Variable

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: prototype_zero and 323 guests