hover mouse over window and move mouse to resize window using autohotkey
I'm trying to creating a script that allows user to resize a window by hovering the mouse by pressing a keyboard shortcut without having to move a mouse to corner of a window each time.
This feature is currently available as part of BetterSnapTool for Mac OS X but I'm trying to develop the same feature for Windows 10 using AutoHotkey
I've developed a script for autohotkey that works well for most applications except for chrome and spotify (see below). It often gets stuck with the title bar menu open after hitting alt+space see video here
^+x::
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
Send !{Space}
Sleep 1
Send m
sleep 1
send {down}
Return
Is there a more reliable way can do this?
resize window autohotkey window-resize
add a comment |
I'm trying to creating a script that allows user to resize a window by hovering the mouse by pressing a keyboard shortcut without having to move a mouse to corner of a window each time.
This feature is currently available as part of BetterSnapTool for Mac OS X but I'm trying to develop the same feature for Windows 10 using AutoHotkey
I've developed a script for autohotkey that works well for most applications except for chrome and spotify (see below). It often gets stuck with the title bar menu open after hitting alt+space see video here
^+x::
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
Send !{Space}
Sleep 1
Send m
sleep 1
send {down}
Return
Is there a more reliable way can do this?
resize window autohotkey window-resize
add a comment |
I'm trying to creating a script that allows user to resize a window by hovering the mouse by pressing a keyboard shortcut without having to move a mouse to corner of a window each time.
This feature is currently available as part of BetterSnapTool for Mac OS X but I'm trying to develop the same feature for Windows 10 using AutoHotkey
I've developed a script for autohotkey that works well for most applications except for chrome and spotify (see below). It often gets stuck with the title bar menu open after hitting alt+space see video here
^+x::
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
Send !{Space}
Sleep 1
Send m
sleep 1
send {down}
Return
Is there a more reliable way can do this?
resize window autohotkey window-resize
I'm trying to creating a script that allows user to resize a window by hovering the mouse by pressing a keyboard shortcut without having to move a mouse to corner of a window each time.
This feature is currently available as part of BetterSnapTool for Mac OS X but I'm trying to develop the same feature for Windows 10 using AutoHotkey
I've developed a script for autohotkey that works well for most applications except for chrome and spotify (see below). It often gets stuck with the title bar menu open after hitting alt+space see video here
^+x::
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
Send !{Space}
Sleep 1
Send m
sleep 1
send {down}
Return
Is there a more reliable way can do this?
resize window autohotkey window-resize
resize window autohotkey window-resize
asked Jan 2 at 19:40
jerrysperryjerrysperry
164
164
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I was able to solve this reliably by moving the mouse to the top right of the window next the minimize button and leaving the mouse button down while using blockinput.
Benefits:
- This allows the the user to move the mouse freely to move the window.
- It works for resizing as well.
- being able to move windows if they're snapped fullscreen.
TIP: script has to be run as administrator for blockinput to work...
;Move Window Mode
^+x::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-186, 10
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
;Resize Window Mode
^+z::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-3, Height-3
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
add a comment |
The problem is that Sleep, 1
might not be enough time for the menu to appear on all applications.
The most reliable way to do it would be avoiding the menu altogether but that's quite some work to do through WinGetPos
, MouseGetPos
, and WinMove
.
I guess you'll still be trying to use the menu, so my tip is to at least wait to be sure that the menu exists. You can do this getting the ProcessID of your hwnd, and wait so that first found window through that PID changes, that could be understood for us as a new window has appeared. In code means something like this:
WinGet, WinPID, PID, ahk_id %hwnd%
oldHwnd := WinExist("ahk_pid " WinPID)
Send !{Space}
newHwnd := oldHwnd
while (newHwnd == oldHwnd)
newHwnd := WinExist("ahk_pid " WinPID)
But you'd need some better exit conditions in case that the menu didn't happen to appear (a timeout?) to not get stuck there.
Still after that the Sleep, 1 might not be enough.
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
add a comment |
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012216%2fhover-mouse-over-window-and-move-mouse-to-resize-window-using-autohotkey%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was able to solve this reliably by moving the mouse to the top right of the window next the minimize button and leaving the mouse button down while using blockinput.
Benefits:
- This allows the the user to move the mouse freely to move the window.
- It works for resizing as well.
- being able to move windows if they're snapped fullscreen.
TIP: script has to be run as administrator for blockinput to work...
;Move Window Mode
^+x::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-186, 10
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
;Resize Window Mode
^+z::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-3, Height-3
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
add a comment |
I was able to solve this reliably by moving the mouse to the top right of the window next the minimize button and leaving the mouse button down while using blockinput.
Benefits:
- This allows the the user to move the mouse freely to move the window.
- It works for resizing as well.
- being able to move windows if they're snapped fullscreen.
TIP: script has to be run as administrator for blockinput to work...
;Move Window Mode
^+x::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-186, 10
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
;Resize Window Mode
^+z::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-3, Height-3
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
add a comment |
I was able to solve this reliably by moving the mouse to the top right of the window next the minimize button and leaving the mouse button down while using blockinput.
Benefits:
- This allows the the user to move the mouse freely to move the window.
- It works for resizing as well.
- being able to move windows if they're snapped fullscreen.
TIP: script has to be run as administrator for blockinput to work...
;Move Window Mode
^+x::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-186, 10
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
;Resize Window Mode
^+z::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-3, Height-3
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
I was able to solve this reliably by moving the mouse to the top right of the window next the minimize button and leaving the mouse button down while using blockinput.
Benefits:
- This allows the the user to move the mouse freely to move the window.
- It works for resizing as well.
- being able to move windows if they're snapped fullscreen.
TIP: script has to be run as administrator for blockinput to work...
;Move Window Mode
^+x::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-186, 10
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
;Resize Window Mode
^+z::
KeyWait Shift
KeyWait Alt
BlockInput, On
MouseGetPos,,, hwnd
WinActivate, ahk_id %hwnd%
WinGetPos, , , Width, Height, A
MouseMove, Width-3, Height-3
Click, down
Send {Shift Up}
Send {Ctrl Up}
BlockInput, Off
Return
edited Jan 3 at 21:25
answered Jan 3 at 20:47
jerrysperryjerrysperry
164
164
add a comment |
add a comment |
The problem is that Sleep, 1
might not be enough time for the menu to appear on all applications.
The most reliable way to do it would be avoiding the menu altogether but that's quite some work to do through WinGetPos
, MouseGetPos
, and WinMove
.
I guess you'll still be trying to use the menu, so my tip is to at least wait to be sure that the menu exists. You can do this getting the ProcessID of your hwnd, and wait so that first found window through that PID changes, that could be understood for us as a new window has appeared. In code means something like this:
WinGet, WinPID, PID, ahk_id %hwnd%
oldHwnd := WinExist("ahk_pid " WinPID)
Send !{Space}
newHwnd := oldHwnd
while (newHwnd == oldHwnd)
newHwnd := WinExist("ahk_pid " WinPID)
But you'd need some better exit conditions in case that the menu didn't happen to appear (a timeout?) to not get stuck there.
Still after that the Sleep, 1 might not be enough.
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
add a comment |
The problem is that Sleep, 1
might not be enough time for the menu to appear on all applications.
The most reliable way to do it would be avoiding the menu altogether but that's quite some work to do through WinGetPos
, MouseGetPos
, and WinMove
.
I guess you'll still be trying to use the menu, so my tip is to at least wait to be sure that the menu exists. You can do this getting the ProcessID of your hwnd, and wait so that first found window through that PID changes, that could be understood for us as a new window has appeared. In code means something like this:
WinGet, WinPID, PID, ahk_id %hwnd%
oldHwnd := WinExist("ahk_pid " WinPID)
Send !{Space}
newHwnd := oldHwnd
while (newHwnd == oldHwnd)
newHwnd := WinExist("ahk_pid " WinPID)
But you'd need some better exit conditions in case that the menu didn't happen to appear (a timeout?) to not get stuck there.
Still after that the Sleep, 1 might not be enough.
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
add a comment |
The problem is that Sleep, 1
might not be enough time for the menu to appear on all applications.
The most reliable way to do it would be avoiding the menu altogether but that's quite some work to do through WinGetPos
, MouseGetPos
, and WinMove
.
I guess you'll still be trying to use the menu, so my tip is to at least wait to be sure that the menu exists. You can do this getting the ProcessID of your hwnd, and wait so that first found window through that PID changes, that could be understood for us as a new window has appeared. In code means something like this:
WinGet, WinPID, PID, ahk_id %hwnd%
oldHwnd := WinExist("ahk_pid " WinPID)
Send !{Space}
newHwnd := oldHwnd
while (newHwnd == oldHwnd)
newHwnd := WinExist("ahk_pid " WinPID)
But you'd need some better exit conditions in case that the menu didn't happen to appear (a timeout?) to not get stuck there.
Still after that the Sleep, 1 might not be enough.
The problem is that Sleep, 1
might not be enough time for the menu to appear on all applications.
The most reliable way to do it would be avoiding the menu altogether but that's quite some work to do through WinGetPos
, MouseGetPos
, and WinMove
.
I guess you'll still be trying to use the menu, so my tip is to at least wait to be sure that the menu exists. You can do this getting the ProcessID of your hwnd, and wait so that first found window through that PID changes, that could be understood for us as a new window has appeared. In code means something like this:
WinGet, WinPID, PID, ahk_id %hwnd%
oldHwnd := WinExist("ahk_pid " WinPID)
Send !{Space}
newHwnd := oldHwnd
while (newHwnd == oldHwnd)
newHwnd := WinExist("ahk_pid " WinPID)
But you'd need some better exit conditions in case that the menu didn't happen to appear (a timeout?) to not get stuck there.
Still after that the Sleep, 1 might not be enough.
answered Jan 2 at 22:08
scsoscso
30624
30624
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
add a comment |
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
Hmmm I think you're right about the menu being too slow.
– jerrysperry
Jan 3 at 15:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012216%2fhover-mouse-over-window-and-move-mouse-to-resize-window-using-autohotkey%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown