-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
brainstorm bug
- Loading branch information
Showing
6 changed files
with
683 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
|
||
; SnowstarCyan_Monitor_Libriay | ||
; Updates: | ||
; 2016y 01m 28d | ||
; Created By Snowstar ([email protected]) | ||
; For rotate my screens to play computer games on bed at winter. ~(≧▽≦)~ | ||
|
||
; API Functions | ||
ChangeDisplaySettingsA := DllCall("User32.dll\ChangeDisplaySettingsA", "Ptr", &lpDevMode, "Int", dwflags) | ||
ChangeDisplaySettingsExA := DllCall("User32.dll\ChangeDisplaySettingsExA", "Str", DeviceName, "Ptr", &lpDevMode, "Ptr", HWND, "Int", dwflags, "Ptr", lParam) | ||
EnumDisplaySettingsA := DllCall("User32.dll\EnumDisplaySettingsA", "Str", DeviceName, "Int", iModeNum, "Ptr", &lpDevMode) | ||
EnumDisplayDevicesA := DllCall("User32.dll\EnumDisplayDevicesA", "Str", DeviceName, "Int", iDevNum, "Ptr", &lpDevMode, "Int", dwflags) | ||
|
||
class DEVMODE_DISPLAY_DEVICE { | ||
__New() { | ||
this.dmSize := 156 | ||
this.dmFields := 0 | ||
} | ||
__Set(key, value) { | ||
if (key == "position_x") || (key == "position_y") | ||
this.dmPosition := &value | ||
else | ||
this[key] := value | ||
} | ||
} | ||
|
||
class DISPLAY_DEVICE { | ||
__New() { | ||
this.cb := 424 | ||
} | ||
} | ||
|
||
_DISPLAY_DEVICE_ATTACHED_TO_DESKTOP := 1 | ||
|
||
Monitor := {} | ||
|
||
Monitor.MapByFunc := Func("MapByFunc") | ||
Monitor.Merge := Func("Merge") | ||
Monitor.GetDevMode := Func("GetDevMode") | ||
Monitor.GetDeviceName := Func("GetDeviceName") | ||
Monitor.RotateDevMode90 := Func("RotateDevMode90") | ||
Monitor.ApplyDevMode := Func("ApplyDevMode") | ||
Monitor.GetDisplayDevices := Func("GetDisplayDevices") | ||
Monitor.RotateOneMonitor := Func("RotateOneMonitor") | ||
Monitor.RotateAllMonitor := Func("RotateAllMonitor") | ||
|
||
MapByFunc(tab, func, params*) { | ||
newtab := {} | ||
for k, v in tab { | ||
newtab[k] := %func%(v, params*) | ||
} | ||
return newtab | ||
} | ||
|
||
Merge(tab1, tab2) { | ||
newtab := {} | ||
for k, v in tab1 { | ||
if (tab1[k] && tab2[k]) { | ||
newtab.push([tab1[k], tab2[k]]) | ||
} | ||
} | ||
return newtab | ||
} | ||
|
||
GetDevMode(deviceName) { | ||
devMode := new DEVMODE_DISPLAY_DEVICE() | ||
success := DllCall("User32.dll\EnumDisplaySettingsA", "Str", deviceName, "Int", -1, "Ptr", devMode) | ||
if (!success) { | ||
MsgBox Can't get current settings. | ||
return null | ||
} | ||
return devMode | ||
} | ||
|
||
GetDeviceName(device) { | ||
return device.DeviceName | ||
} | ||
|
||
RotateDevMode90(devMode, devModeMain) { | ||
New_Orientation := Mod(devMode.displayOrientation + 1, 4) | ||
|
||
; Calculate new positions | ||
New_position_x := (devModeMain ? devModeMain.pelsHeight - devMode.position_y - devMode.pelsHeight : devMode.position_y) | ||
New_position_y := devMode.position_x | ||
New_pelsWidth := devMode.pelsHeight | ||
New_pelsHeight := devMode.pelsWidth | ||
|
||
devMode.position_x := New_position_x | ||
devMode.position_y := New_position_y | ||
devMode.pelsWidth := New_pelsWidth | ||
devMode.pelsHeight := New_pelsHeight | ||
devMode.displayOrientation := New_Orientation | ||
|
||
return devMode | ||
} | ||
|
||
ApplyDevMode(deviceToDevmode) { | ||
deviceName := deviceToDevmode[1] | ||
devMode := deviceToDevmode[2] | ||
success := DllCall("User32.dll\ChangeDisplaySettingsExA", "Str", deviceName, "Ptr", devMode, "Ptr", 0, "Int", 0, "Ptr", 0) | ||
return success | ||
} | ||
|
||
GetDisplayDevices() { | ||
lsDisplayDevice := [] | ||
iDevNum := 0 | ||
Loop { | ||
lpDisplayDevice := new DISPLAY_DEVICE() | ||
if !DllCall("User32.dll\EnumDisplayDevicesA", "Str", Null, "Int", iDevNum, "Ptr", lpDisplayDevice, "Int", 0) { | ||
break | ||
} | ||
if (lpDisplayDevice.StateFlags & _DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) { | ||
lsDisplayDevice.Push(lpDisplayDevice) | ||
} | ||
iDevNum++ | ||
} | ||
return lsDisplayDevice | ||
} | ||
|
||
RotateOneMonitor(degree, abs := false, deviceName := "") { | ||
devMode := Monitor.GetDevMode(deviceName) | ||
if !devMode { | ||
return | ||
} | ||
|
||
rotCount := Mod((Floor(degree / 90)), 4) | ||
if abs { | ||
rotCount := Mod(rotCount - devMode.displayOrientation, 4) | ||
} | ||
Loop %rotCount% { | ||
devMode := Monitor.RotateDevMode90(devMode) | ||
} | ||
|
||
success := Monitor.ApplyDevMode([deviceName, devMode]) | ||
return success | ||
} | ||
|
||
RotateAllMonitor(degree, abs := false) { | ||
lsDevice := Monitor.GetDisplayDevices() | ||
lsDeviceName := Monitor.MapByFunc(lsDevice, Monitor.GetDeviceName) | ||
|
||
lsDevMode := Monitor.MapByFunc(lsDeviceName, Monitor.GetDevMode) | ||
if !lsDevMode[1] { | ||
MsgBox You can't rotate the `non-screen` | ||
return | ||
} | ||
|
||
rotCount := Mod((Floor(degree / 90)), 4) | ||
if abs { | ||
rotCount := Mod(rotCount - lsDevMode[1].displayOrientation, 4) | ||
} | ||
Loop %rotCount% { | ||
lsDevMode := Monitor.MapByFunc(lsDevMode, Monitor.RotateDevMode90, lsDevMode[1]) | ||
} | ||
|
||
lsDeviceToDevmode := Monitor.Merge(lsDeviceName, lsDevMode) | ||
lsSuccess := Monitor.MapByFunc(lsDeviceToDevmode, Monitor.ApplyDevMode) | ||
return lsSuccess | ||
} | ||
|
||
Monitor.RotateOneMonitor(90) | ||
MsgBox, % GetDisplayDevices().length | ||
return | ||
|
||
#^p:: ScreenRotate() | ||
ScreenRotate(){ | ||
|
||
; Unit Test | ||
Monitor.RotateOneMonitor(90) | ||
Sleep, 3000 | ||
Monitor.RotateOneMonitor(0, true) | ||
Sleep, 3000 | ||
Monitor.RotateAllMonitor(-90) | ||
Sleep, 3000 | ||
Monitor.RotateAllMonitor(180) | ||
Sleep, 3000 | ||
Monitor.RotateAllMonitor(90, true) | ||
Sleep, 3000 | ||
Monitor.RotateAllMonitor(-90, true) | ||
Sleep, 3000 | ||
Monitor.RotateAllMonitor(0, true) | ||
Sleep, 3000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
; placeholder | ||
; ; | ||
; ; ; SnowstarCyan_Monitor_Libriay | ||
; ; ; Updates: | ||
; ; ; 2016y 01m 28d | ||
; ; ; Created By Snowstar ([email protected]) | ||
; ; ; For rotate my screens to play computer games on bed at winter. ~(≧▽≦)~ | ||
; ; | ||
; ; API Functions for Reference | ||
; ; ChangeDisplaySettingsA := DllCall("User32.dll\ChangeDisplaySettingsA", "Ptr", &lpDevMode, "Int", dwflags) | ||
; ; ChangeDisplaySettingsExA := DllCall("User32.dll\ChangeDisplaySettingsExA", "Str", DeviceName, "Ptr", &lpDevMode, "Ptr", HWND, "Int", dwflags, "Ptr", lParam) | ||
; ; EnumDisplaySettingsA := DllCall("User32.dll\EnumDisplaySettingsA", "Str", DeviceName, "Int", iModeNum, "Ptr", &lpDevMode) | ||
; ; EnumDisplayDevicesA := DllCall("User32.dll\EnumDisplayDevicesA", "Str", DeviceName, "Int", iDevNum, "Ptr", &lpDevMode, "Int", dwflags) | ||
|
||
; ; MsgBox % "EnumDisplayDevicesA" . EnumDisplayDevicesA | ||
; ; | ||
; ; Monitor.RotateOneMonitor(90) | ||
; ; len := GetDisplayDevices().length | ||
|
||
; ; MsgBox, % "len" . len | ||
|
||
; class DEVMODE_DISPLAY_DEVICE { | ||
; __New() { | ||
; this.dmSize := 156 | ||
; this.dmFields := 0 | ||
; } | ||
; __Set(key, value) { | ||
; if (key == "position_x") || (key == "position_y") | ||
; this.dmPosition := &value | ||
; else | ||
; this[key] := value | ||
; } | ||
; } | ||
|
||
; class DISPLAY_DEVICE { | ||
; __New() { | ||
; this.cb := 424 | ||
; } | ||
; } | ||
|
||
; ; _DISPLAY_DEVICE_ATTACHED_TO_DESKTOP := 1 | ||
|
||
; Monitor := {} | ||
; Monitor.MapByFunc := Func("MapByFunc") | ||
; Monitor.Merge := Func("Merge") | ||
; Monitor.GetDeviceMode := Func("GetDeviceMode") | ||
; Monitor.GetDeviceName := Func("GetDeviceName") | ||
; Monitor.RotateDevMode90 := Func("RotateDevMode90") | ||
; Monitor.ApplyDevMode := Func("ApplyDevMode") | ||
; Monitor.GetDisplayDevices := Func("GetDisplayDevices") | ||
; Monitor.RotateOneMonitor := Func("RotateOneMonitor") | ||
; Monitor.RotateAllMonitor := Func("RotateAllMonitor") | ||
|
||
; Monitor.RotateOneMonitor(90) | ||
; MsgBox, % "len: " . GetMonitorCount() | ||
|
||
; ; len := GetDisplayDevices().length | ||
|
||
|
||
; MapByFunc(tab, func, params*) { | ||
; newtab := {} | ||
; for k, v in tab { | ||
; newtab[k] := %func%(v, params*) | ||
; } | ||
; return newtab | ||
; } | ||
|
||
; Merge(tab1, tab2) { | ||
; newtab := {} | ||
; for k, v in tab1 { | ||
; if (tab1[k] && tab2[k]) { | ||
; newtab.push([tab1[k], tab2[k]]) | ||
; } | ||
; } | ||
; return newtab | ||
; } | ||
|
||
; GetDeviceMode(deviceName) { | ||
; devMode := new DEVMODE_DISPLAY_DEVICE() | ||
; success := DllCall("User32.dll\EnumDisplaySettingsA", "Str", deviceName, "Int", -1, "Ptr", devMode) | ||
; if (!success) { | ||
; MsgBox Can't get current settings. | ||
; return null | ||
; } | ||
; return devMode | ||
; } | ||
|
||
; GetDeviceName(device) { | ||
; return device.DeviceName | ||
; } | ||
|
||
; RotateDevMode90(devMode, devModeMain) { | ||
; New_Orientation := Mod(devMode.displayOrientation + 1, 4) | ||
|
||
; ; Calculate new positions | ||
; New_position_x := (devModeMain ? devModeMain.pelsHeight - devMode.position_y - devMode.pelsHeight : devMode.position_y) | ||
; New_position_y := devMode.position_x | ||
; New_pelsWidth := devMode.pelsHeight | ||
; New_pelsHeight := devMode.pelsWidth | ||
|
||
; devMode.position_x := New_position_x | ||
; devMode.position_y := New_position_y | ||
; devMode.pelsWidth := New_pelsWidth | ||
; devMode.pelsHeight := New_pelsHeight | ||
; devMode.displayOrientation := New_Orientation | ||
|
||
; return devMode | ||
; } | ||
|
||
; ApplyDevMode(deviceToDevmode) { | ||
; deviceName := deviceToDevmode[1] | ||
; devMode := deviceToDevmode[2] | ||
; success := DllCall("User32.dll\ChangeDisplaySettingsExA", "Str", deviceName, "Ptr", devMode, "Ptr", 0, "Int", 0, "Ptr", 0) | ||
; return success | ||
; } | ||
|
||
; GetDisplayDevices() { | ||
; lsDisplayDevice := [] | ||
; iDevNum := 0 | ||
; Loop { | ||
; lpDisplayDevice := new DISPLAY_DEVICE() | ||
; if !DllCall("User32.dll\EnumDisplayDevicesA", "ptr", 0, "Int", iDevNum, "Ptr", lpDisplayDevice, "Int", 0) { | ||
; break | ||
; } | ||
; if (lpDisplayDevice.StateFlags & _DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) { | ||
; lsDisplayDevice.Push(lpDisplayDevice) | ||
; } | ||
; MsgBox % "num" . iDevNum | ||
; iDevNum++ | ||
; } | ||
; return lsDisplayDevice | ||
; } | ||
|
||
; RotateOneMonitor(degree, abs := false, deviceName := "") { | ||
; devMode := Monitor.GetDeviceMode(deviceName) | ||
; if !devMode { | ||
; return | ||
; } | ||
|
||
; rotCount := Mod((Floor(degree / 90)), 4) | ||
; if abs { | ||
; rotCount := Mod(rotCount - devMode.displayOrientation, 4) | ||
; } | ||
; Loop %rotCount% { | ||
; devMode := Monitor.RotateDevMode90(devMode) | ||
; } | ||
|
||
; success := Monitor.ApplyDevMode([deviceName, devMode]) | ||
; return success | ||
; } | ||
|
||
; RotateAllMonitor(degree, abs := false) { | ||
; lsDevice := Monitor.GetDisplayDevices() | ||
; lsDeviceName := Monitor.MapByFunc(lsDevice, Monitor.GetDeviceName) | ||
|
||
; lsDevMode := Monitor.MapByFunc(lsDeviceName, Monitor.GetDeviceMode) | ||
; if !lsDevMode[1] { | ||
; MsgBox You can't rotate the `non-screen` | ||
; return | ||
; } | ||
|
||
; rotCount := Mod((Floor(degree / 90)), 4) | ||
; if abs { | ||
; rotCount := Mod(rotCount - lsDevMode[1].displayOrientation, 4) | ||
; } | ||
; Loop %rotCount% { | ||
; lsDevMode := Monitor.MapByFunc(lsDevMode, Monitor.RotateDevMode90, lsDevMode[1]) | ||
; } | ||
|
||
; lsDeviceToDevmode := Monitor.Merge(lsDeviceName, lsDevMode) | ||
; lsSuccess := Monitor.MapByFunc(lsDeviceToDevmode, Monitor.ApplyDevMode) | ||
; return lsSuccess | ||
; } | ||
|
||
; ; return | ||
|
||
; ; #^p:: ScreenRotate() | ||
; ; ScreenRotate(){ | ||
|
||
; ; ; Unit Test | ||
; ; Monitor.RotateOneMonitor(90) | ||
; ; ; Sleep, 3000 | ||
; ; ; Monitor.RotateOneMonitor(0, true) | ||
; ; ; Sleep, 3000 | ||
; ; ; Monitor.RotateAllMonitor(-90) | ||
; ; ; Sleep, 3000 | ||
; ; ; Monitor.RotateAllMonitor(180) | ||
; ; ; Sleep, 3000 | ||
; ; ; Monitor.RotateAllMonitor(90, true) | ||
; ; ; Sleep, 3000 | ||
; ; ; Monitor.RotateAllMonitor(-90, true) | ||
; ; ; Sleep, 3000 | ||
; ; ; Monitor.RotateAllMonitor(0, true) | ||
; ; ; Sleep, 3000 | ||
; ; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Screen Rotate | ||
|
||
使用方法 | ||
|
||
1. OneNote 2016 打开一个窗口,标题写成这样 "剪贴板收集"。 | ||
2. 然后再用 Ctrl + C 复制东西的时候就会自动记到 OneNote 里 | ||
3. 如图 | ||
![插件-OneNote剪贴板收集器.gif](./插件-OneNote剪贴板收集器.gif) |
Oops, something went wrong.