Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog hidden to edge
#1
hello everyone

Using the following toolbar code, I can achieve the effect of auto hide, see Gif Demo below

How to make the dialog achieve a similar effect? Any suggestions are welcome. Thanks in advance

Expected effect:
Press the win + left key, the dialog hidden as a vertical line on the left edge of the desktop
Press the win + right key, the dialog hidden as a vertical line on the right edge of the desktop
Press the win + up key, the dialoghidden as a horizontal line on the top edge of the desktop


Toolbar Toolbar Hide test
Code:
Copy      Help
;/mov0 -1 348 /siz0 106 196 /ssiz0 3 196 /set0 0x450A 0xFCFF
;At first, toolbar will be at the left-bottom edge of the screen. You can drag it to another place. Recommended trigger: mouse, screen edge, Slow.
notepad :run "$system$\notepad.exe"
write :run "$system$\write.exe"
calc :run "$system$\calc.exe"

Macro Dialog Hide test
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 72 52 96 13 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040B01 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "400 WL[]401 WR[]402 WU")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 400
,mes "as a vertical line on the left edge of the desktop"
,case 401
,mes "as a vertical line on the right edge of the desktop"
,case 402
,mes "as a horizontal line on the up edge of the desktop"
ret 1

[Image: GIF-2021-02-03-09-04-44.gif]
#2
In Archive there is something close to what you want.
https://www.quickmacros.com/forum/showth...p?tid=2852
this should be a good starting point.

