Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance, Force
- #Include, Rini.ahk
- OnMessage(0x115, "OnScroll") ; WM_VSCROLL
- OnMessage(0x114, "OnScroll") ; WM_HSCROLL
- Gui, +Resize +0x300000 ; WS_VSCROLL | WS_HSCROLL
- RIni_Read("Config", "Config.ini")
- Secs := RIni_GetSections("Config", "|")
- Gui, Add, Tab, AltSubmit gTab vTabbing w300 h600, %Secs%
- If InStr(Secs, "|")
- {
- Loop, Parse, Secs, |
- {
- KeyNum := A_Index
- Section := A_LoopField
- Gui, Tab, %A_Index%
- Keys := RIni_GetSectionKeys("Config",Section)
- Loop, Parse, Keys, `,
- {
- IniRead, Val, Config.ini, %Section%, %A_LoopField%
- Gui, Add, Text,, %A_LoopField%
- If (!Val || Val = 1)
- {
- Gui, Add, CheckBox, v%Section%_%A_LoopField% Checked%Val%
- ConHeight%KeyNum% += 43
- }
- Else
- {
- Gui, Add, Edit, v%Section%_%A_LoopField%, %Val%
- ConHeight%KeyNum% += 46.3
- }
- }
- ConHeight .= ConHeight%KeyNum% "`n"
- }
- }
- Else
- {
- Section := Secs
- Gui, Tab, 1
- Keys := RIni_GetSectionKeys("Config",Section)
- Loop, Parse, Keys, `,
- {
- IniRead, Val, Config.ini, %Section%, %A_LoopField%
- Gui, Add, Text,, %A_LoopField%
- If (!Val || Val = 1)
- Gui, Add, CheckBox, v%Section%_%A_LoopField% Checked%Val%
- Else
- Gui, Add, Edit, v%Section%_%A_LoopField%, %Val%
- }
- }
- Gui, Tab
- Gui, Add, Button, % "vButton gSubmit y" ConHeight1 + 50 " xm", Save Changes
- GuiControl, Move, Tabbing, % "H" ConHeight1 + 35
- Gui, Show,, Ini Editor
- Gui, +LastFound
- GroupAdd, MyGui, % "ahk_id " . WinExist()
- Return
- Submit:
- Gui, Submit
- If InStr(Secs, "|")
- {
- Loop, Parse, Secs, |
- {
- Section := A_LoopField
- Keys := RIni_GetSectionKeys("Config",Section)
- Loop, Parse, Keys, `,
- IniWrite, % %Section%_%A_LoopField%, Config.ini, %Section%, %A_LoopField%
- }
- }
- Else
- {
- Section := Secs
- Gui, Tab, 1
- Keys := RIni_GetSectionKeys("Config",Section)
- Loop, Parse, Keys, `,
- IniWrite, % %Section%_%A_LoopField%, Config.ini, %Section%, %A_LoopField%
- }
- ExitApp
- GuiSize:
- UpdateScrollBars(A_Gui, A_GuiWidth, A_GuiHeight)
- return
- GuiClose:
- ExitApp
- #IfWinActive ahk_group MyGui
- WheelUp::
- WheelDown::
- +WheelUp::
- +WheelDown::
- ; SB_LINEDOWN=1, SB_LINEUP=0, WM_HSCROLL=0x114, WM_VSCROLL=0x115
- OnScroll(InStr(A_ThisHotkey,"Down") ? 1 : 0, 0, GetKeyState("Shift") ? 0x114 : 0x115, WinExist())
- return
- #IfWinActive
- UpdateScrollBars(GuiNum, GuiWidth, GuiHeight)
- {
- static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1
- Gui, %GuiNum%:Default
- Gui, +LastFound
- ; Calculate scrolling area.
- Left := Top := 9999
- Right := Bottom := 0
- WinGet, ControlList, ControlList
- Loop, Parse, ControlList, `n
- {
- GuiControlGet, c, Pos, %A_LoopField%
- if (cX < Left)
- Left := cX
- if (cY < Top)
- Top := cY
- if (cX + cW > Right)
- Right := cX + cW
- if (cY + cH > Bottom)
- Bottom := cY + cH
- }
- Left -= 8
- Top -= 8
- Right += 8
- Bottom += 8
- ScrollWidth := Right-Left
- ScrollHeight := Bottom-Top
- ; Initialize SCROLLINFO.
- VarSetCapacity(si, 28, 0)
- NumPut(28, si) ; cbSize
- NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask
- ; Update horizontal scroll bar.
- NumPut(ScrollWidth, si, 12) ; nMax
- NumPut(GuiWidth, si, 16) ; nPage
- DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1)
- ; Update vertical scroll bar.
- ; NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask
- NumPut(ScrollHeight, si, 12) ; nMax
- NumPut(GuiHeight, si, 16) ; nPage
- DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1)
- if (Left < 0 && Right < GuiWidth)
- x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left)
- if (Top < 0 && Bottom < GuiHeight)
- y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top)
- if (x || y)
- DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0)
- }
- OnScroll(wParam, lParam, msg, hwnd)
- {
- static SIF_ALL=0x17, SCROLL_STEP=10
- bar := msg=0x115 ; SB_HORZ=0, SB_VERT=1
- VarSetCapacity(si, 28, 0)
- NumPut(28, si) ; cbSize
- NumPut(SIF_ALL, si, 4) ; fMask
- if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si)
- return
- VarSetCapacity(rect, 16)
- DllCall("GetClientRect", "uint", hwnd, "uint", &rect)
- new_pos := NumGet(si, 20) ; nPos
- action := wParam & 0xFFFF
- if action = 0 ; SB_LINEUP
- new_pos -= SCROLL_STEP
- else if action = 1 ; SB_LINEDOWN
- new_pos += SCROLL_STEP
- else if action = 2 ; SB_PAGEUP
- new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP
- else if action = 3 ; SB_PAGEDOWN
- new_pos += NumGet(rect, 12, "int") - SCROLL_STEP
- else if (action = 5 || action = 4) ; SB_THUMBTRACK || SB_THUMBPOSITION
- new_pos := wParam>>16
- else if action = 6 ; SB_TOP
- new_pos := NumGet(si, 8, "int") ; nMin
- else if action = 7 ; SB_BOTTOM
- new_pos := NumGet(si, 12, "int") ; nMax
- else
- return
- min := NumGet(si, 8, "int") ; nMin
- max := NumGet(si, 12, "int") - NumGet(si, 16) ; nMax-nPage
- new_pos := new_pos > max ? max : new_pos
- new_pos := new_pos < min ? min : new_pos
- old_pos := NumGet(si, 20, "int") ; nPos
- x := y := 0
- if bar = 0 ; SB_HORZ
- x := old_pos-new_pos
- else
- y := old_pos-new_pos
- ; Scroll contents of window and invalidate uncovered area.
- DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0)
- ; Update scroll bar.
- NumPut(new_pos, si, 20, "int") ; nPos
- DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1)
- }
- Tab:
- Gui, Submit, NoHide
- GuiControl, Move, Tabbing, % "H" ConHeight%Tabbing% + 35
- GuiControl, Move, Button, % "Y" ConHeight%Tabbing% + 50
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement