Sorry for the late reply, trying to opt for a good one rather than a timely one. I felt like there was a lot to learn in just those two snippets, and after a while of struggling to get both working simultaneously in my old script (user errors), decided to rebuild everything in a single gui like you've suggested (which is a much better way to do things). I appreciate the help, everything works in my new script with exception to being able to submit for the color strips to update during a hotkey. I've tried a few different approaches to no success; I can manually activate the edit then write a hex color and press enter manually for a successful color update, I can even target the gui with focus through a hotkey then hit enter manually to success, but nothing within a hotkey sequence while sending enter and I don't understand why. [Line 299 in "DropR"]
I also had a mysterious blue color appear when I tried to change your function to affect the foreground color of the progress rather than the background. I edited the function and the control to what I expect would work, and it did have it working--but I couldn't get the background to reappear and my progress control is strangely blue on startup which I don't understand. I wanted to use the background as the border or frame by keeping it a static grey (#2B2B2B) but I had to work around it by adding borders to the image underlay beneath.
I've taken care of everything else to try and learn more about AHK, but I'd still appreciate a look over what I'm doing if you have time. From lines 268-430, I'm copying data to then paste into the hex edits or vice versa into Illustrator panels, but the only way I know to do this is through my clipboard. I suspect there'd be a better way than GuiControlGet > Clipboard then Clipboard > AI Panel and it's not an interruption but it'd be nice to retain previous clipboard contents without clearing them in case they're shapes or objects within Illustrator. I'm including the full script below, also a link to
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force
mainProg := "illustrator"
mask = 373737
frame = 434343
Ctext = D5D5D5
; Gui
;Settings
Gui, +AlwaysOnTop +Border -Caption +Owner hwndGuiID ; GuiID is used for the context-sensitive hotkeys
Gui, Margin , 2, 5
Gui, Font, s8 q4, Arial
Gui, Color, %mask%, 2c2c2c ; the second value will set the background color for the Edit controls
Gui +LastFound
WinSet, TransColor, %Mask%
;Header
Gui, Add, Picture, , mytmodHead.png
;Mouse Underlay
Gui, Add, Picture, yp+10 vMyPic, MyTmGui_def.png
;Mouse Keys
Gui, Add, Picture, xm+13 ym+15 vmLButton, mytmouseBig.png
GuiControl, Hide, mLButton
Gui, Add, Picture, xm+49 ym+15 vmRButton, mytmouseBig.png
GuiControl, Hide, mRButton
Gui, Add, Picture, xm+2 ym+36 vmF13, mytmouseMini.png
GuiControl, Hide, mF13
Gui, Add, Picture, xm+13 ym+36 vmF14, mytmouseMini.png
GuiControl, Hide, mF14
Gui, Add, Picture, xm+31 ym+33 vmMButton, mytmouseMedium.png
GuiControl, Hide, mMButton
Gui, Add, Picture, xm+13 ym+47 vmF15, mytmouseMedium.png
GuiControl, Hide, mF15
Gui, Add, Picture, xm+31 ym+47 vmF16, mytmouseMedium.png
GuiControl, Hide, mF16
Gui, Add, Picture, xm+49 ym+47 vmF17, mytmouseMedium.png
GuiControl, Hide, mF17
Gui, Add, Picture, xm+13 ym+62 vmXButton2, mytmouseMedium.png
GuiControl, Hide, mXButton2
Gui, Add, Picture, xm+31 ym+62 vmXButton1, mytmouseMedium.png
GuiControl, Hide, mXButton1
Gui, Add, Picture, xm+49 ym+62 vmF18, mytmouseMedium.png
GuiControl, Hide, mF18
;Divider
Gui, Add, Picture, xp-49 yp+20, mytmodDiv.png
;Mod Keys
Gui, Add, Picture, xp+7 yp+10 c%Rc% background0x%Mask% , myTmod+down.png
Gui, Add, Picture, yp c%Rc% background0x%Mask% vMyShiftUp, myTmod+up.png
Gui, Add, Picture, yp+16 c%Gc% background0x%Mask% vMyCtrlDown, myTmod^down.png
Gui, Add, Picture, yp c%Gc% background0x%Mask% vMyCtrlUp, myTmod^up.png
Gui, Add, Picture, xp+25 yp c%Bc% background0x%Mask% vMyAltDown, myTmod!down.png
Gui, Add, Picture, xp yp c%Bc% background0x%Mask% vMyAltUp, myTmod!up.png
;Bottom Underlay
Gui, Add, Picture, xp-34 yp+22 , mytmodBottom.png
;Settings (Offset, Angle, # of Loops)
;Gui, Add, Edit, xp+36 yp+11 w27 h13 Limit4 Uppercase -Multi -E0x200 c%Ctext% vBatchNo, 1.36
Gui, Add, Edit, Limit1 xp+6 yp+8 w28 h13 -E0x200 -VScroll c%Ctext% vOffsetN +WantReturn,
Gui, Add, UpDown, c2c2c2c Hidden vScrollBoxA , 2 ; ClassNN msctls_updown321
Gui, Add, Picture, xp+17 yp , mytmodNumArrows2.png
Gui, Add, Edit, Limit3 xp-18 yp+21 w22 h12 -E0x200 -VScroll c%Ctext% vAngleN +WantReturn, 135
Gui, Add, Picture, xp+22 yp , mytmodNumDeg.png
; Gui, Add, UpDown, c2c2c2c vScrollBoxA , 2 ; ClassNN {msctls_updown321}
Gui, Add, Edit, Limit1 xp-22 yp+21 w28 h13 -E0x200 -VScroll c%Ctext% vLoopN +WantReturn,
Gui, Add, UpDown, c2c2c2c Hidden vScrollBoxB , 5 ; ClassNN msctls_updown322
Gui, Add, Picture, xp+17 yp , mytmodNumArrows2.png
;Hex Color strips
; The below produces a mysterious blue color, not sure where it's coming from
; Gui, Add, Progress, xm+2 yp+150 w10 h12 Background%frame% cd44400 vRshifter, 100
Gui, Add, Progress, xm+2 yp+28 w10 h12 Backgroundd44400 vRshifter,
Gui, Add, Edit, x+3 yp w50 h12 Limit6 Uppercase -Multi -E0x200 c%Ctext% vRstripColor, d44400
Gui, Add, Progress, xm+2 yp+19 w10 h12 Background24EE49 vGshifter
Gui, Add, Edit, x+3 yp w50 h12 Limit6 Uppercase -Multi -E0x200 c%Ctext% vGstripColor, 24ee49
Gui, Add, Progress, xm+2 yp+19 w10 h12 Background5064F1 vBshifter
Gui, Add, Edit, x+3 yp w50 h12 Limit6 Uppercase -Multi -E0x200 c%Ctext% vBstripColor, 5064f1
Gui, Show, x571 y975
Return
; KeyLights (Mouse)
~*LButton::
GuiControl, Show, mLButton
Return
~*LButton Up::
GuiControl, Hide, mLButton
Return
~*RButton::
GuiControl, Show, mRButton
Return
~*RButton Up::
GuiControl, Hide, mRButton
Return
~*F13::
GuiControl, Show, mF13
Return
~*F13 Up::
GuiControl, Hide, mF13
Return
~*F14::
GuiControl, Show, mF14
Return
~*F14 Up::
GuiControl, Hide, mF14
Return
~*MButton::
GuiControl, Show, mMButton
Return
~*MButton Up::
GuiControl, Hide, mMButton
Return
~*F15::
GuiControl, Show, mF15
Return
~*F15 Up::
GuiControl, Hide, mF15
Return
~*F16::
GuiControl, Show, mF16
Return
~*F16 Up::
GuiControl, Hide, mF16
Return
~*F17::
GuiControl, Show, mF17
Return
~*F17 Up::
GuiControl, Hide, mF17
Return
~*XButton1::
GuiControl, Show, mXButton1
Return
~*XButton1 Up::
GuiControl, Hide, mXButton1
Return
~*XButton2::
GuiControl, Show, mXButton2
Return
~*XButton2 Up::
GuiControl, Hide, mXButton2
Return
~*F18::
GuiControl, Show, mF18
Return
~*F18 Up::
GuiControl, Hide, mF18
Return
; KeyLights (Modifiers)
~*LControl::
GuiControl, Hide, MyCtrlUp
GuiControl, Show, MyCtrlDown
CtrlState := "D"
Gosub, KeyChecker
Return
~*LControl Up::
GuiControl, Hide, MyCtrlDown
GuiControl, Show, MyCtrlUp
CtrlState := ""
Gosub, KeyChecker
Return
~*LShift::
GuiControl, Hide, MyShiftUp
GuiControl, Show, MyShiftDown
ShiftState := "D"
Gosub, KeyChecker
Return
~*LShift Up::
GuiControl, Hide, MyShiftDown
GuiControl, Show, MyShiftUp
ShiftState := ""
Gosub, KeyChecker
Return
~*LAlt::
GuiControl, Show, MyAltDown
GuiControl, Hide, MyAltUp
AltState := "D"
Gosub, KeyChecker
Return
~*LAlt Up::
GuiControl, Hide, MyAltDown
GuiControl, Show, MyAltUp
AltState := ""
Gosub, KeyChecker
Return
; Update the MouseGUIsub charts
KeyChecker:
if ( (AltState = "D") && (CtrlState = "D") && (ShiftState = "D") )
GuiControl, , MyPic, MyTmGui_keymap.png
Else if ( (AltState = "D") && (CtrlState = "D") && (ShiftState != "D") )
GuiControl, , MyPic, MyTmGui_^!.png
Else if ( (AltState = "D") && (CtrlState != "D") && (ShiftState = "D") )
GuiControl, , MyPic, MyTmGui_+!.png
Else if ( (AltState != "D") && (CtrlState = "D") && (ShiftState = "D") )
GuiControl, , MyPic, MyTmGui_^+.png
Else if ( (AltState != "D") && (CtrlState = "D") && (ShiftState = "D") )
GuiControl, , MyPic, MyTmGui_^+.png
Else if ( (AltState != "D") && (CtrlState != "D") && (ShiftState = "D") )
GuiControl, , MyPic, MyTmGui_+.png
Else if ( (AltState != "D") && (CtrlState = "D") && (ShiftState != "D") )
GuiControl, , MyPic, MyTmGui_^.png
Else if ( (AltState = "D") && (CtrlState != "D") && (ShiftState != "D") )
GuiControl, , MyPic, MyTmGui_!.png
Else
GuiControl, , MyPic, MyTmGui_def.png
return
GuiEscape:
ExitApp
; Context-sensitive hotkeys, will be triggered only if the Gui is active and one of the Edit controls has the focus
#If WinActive("ahk_id " . GuiID) && (EditVar := ColorEditHasFocus())
Return::
EditClr := SubStr(EditVar, 1, 1) ; Progress and Edit variable names share the first letter
GuiControlGet, HexClr, , %EditVar% ; get the contents of the Edit control
GuiControl, +Background%HexClr%, %EditClr%shifter ; change the background color of the related Progress control
; The mysterious blue color comes when switching the line above to this:
; GuiControl, +Background +c%HexClr%, %EditClr%shifter ; It will change color but the background won't respawn/reshow/reactivate
Return
#If ; end of context-sensitive hotkeys
; Function to get the name of the variable assigned to the focused Edit control, if any
ColorEditHasFocus() {
Static ColorEdits := "RstripColor,GstripColor,BstripColor"
GuiControlGet, FocusVar, FocusV
If FocusVar In %ColorEdits%
Return FocusVar
}
^Tab::
GuiControl, Focus, Edit1
WinActivate, ahk_id %GuiID%
Return
; Reset RGB
F21::
BlockInput, MouseMove
; WinActivate, ahk_id %GuiID%
; WinActivate, ahk_exe AutoHotkey.exe
Sleep, 50
Click, 625, 1307 Left, Down
Sleep, 20
Click, 625, 1307 Left, Up
Sleep, 20
Send, {CtrlDown}{a}{CtrlUp}
Sleep, 20
SendInput, d44400
Sleep, 20
Send, {Tab}
Sleep, 20
SendInput, 24ee49
Sleep, 20
Send, {Tab}
Sleep, 20
SendInput, 5064f1
Sleep, 20
Send, {Enter}
WinActivate, ahk_class %mainProg%
Sleep, 50
Click, 1280, 720, 0
BlockInput, MouseMoveOff
return
; DropR
F22::
BlockInput, MouseMove
Gui, Submit, NoHide
Clipboard := RstripColor
ClipWait, 0,
WinActivate, ahk_class tooltips_class32 Hwnd0x2b0436
Click, 2506, 229 Left,
Click, 2506, 239 Left,
Sleep, 20
Send, {CtrlDown}{a}{CtrlUp}
Sleep, 50
Send, %Clipboard%
Sleep, 50
Send, {Enter}
WinActivate, ahk_class %mainProg%
Sleep, 50
Click, 1280, 720, 0
BlockInput, MouseMoveOff
return
^F22::
; BlockInput, MouseMove
Clipboard =
WinActivate, ahk_class tooltips_class32 Hwnd0x2b0436
Click, 2506, 230 Left, Down
Sleep, 20
Click, 2506, 230 Left, Up
Sleep, 20
Send, {CtrlDown}{a}{c}{CtrlUp}
ClipWait, 1
Sleep, 50
; Tried to activate GUI, replace contents, hit Enter to submit
; WinActivate, ahk_id %GuiID%
; GuiControl, , Edit4, %Clipboard%
; Sleep, 50
; Send, {Enter}
; Sleep, 50
; Tried to activate focus on control, hit Enter and submit
; GuiControl, Focus, Edit4
; Sleep, 50
; Send, {Enter}
; Tried to click the edit control, hit enter and submit
; Click, 625, 1304 Left, Down
; Sleep, 20
; Click, 625, 1304 Left, Up
; Sleep, 20
; Send, {CtrlDown}{a}{CtrlUp}
; Sleep, 20
; Send, {Enter}
; Tried duplicating your context sensitive function, put it in a label and using gosub
; gosub ReturnDupe
; Gui, Submit, NoHide
; Tried using "return" instead of "enter", vice versa, even changing the hotkey here and in the
; function to another keyboard key entirely, still doesn't work?
; Send, {Return}
; It will change if I stop at the focus then manually hit enter, but not when I simulate/send an enter?
WinActivate, ahk_id %GuiID%
Sleep, 50
Send, {CtrlDown}{Tab}{CtrlUp}
Sleep, 50
Send, {Tab}{Tab}{Tab}
Sleep, 50
Send, %Clipboard%
Sleep, 50
Send, {Enter} ; I can get a message box after this line but the colors still don't change
Sleep, 20
; MsgBox, Where are you, Enter?
; Gui, Submit, NoHide
; WinActivate, ahk_class %mainProg%
; Sleep, 50
; Click, 1280, 720, 0
; BlockInput, MouseMoveOff
return
; DropG
F23::
BlockInput, MouseMove
Gui, Submit, NoHide
Clipboard := GstripColor
ClipWait, 0,
WinActivate, ahk_class tooltips_class32 Hwnd0x2b0436
Click, 2506, 229 Left,
Click, 2506, 239 Left,
Sleep, 20
Send, {CtrlDown}{a}{CtrlUp}
Sleep, 50
Send, %Clipboard%
Sleep, 50
Send, {Enter}
WinActivate, ahk_class %mainProg%
Sleep, 50
Click, 1280, 720, 0
BlockInput, MouseMoveOff
return
^F23::
BlockInput, MouseMove
Clipboard =
WinActivate, ahk_class tooltips_class32 Hwnd0x2b0436
Click, 2506, 230 Left, Down
Sleep, 20
Click, 2506, 230 Left, Up
Sleep, 20
Send, {CtrlDown}{a}{c}{CtrlUp}
ClipWait, 1
Sleep, 50
WinActivate, ahk_id %GuiID%
GuiControl, , Edit5, %Clipboard%
Sleep, 20
GuiControl, Focus, Edit5
Sleep, 20
Send, {Enter}
Gui, Submit, NoHide
Sleep, 20
WinActivate, ahk_class %mainProg%
Sleep, 50
Click, 1280, 720, 0
BlockInput, MouseMoveOff
return
; DropB
F24::
BlockInput, MouseMove
Gui, Submit, NoHide
Clipboard := BstripColor
ClipWait, 0,
WinActivate, ahk_class tooltips_class32 Hwnd0x2b0436
Click, 2506, 229 Left, Down
Sleep, 20
Click, 2506, 239 Left, Up
Sleep, 20
Send, {CtrlDown}{a}{CtrlUp}
Send, %Clipboard%
Send, {Enter}
WinActivate, ahk_class %mainProg%
Sleep, 50
Click, 1280, 720, 0
BlockInput, MouseMoveOff
return
^F24::
BlockInput, MouseMove
Clipboard =
WinActivate, ahk_class tooltips_class32 Hwnd0x2b0436
Click, 2506, 230 Left, Down
Sleep, 20
Click, 2506, 230 Left, Up
Sleep, 20
Send, {CtrlDown}{a}{c}{CtrlUp}
ClipWait, 1
Sleep, 50
WinActivate, ahk_id %GuiID%
GuiControl, , Edit6, %Clipboard%
Sleep, 20
GuiControl, Focus, Edit6
Sleep, 20
Send, {Enter}
Sleep, 20
Gui, Submit, NoHide
Sleep, 50
WinActivate, ahk_class %mainProg%
Sleep, 50
Click, 1280, 720, 0
BlockInput, MouseMoveOff
return
; Loops
;Left
*$+!XButton2::
; BlockInput, On
GuiControl, Show, mXButton2
Sleep, 50
; Send, {LAlt Up}{LShift Up}
Gui, Submit, NoHide
Clipboard := LoopN
ClipWait, 0
Loop, %clipboard%
{
Send, {Left}
Sleep, 50
}
; Send, {LAlt Down}{LShift Down}
GuiControl, Hide, mXButton2
; BlockInput, Off
Return
;Right
*$+!XButton1::
; BlockInput, On
GuiControl, Show, mXButton1
Sleep, 50
; Send, {LAlt Up}{LShift Up}
Gui, Submit, NoHide
Clipboard := LoopN
ClipWait, 0
Loop, %clipboard%
{
Send, {Right}
; Sleep, 50
}
GuiControl, Hide, mXButton1
; BlockInput, Off
Return
;Up
*$+!F15::
; BlockInput, On
GuiControl, Show, mF15
Sleep, 50
; Send, {LAlt Up}{LShift Up}
Gui, Submit, NoHide
Clipboard := LoopN
ClipWait, 0
Loop, %clipboard%
{
Send, {Up}
; Sleep, 50
}
GuiControl, Hide, mF15
; BlockInput, Off
Return
;Down
*$+!F16::
; BlockInput, On
GuiControl, Show, mF16
Sleep, 50
; Send, {LAlt Up}{LShift Up}
Gui, Submit, NoHide
Clipboard := LoopN
ClipWait, 0
Loop, %clipboard%
{
Send, {Down}
; Sleep, 20
}
GuiControl, Hide, mF16
; BlockInput, Off
Return
;Redo
*^+F15::
Gui, Submit, NoHide
GuiControl, Show, mF15
Clipboard := LoopN
ClipWait, 0
Loop, %clipboard%
{
Send, {CtrlDown}{d}{CtrlUp}
; Sleep, 20
}
GuiControl, Hide, mF15
Return
;RedoClone
*^+F16::
GuiControl, Show, mF16
Gui, Submit, NoHide
Clipboard := LoopN
ClipWait, 0
Loop, %clipboard%
{
; Will produce clones at end, glitched
; Send, {CtrlUp}{ShiftDown}{F7 Down}{ShiftUp}
; Sleep, 20
Send, {MButton}
Sleep, 50
Send, {CtrlDown}{d}{CtrlUp}
Sleep, 20
}
GuiControl, Hide, mF16
Return
;RotationAngle
^+MButton::
KeyWait, LControl
KeyWait, LShift
Gui, Submit, NoHide
Clipboard := AngleN
ClipWait, 0
WinActivate, ahk_class %mainProg%
Send, {r}
Sleep, 20
Send, {Enter}
; WinWaitActive, Rotate
; WinActivate, Rotate
Sleep, 200
Send, %Clipboard%
Sleep, 20
Send, {Enter}
Sleep, 20
WinActivate, ahk_class %mainProg%
BlockInput, Off
return
Esc::ExitApp
Lastly, without wearing out my welcome or hopefully appearing ungrateful, would it be impractical to simulate animation through changing GuiControl pictures every 40ms, 20ms, or 16.667 ms? I ask because I thought it'd be interesting to use loops containing GuiControls with png sequences that simulate 25 (or any I'd want) frames per second, so animations within loops that I could potentially break conditionally or have be interactive in some manner. I've seen that gifs are supported in gui displays but I don't see many discussions about using them interactively, and I'd specifically want to cushion animations like button presses with 3 to 5 frames to "ease in" or "ease out" of extreme poses when activated. If I could get away with it, I'd actually love to have multiple looping animations (which would be vector so very low data size and strict color profile, like my avatar or these icons in the gui) running on the gui but I'm not sure if it's pie in the sky or too cpu-intensive. Are there any examples that you've seen or know of, or any ways you think this would be best done? Avoiding flashing too?