Function dialog_autoshrink
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str ax3SHD
ax3SHD="http://www.quickmacros.com"
if(!ShowDialog("dialog_autoshrink" &dialog_autoshrink &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A48 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ActiveX 0x54030000 0x0 0 14 224 100 "SHDocVw.WebBrowser"
;END DIALOG
;DIALOG EDITOR: "" 0x2020100 "" ""

ret
;messages

DT_AutoShrink hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Function DT_AutoShrink
Code:
Copy      Help
;/
function# hDlg message wParam lParam

;Adds simple auto-shrink (actually roll-up) feature for a dialog.
;The dialog must be a smart dialog, ie with dialog procedure.
;Insert the following statement in the dialog procedure, before 'sel message' line:

;DT_AutoShrink hDlg message wParam lParam


type DASDATA !shr RECT'r
DASDATA* d=+GetProp(hDlg "qm_das")

sel message
,case WM_INITDIALOG
,SetProp hDlg "qm_das" d._new
,goto shrink
,case WM_DESTROY
,d._delete; RemoveProp hDlg "qm_das"
,case [WM_SETCURSOR,WM_PARENTNOTIFY]
,if(d.shr) goto shrink
,case WM_TIMER
,sel wParam
,,case 1578
,,if(win(mouse)!=hDlg and !GetCapture) goto shrink
ret

;shrink
d.shr^1
if(d.shr)
,KillTimer hDlg 1578
,GetWindowRect hDlg &d.r
,TITLEBARINFO ti.cbSize=sizeof(TITLEBARINFO)
,GetTitleBarInfo hDlg &ti
,int hei
,if(ti.rgstate[0]&STATE_SYSTEM_INVISIBLE) hei=20
,else hei=ti.rcTitleBar.bottom-ti.rcTitleBar.top+4
,siz 0 hei hDlg 1
else
,siz 0 d.r.bottom-d.r.top hDlg 1
,SetTimer hDlg 1578 100 0
#3
@redbull2k
Thank you for sharing

At present, need to find the code that is automatically hidden near the edge Smile

I think QM should already have this function, similar to the above demonstration

Autohotkey code reference:
https://github.com/scavin/winautohide/
 
Code:
Copy      Help
 
/*
 * BoD winautohide v1.00.
 *
 * This program and its source are in the public domain.
 * Contact [email protected] for more information.
 *
 * Version history:
 * 2008-06-13: v1.00
 */

#SingleInstance ignore

/*
 * Hotkey bindings
 */
Hotkey, #right, toggleWindowRight
Hotkey, #left, toggleWindowLeft
Hotkey, #up, toggleWindowUp
Hotkey, #down, toggleWindowDown

; uncomment the following lines to use ctrl+alt+shift instead if you don't have a "windows" key
;Hotkey, !^+right, toggleWindowRight
;Hotkey, !^+left, toggleWindowLeft
;Hotkey, !^+up, toggleWindowUp
;Hotkey, !^+down, toggleWindowDown



/*
 * Timer initialization.
 */
SetTimer, watchCursor, 300


/*
 * Tray menu initialization.
 */
Menu, tray, NoStandard
Menu, tray, Add, About..., menuAbout
Menu, tray, Add, Un-autohide all windows, menuUnautohideAll
Menu, tray, Add, Exit, menuExit
Menu, tray, Default, About...


return ; end of code that is to be executed on script start-up


/*
 * Tray menu implementation.
 */
menuAbout:
MsgBox, 8256, About, BoD winautohide v1.00.`n`nThis program and its source are in the public domain.`nContact [email protected] for more information.
return

menuUnautohideAll:
Loop, Parse, autohideWindows, `,
{
curWinId := A_LoopField
if (autohide_%curWinId%) {
Gosub, unautohide
}
}
return

menuExit:
Gosub, menuUnautohideAll
ExitApp
return



/*
 * Timer implementation.
 */
watchCursor:
MouseGetPos, , , winId ; get window under mouse pointer
if (autohide_%winId%) { ; window is on the list of 'autohide' windows
if (hidden_%winId%) { ; window is in 'hidden' position
previousActiveWindow := WinExist("A")
WinActivate, ahk_id %winId% ; activate the window
WinMove, ahk_id %winId%, , showing_%winId%_x, showing_%winId%_y ; move it to 'showing' position
hidden_%winId% := false
needHide := winId ; store it for next iteration
}
} else {
if (needHide) {
WinMove, ahk_id %needHide%, , hidden_%needHide%_x, hidden_%needHide%_y ; move it to 'hidden' position
WinActivate, ahk_id %previousActiveWindow% ; activate previously active window
hidden_%needHide% := true
needHide := false ; do that only once
}
}
return


/*
 * Hotkey implementation.
 */
toggleWindowRight:
mode := "right"
Gosub, toggleWindow
return

toggleWindowLeft:
mode := "left"
Gosub, toggleWindow
return

toggleWindowUp:
mode := "up"
Gosub, toggleWindow
return

toggleWindowDown:
mode := "down"
Gosub, toggleWindow
return


toggleWindow:
WinGet, curWinId, id, A
autohideWindows = %autohideWindows%,%curWinId%
if (autohide_%curWinId%) {
Gosub, unautohide
} else {
autohide_%curWinId% := true
Gosub, workWindow
WinGetPos, orig_%curWinId%_x, orig_%curWinId%_y, width, height, ahk_id %curWinId% ; get the window size and store original position

if (mode = "right") {
showing_%curWinId%_x := A_ScreenWidth - width
showing_%curWinId%_y := orig_%curWinId%_y

hidden_%curWinId%_x := A_ScreenWidth - 1
hidden_%curWinId%_y := orig_%curWinId%_y
} else if (mode = "left") {
showing_%curWinId%_x := 0
showing_%curWinId%_y := orig_%curWinId%_y

hidden_%curWinId%_x := -width + 1
hidden_%curWinId%_y := orig_%curWinId%_y
} else if (mode = "up") {
showing_%curWinId%_x := orig_%curWinId%_x
showing_%curWinId%_y := 0

hidden_%curWinId%_x := orig_%curWinId%_x
hidden_%curWinId%_y := -height + 1
} else { ; down
showing_%curWinId%_x := orig_%curWinId%_x
showing_%curWinId%_y := A_ScreenHeight - height

hidden_%curWinId%_x := orig_%curWinId%_x
hidden_%curWinId%_y := A_ScreenHeight - 1
}

WinMove, ahk_id %curWinId%, , hidden_%curWinId%_x, hidden_%curWinId%_y ; hide the window
hidden_%curWinId% := true
}
return


unautohide:
autohide_%curWinId% := false
needHide := false
Gosub, unworkWindow
WinMove, ahk_id %curWinId%, , orig_%curWinId%_x, orig_%curWinId%_y ; go back to original position
hidden_%curWinId% := false
return

workWindow:
DetectHiddenWindows, On
WinSet, AlwaysOnTop, on, ahk_id %curWinId% ; always-on-top
WinHide, ahk_id %curWinId%
WinSet, Style, -0xC00000, ahk_id %curWinId% ; no title bar
WinSet, ExStyle, +0x80, ahk_id %curWinId% ; remove from task bar
WinShow, ahk_id %curWinId%
return

unworkWindow:
DetectHiddenWindows, On
WinSet, AlwaysOnTop, off, ahk_id %curWinId% ; always-on-top
WinHide, ahk_id %curWinId%
WinSet, Style, +0xC00000, ahk_id %curWinId% ; title bar
WinSet, ExStyle, -0x80, ahk_id %curWinId% ; remove from task bar
WinShow, ahk_id %curWinId%
return
#4
try this out
keep in mind there is presently a bug in qm with the win key
so they actual keys that work are Left,Right,Up,& Down. I have left it with the WL combo as i presume the bug will get fixed
5 hot keys Left,Right,Up,& Down to move dialog to screen edge. end to make dialog like normal in center of screen.

Function DialogShrink
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 72 52 96 13 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040B01 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sub.DT_AutoShrink hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "400 WL[]401 WR[]402 WU[]403 WD[]404 E")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 400 ;;vertical line on the left edge of the desktop
,PostMessage hDlg WM_APP 1 0
,case 401 ;;vertical line on the right edge of the desktop
,PostMessage hDlg WM_APP 2 0
,case 402 ;;horizontal line on the Top edge of the desktop
,PostMessage hDlg WM_APP 3 0
,case 403 ;;horizontal line on the Bottom edge of the desktop
,PostMessage hDlg WM_APP 4 0
,case 404 ;;restore window to center screen with no shrink
,PostMessage hDlg WM_APP 0 0
ret 1

#sub DT_AutoShrink
/
function# hDlg message wParam lParam

;Adds simple auto-shrink feature for a dialog.
;The dialog must be a smart dialog, ie with dialog procedure.
;Insert the following statement in the dialog procedure, before 'sel message' line:
;DT_AutoShrink hDlg message wParam lParam

int- shrinkMode
type DASDATA !shr RECT'r int'mode
DASDATA* d=+GetProp(hDlg "qm_das")

sel message
,case WM_INITDIALOG
,SetProp hDlg "qm_das" d._new
,if(shrinkMode<>0)
,,goto shrink
,case WM_DESTROY
,d._delete; RemoveProp hDlg "qm_das"
,case [WM_SETCURSOR,WM_PARENTNOTIFY]
,if(d.shr) goto shrink
,case WM_APP
,shrinkMode=wParam
,goto shrink
,case WM_TIMER
,sel wParam
,,case 1578
,,if(win(mouse)!=hDlg and !GetCapture) 
,,,goto shrink
ret

;shrink
RECT r1
d.shr^1
if(d.shr)
,KillTimer hDlg 1578
,GetWindowRect hDlg &d.r
,if(GetWinStyle(hDlg)&WS_CAPTION) SetWinStyle hDlg WS_CAPTION 2
,sel shrinkMode
,,case 1
,,siz 10 0 hDlg 2
,,r1.left=1; r1.top=0
,,AdjustWindowPos hDlg &r1 3        
,,case 2
,,siz 10 0 hDlg 2    
,,r1.left=-1; r1.top=0
,,AdjustWindowPos hDlg &r1 3
,,case 3
,,siz 0 10 hDlg 1
,,r1.left=0; r1.top=1
,,AdjustWindowPos hDlg &r1 3        
,,case 4
,,siz 0 10 hDlg 1
,,r1.left=0; r1.top=-1
,,AdjustWindowPos hDlg &r1 3            
,,case 0
,,SetWinStyle hDlg WS_CAPTION 1
,,siz d.r.right-d.r.left d.r.bottom-d.r.top hDlg
,,r1.left=0; r1.top=0
,,AdjustWindowPos hDlg &r1 3
else
,if(GetWinStyle(hDlg)~WS_CAPTION) SetWinStyle(hDlg WS_CAPTION 1)
,,siz d.r.right-d.r.left d.r.bottom-d.r.top hDlg
,,if(shrinkMode=2)
,,,r1.left=-1; r1.top=0
,,,AdjustWindowPos hDlg &r1 2
,,if(shrinkMode=4)
,,,r1.left=0; r1.top=-1
,,,AdjustWindowPos hDlg &r1 3
,,SetTimer hDlg 1578 100 0
#5
1.Auto expand and display, not very sensitive
I don't understand what your saying.

2 .I need to press any direction key first, Otherwise, the dialog box cannot be hidden when it is placed on the edge
the arrow keys place the dialog and shrink it. not sure what your asking.
#6
1.Auto expand and display, not very sensitive
For example, sometimes I move the mouse pointer to the edge of the dialog box, and the dialog box doesn't expand, I need to keep moving


2.After opening the dialog, I drag it to the edge of the desktop, The dialog cannot be automatically hidden to the edge
After pressing the End key, the window cannot be dragged to other places

See Gif demo:

[Image: abc.gif]

I expect:
I drag the dialog to the edge of the desktop, It can be automatically hidden to the edge
When I drag the title bar out of the edge, turn off hide

QM toolbar auto expansion is very sensitive:
[Image: b.gif]
#7
It would be great if the following functions could be realized  Smile

[Image: GIF-2021-02-04-17-56-25.gif]
#8
@kevin
#4 
The hotkey doesn't work. I change the modifier key to Alt, 
In addition, I want to modify the color of the folded dialog box, but there is a small problem. Is there another solution? Thank you in advance

[Image: 1677900600]


Macro Autoshrink2
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80A48 0x0 0 0 224 136 "Dialog" "4"
;3 ActiveX 0x54030000 0x0 0 6 224 110 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str ax3SHD
ax3SHD=
;www.quickmacros.com
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sub.DT_AutoShrink hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,;DT_SetAccelerators(hDlg "400 WL[]401 WR[]402 WU[]403 WD[]404 E")
,DT_SetAccelerators(hDlg "400 AL[]401 AR[]402 AU[]403 AD[]404 E")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 400 ;;vertical line on the left edge of the desktop
,PostMessage hDlg WM_APP 1 0
,case 401 ;;vertical line on the right edge of the desktop
,PostMessage hDlg WM_APP 2 0
,case 402 ;;horizontal line on the Top edge of the desktop
,PostMessage hDlg WM_APP 3 0
,case 403 ;;horizontal line on the Bottom edge of the desktop
,PostMessage hDlg WM_APP 4 0
,case 404 ;;restore window to center screen with no shrink
,PostMessage hDlg WM_APP 0 0
ret 1

#sub DT_AutoShrink
/
function# hDlg message wParam lParam

;Adds simple auto-shrink feature for a dialog.
;The dialog must be a smart dialog, ie with dialog procedure.
;Insert the following statement in the dialog procedure, before 'sel message' line:
;DT_AutoShrink hDlg message wParam lParam

int- shrinkMode
type DASDATA !shr RECT'r int'mode
DASDATA* d=+GetProp(hDlg "qm_das")

sel message
,case WM_INITDIALOG
,SetProp hDlg "qm_das" d._new
,if(shrinkMode<>0)
,,goto shrink
,case WM_DESTROY
,d._delete; RemoveProp hDlg "qm_das"
,case [WM_SETCURSOR,WM_PARENTNOTIFY]
,if(d.shr) goto shrink
,case WM_APP
,shrinkMode=wParam
,goto shrink
,case WM_TIMER
,sel wParam
,,case 1578
,,if(win(mouse)!=hDlg and !GetCapture)
,,,goto shrink
ret

;shrink
RECT r1
d.shr^1
if(d.shr)
,KillTimer hDlg 1578
,GetWindowRect hDlg &d.r
,if(GetWinStyle(hDlg)&WS_CAPTION)
,,SetWinStyle hDlg WS_CAPTION|WS_SYSMENU 2
,,SetWinStyle hDlg WS_EX_TOOLWINDOW 1|4
,sel shrinkMode
,,case 1
,,siz 10 0 hDlg 2
,,r1.left=1; r1.top=0
,,AdjustWindowPos hDlg &r1 3
,,case 2
,,siz 10 0 hDlg 2
,,r1.left=-1; r1.top=0
,,AdjustWindowPos hDlg &r1 3
,,case 3
,,siz 0 10 hDlg 1
,,r1.left=0; r1.top=1
,,AdjustWindowPos hDlg &r1 3
,,case 4
,,siz 0 10 hDlg 1
,,r1.left=0; r1.top=-1
,,AdjustWindowPos hDlg &r1 3
,,case 0
,,SetWinStyle hDlg WS_CAPTION 1
,,siz d.r.right-d.r.left d.r.bottom-d.r.top hDlg
,,r1.left=0; r1.top=0
,,AdjustWindowPos hDlg &r1 3
,DT_SetBackgroundColor hDlg 0 0x00FF00
else
,DT_SetBackgroundColor hDlg 0 0xFFFFFF
,if(GetWinStyle(hDlg)~WS_CAPTION) SetWinStyle(hDlg WS_CAPTION 1)
,,siz d.r.right-d.r.left d.r.bottom-d.r.top hDlg
,,if(shrinkMode=2)
,,,r1.left=-1; r1.top=0
,,,AdjustWindowPos hDlg &r1 2
,,if(shrinkMode=4)
,,,r1.left=0; r1.top=-1
,,,AdjustWindowPos hDlg &r1 3
,,SetTimer hDlg 1578 100 0

Above the IE control in the dialog box, I need to leave a certain height of space to display the color. Is there a good plan?


Forum Jump:


Users browsing this thread: 1 Guest(s)