Skip to content

Commit 932c4ad

Browse files
authored
Add files via upload
0 parents  commit 932c4ad

File tree

1 file changed

+260
-0
lines changed

1 file changed

+260
-0
lines changed

Cemu.ahk

+260
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
SetSystemCursor( Cursor = "", cx = 0, cy = 0 )
2+
{
3+
BlankCursor := 0, SystemCursor := 0, FileCursor := 0 ; init
4+
5+
SystemCursors = 32512IDC_ARROW,32513IDC_IBEAM,32514IDC_WAIT,32515IDC_CROSS
6+
,32516IDC_UPARROW,32640IDC_SIZE,32641IDC_ICON,32642IDC_SIZENWSE
7+
,32643IDC_SIZENESW,32644IDC_SIZEWE,32645IDC_SIZENS,32646IDC_SIZEALL
8+
,32648IDC_NO,32649IDC_HAND,32650IDC_APPSTARTING,32651IDC_HELP
9+
10+
If Cursor = ; empty, so create blank cursor
11+
{
12+
VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 )
13+
BlankCursor = 1 ; flag for later
14+
}
15+
Else If SubStr( Cursor,1,4 ) = "IDC_" ; load system cursor
16+
{
17+
Loop, Parse, SystemCursors, `,
18+
{
19+
CursorName := SubStr( A_Loopfield, 6, 15 ) ; get the cursor name, no trailing space with substr
20+
CursorID := SubStr( A_Loopfield, 1, 5 ) ; get the cursor id
21+
SystemCursor = 1
22+
If ( CursorName = Cursor )
23+
{
24+
CursorHandle := DllCall( "LoadCursor", Uint,0, Int,CursorID )
25+
Break
26+
}
27+
}
28+
If CursorHandle = ; invalid cursor name given
29+
{
30+
Msgbox,, SetCursor, Error: Invalid cursor name
31+
CursorHandle = Error
32+
}
33+
}
34+
Else If FileExist( Cursor )
35+
{
36+
SplitPath, Cursor,,, Ext ; auto-detect type
37+
If Ext = ico
38+
uType := 0x1
39+
Else If Ext in cur,ani
40+
uType := 0x2
41+
Else ; invalid file ext
42+
{
43+
Msgbox,, SetCursor, Error: Invalid file type
44+
CursorHandle = Error
45+
}
46+
FileCursor = 1
47+
}
48+
Else
49+
{
50+
Msgbox,, SetCursor, Error: Invalid file path or cursor name
51+
CursorHandle = Error ; raise for later
52+
}
53+
If CursorHandle != Error
54+
{
55+
Loop, Parse, SystemCursors, `,
56+
{
57+
If BlankCursor = 1
58+
{
59+
Type = BlankCursor
60+
%Type%%A_Index% := DllCall( "CreateCursor"
61+
, Uint,0, Int,0, Int,0, Int,32, Int,32, Uint,&AndMask, Uint,&XorMask )
62+
CursorHandle := DllCall( "CopyImage", Uint,%Type%%A_Index%, Uint,0x2, Int,0, Int,0, Int,0 )
63+
DllCall( "SetSystemCursor", Uint,CursorHandle, Int,SubStr( A_Loopfield, 1, 5 ) )
64+
}
65+
Else If SystemCursor = 1
66+
{
67+
Type = SystemCursor
68+
CursorHandle := DllCall( "LoadCursor", Uint,0, Int,CursorID )
69+
%Type%%A_Index% := DllCall( "CopyImage"
70+
, Uint,CursorHandle, Uint,0x2, Int,cx, Int,cy, Uint,0 )
71+
CursorHandle := DllCall( "CopyImage", Uint,%Type%%A_Index%, Uint,0x2, Int,0, Int,0, Int,0 )
72+
DllCall( "SetSystemCursor", Uint,CursorHandle, Int,SubStr( A_Loopfield, 1, 5 ) )
73+
}
74+
Else If FileCursor = 1
75+
{
76+
Type = FileCursor
77+
%Type%%A_Index% := DllCall( "LoadImageA"
78+
, UInt,0, Str,Cursor, UInt,uType, Int,cx, Int,cy, UInt,0x10 )
79+
DllCall( "SetSystemCursor", Uint,%Type%%A_Index%, Int,SubStr( A_Loopfield, 1, 5 ) )
80+
}
81+
}
82+
}
83+
}
84+
85+
RestoreCursors()
86+
{
87+
SPI_SETCURSORS := 0x57
88+
DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 )
89+
}
90+
91+
92+
93+
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
94+
; #Warn ; Enable warnings to assist with detecting common errors.
95+
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
96+
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
97+
Coordmode, Mouse, Screen
98+
99+
hmenug := 0
100+
101+
; Shortcut: Win+C
102+
; Move gamepad view to secondary monitor and maximize
103+
; Move Cemu main view to primary monitor and maximize
104+
; Hide title bars and menu
105+
; Set taskbar autohide
106+
; Hide mouse cursor
107+
#c::
108+
109+
global hmenug
110+
111+
; Set taskbar autohide
112+
VarSetCapacity(APPBARDATA, A_PtrSize=4 ? 36:48)
113+
NumPut(DllCall("Shell32\SHAppBarMessage", "UInt", 4 ; ABM_GETSTATE
114+
, "Ptr", &APPBARDATA
115+
, "Int")
116+
? 1:1, APPBARDATA, A_PtrSize=4 ? 32:40) ; 2 - ABS_ALWAYSONTOP, 1 - ABS_AUTOHIDE
117+
, DllCall("Shell32\SHAppBarMessage", "UInt", 10 ; ABM_SETSTATE
118+
, "Ptr", &APPBARDATA)
119+
120+
; Hide mouse cursor
121+
SetSystemCursor()
122+
123+
Sleep, 50
124+
125+
SysGet, MonPri, MonitorPrimary
126+
MonSec := 1
127+
if(MonPri = 1) {
128+
MonSec := 2
129+
}
130+
131+
; Attempt to move Gamepad to New Window
132+
SysGet, Mon1, Monitor, %MonSec% ; Get secondary Monitor Info X and Y
133+
WinGetPos, Padx, Pady, Padw, Padh, GamePad View ; Get the GamePad's Width and Height Probably not necessary as we maximize below
134+
WinMove, GamePad View,, %Mon1Left%, %Mon1Top%, Padw, Padh ; Move Window to secondary monitor
135+
WinMaximize, GamePad View ; Maximize window to fill Monitor
136+
WinSet, Style, -0xC00000, GamePad View ; Remove the title bar
137+
138+
; Attempt to move Cemu to New Window
139+
SysGet, Mon1, Monitor, %MonPri% ; Get primary Monitor Info X and Y
140+
WinGetPos, Padx, Pady, Padw, Padh, Cemu ; Get the Cemu's Width and Height Probably not necessary as we maximize below
141+
WinMove, Cemu,, %Mon1Left%, %Mon1Top%, Padw, Padh ; Move Window to primary monitor
142+
WinMaximize, Cemu ; Maximize window to fill Monitor
143+
WinSet, Style, -0xC00000, Cemu ; Remove the title bar
144+
145+
WinWait Cemu,,2
146+
147+
; Remove menu bar in Cemu
148+
if (ErrorLevel = 0) {
149+
hmenu:=DllCall("GetMenu", uint, WinExist()) ; Get menu bar of "last found window".
150+
if(hmenu!=0) {
151+
hmenug := hmenu
152+
}
153+
DllCall("SetMenu", uint, WinExist(), uint, 0) ; Remove menu bar of "last found window".
154+
}
155+
156+
return
157+
158+
; Shortcut Win+Z
159+
; Restore size of gamepad view and move to primary monitor
160+
; Restore size of Cemu main view and move to primary monitor
161+
; Restore title bars and menu
162+
; Reset taskbar autohide
163+
; Restore mouse cursor
164+
#z::
165+
166+
global hmenug
167+
168+
; reset taskbar autohide
169+
VarSetCapacity(APPBARDATA, A_PtrSize=4 ? 36:48)
170+
NumPut(DllCall("Shell32\SHAppBarMessage", "UInt", 4 ; ABM_GETSTATE
171+
, "Ptr", &APPBARDATA
172+
, "Int")
173+
? 2:2, APPBARDATA, A_PtrSize=4 ? 32:40) ; 2 - ABS_ALWAYSONTOP, 1 - ABS_AUTOHIDE
174+
, DllCall("Shell32\SHAppBarMessage", "UInt", 10 ; ABM_SETSTATE
175+
, "Ptr", &APPBARDATA)
176+
177+
; restore mouse cursor
178+
RestoreCursors()
179+
180+
Sleep, 50
181+
182+
; Restore Gamepad view
183+
WinRestore, GamePad View
184+
185+
SysGet, MonPri, MonitorPrimary
186+
MonSec := 1
187+
if(MonPri = 1) {
188+
MonSec := 2
189+
}
190+
191+
; Attempt moving Gamepad View back to primary monitor
192+
SysGet, Mon1, Monitor, %MonPri% ; Get primary Monitor Info X and Y
193+
WinGetPos, Padx, Pady, Padw, Padh, GamePad View ; Get the GamePad's Width and Height
194+
WinMove, GamePad View,, %Mon1Left%, %Mon1Top%, Padw, Padh ; Move Window to primary monitor
195+
196+
WinSet, Style, +0xC00000, GamePad View ; Restore the title bar
197+
198+
; Restore Cemu Window
199+
WinRestore, Cemu
200+
201+
; Attempt moving Gamepad View back to primary monitor
202+
WinGetPos, Padx, Pady, Padw, Padh, Cemu ; Get the Cemu's Width and Height
203+
WinMove, Cemu,, %Mon1Left%, %Mon1Top%, Padw, Padh ; Move Window to primary monitor
204+
205+
WinSet, Style, +0xC00000, Cemu ; Restore the title bar
206+
207+
WinWait Cemu,,2
208+
209+
; Restore the menu bar in Cemu
210+
if (ErrorLevel = 0) {
211+
if(hmenug != 0) {
212+
DllCall("SetMenu", uint, WinExist(), uint, hmenug) ; Restoree menu bar of "last found window".
213+
}
214+
215+
}
216+
hmenug := 0
217+
218+
return
219+
220+
; Shortcut Win+P
221+
; Move mouse cursor to primary monitor (Cemu main view)
222+
#p::
223+
Coordmode, Mouse, Screen
224+
SendMode Event
225+
226+
SysGet, MonPri, MonitorPrimary
227+
MonSec := 1
228+
if(MonPri = 1) {
229+
MonSec := 2
230+
}
231+
232+
SysGet, Mon1, Monitor, %MonPri% ; Get primary Monitor Info X and Y
233+
GoX := Mon1Left+100
234+
GoY := Mon1Top+100
235+
236+
MouseMove %GoX%, %GoY%
237+
SendMode Input
238+
239+
return
240+
241+
; Shortcut Win+O
242+
; Move mouse cursor to secondary monitor (Gamepad view)
243+
#o::
244+
Coordmode, Mouse, Screen
245+
SendMode Event
246+
247+
SysGet, MonPri, MonitorPrimary
248+
MonSec := 1
249+
if(MonPri = 1) {
250+
MonSec := 2
251+
}
252+
SendMode Input
253+
254+
SysGet, Mon1, Monitor, %MonSec% ; Get second Monitor Info X and Y
255+
GoX := Mon1Left+100
256+
GoY := Mon1Top+100
257+
258+
MouseMove %GoX%, %GoY%
259+
260+
return

0 commit comments

Comments
 (0)