I'm new to all this and and struggling to fit these bits of code together.
What i want is a toggle switch that:
1) rotates the display 90°
2) opens and resizes a window
3) moves the taskbar to the top
4) changes taskbar to autohide.
I then want the switch to undo parts 1), 3), and 4).
I've searched far and wide and have got my seperate bits of code i just need help putting them into one and making it toggle-able.(I think it may work better as .exe activated by desktop shortcut rather than a hotkey.)
1) & 2)
Code: Select all
#singleInstance force
#noEnv
display:="\\.\DISPLAY1"
lookup:={"^!w":[0,0],"^!e":[1,1],"^!up":[2,0],"^!left":[3,1]}
return
^!w::
^!e::
^!up::
^!left::
if (lookup[a_thisHotkey][2]){ ; rotating to portrait
sRes:=strSplit((cRes:=screenRes_Get(display)),["x","@"])
if (sRes[2] < sRes[1]) {
cRes:=sRes[2] "x" sRes[1] "@" sRes[3]
}
} else { ; rotating to landscape
sRes:=strSplit((cRes:=screenRes_Get(display)),["x","@"])
if (sRes[2] > sRes[1]) {
cRes:=sRes[2] "x" sRes[1] "@" sRes[3]
}
}
screenRes_Set(cRes,display,lookup[a_thisHotkey][1])
WinShow ahk_class Shell_TrayWnd
SetTitleMatchMode, 2
WinActivate, - Zoom
WinMove, A,, 0, 0, 1090, 650
IfWinNotExist, - "Drawboard PDF"
{ Run "C:\WinStoreAppLinks\DrawboardPDF"
Sleep 300
}
WinActivate, - "Drawboard PDF"
WinMove, A,, 0, 585, 1090, 1300
return
screenRes_Set(WxHaF, Disp:=0, orient:=0) { ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution ; edited orientation in by Masonjar13
Local DM, N:=VarSetCapacity(DM,220,0), F:=StrSplit(WxHaF,["x","@"],A_Space)
Return DllCall("ChangeDisplaySettingsExW",(Disp=0 ? "Ptr" : "WStr"),Disp,"Ptr",NumPut(F[3],NumPut(F[2],NumPut(F[1]
,NumPut(32,NumPut(0x5C0080,NumPut(220,NumPut(orient,DM,84,"UInt")-20,"UShort")+2,"UInt")+92,"UInt"),"UInt")
,"UInt")+4,"UInt")-188, "Ptr",0, "Int",0, "Int",0)
}
screenRes_Get(Disp:=0) { ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution
Local DM, N:=VarSetCapacity(DM,220,0)
Return DllCall("EnumDisplaySettingsW", (Disp=0 ? "Ptr" : "WStr"),Disp, "Int",-1, "Ptr",&DM)=0 ? ""
: Format("{:}x{:}@{:}", NumGet(DM,172,"UInt"),NumGet(DM,176,"UInt"),NumGet(DM,184,"UInt"))
}
Code: Select all
#q:: ;taskbar - toggle auto-hide
vToggle := !vToggle * 0x3
;ABM_SETSTATE := 0xA
VarSetCapacity(APPBARDATA, A_PtrSize=8?48:36, 0)
NumPut(vToggle, &APPBARDATA, A_PtrSize=8?40:32, "UInt")
DllCall("shell32\SHAppBarMessage", UInt,0xA, Ptr,&APPBARDATA, UPtr)
return
4)
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#i::TaskbarMove("Top")
#j::TaskbarMove("Bottom")
#Numpad4::TaskbarMove("Left")
#Numpad6::TaskbarMove("Right")
TaskbarMove(p_pos) {
vToggle := !vToggle * 0x3
;ABM_SETSTATE := 0xA
VarSetCapacity(APPBARDATA, A_PtrSize=8?48:36, 0)
NumPut(vToggle, &APPBARDATA, A_PtrSize=8?40:32, "UInt")
DllCall("shell32\SHAppBarMessage", UInt,0xA, Ptr,&APPBARDATA, UPtr)
label:="TaskbarMove_" p_pos
WinExist("ahk_class Shell_TrayWnd")
SysGet, s, Monitor
if (IsLabel(label)) {
Goto, %label%
}
return
TaskbarMove_Top:
TaskbarMove_Bottom:
WinMove(sLeft, s%p_pos%, sRight, 0)
return
TaskbarMove_Left:
TaskbarMove_Right:
WinMove(s%p_pos%, sTop, 0, sBottom)
return
}
WinMove(p_x, p_y, p_w="", p_h="", p_hwnd="") {
WM_ENTERSIZEMOVE:=0x0231
WM_EXITSIZEMOVE :=0x0232
if (p_hwnd!="") {
WinExist("ahk_id " p_hwnd)
}
SendMessage, WM_ENTERSIZEMOVE
;//Tooltip WinMove(%p_x%`, %p_y%`, %p_w%`, %p_h%)
WinMove, , , p_x, p_y, p_w, p_h
SendMessage, WM_EXITSIZEMOVE
}