Jump to content

XiaolinDraconis

Active Members
  • Posts

    32
  • Joined

  • Last visited

XiaolinDraconis's Achievements

  1. Ok so the transparency issue was due to a mix up in the variables, and the hotkey method I chose was with If Then statements and that just didn't work well so I went with a Switch Case. And TADA! Thanks again, oh and if you notice the hotkey has a variable now, that's for future adjustments, going to make it so the key can be changed. Near Perfection #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> Opt("TrayMenuMode", 3) Global $inifile = @ScriptDir & "\OTPT.ini", $val = IniRead($inifile,"Transparency","Value","204"), $transparency = 204, $AOT = 1, $Toggle = 0, $TapCount = 0, $Hotkey = "^{SPACE}" HotKeySet($Hotkey, "TapTimer") If FileExists($inifile) Then $AOT = IniRead($inifile, "AOT", "True", "1") $transparency = IniRead($inifile, "Transparency", "Value", "204") Else IniWrite($inifile, "AOT", "True", $AOT & @CRLF) IniWrite($inifile, "Transparency", "Value", $transparency & @CRLF & @CRLF & "Max Transparency Value = 255") EndIf $optionsGUI = GUICreate("Options", 365, 200, @DesktopWidth / 2 - 365 / 2, @DesktopHeight / 2 - 200 / 2) $RadioON = GUICtrlCreateRadio("ON", 128, 40, 49, 17) If $AOT = 1 Then GUICtrlSetState(-1, $GUI_CHECKED) $RadioOFF = GUICtrlCreateRadio("OFF", 184, 40, 49, 17) If $AOT = 0 Then GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateLabel("Always on top:", 116, 8, 120, 24) GUICtrlSetFont(-1, 12, 800, 0) GUICtrlCreateLabel("Transparency:", 96, 74, 117, 24) GUICtrlSetFont(-1, 12, 800, 0) $tlabel = GUICtrlCreateLabel($transparency, 216, 74, 117, 24) GUICtrlSetFont(-1, 12, 800, 0) $tSlider = GUICtrlCreateSlider(24, 112, 318, 45) GUICtrlSetLimit(-1, 255, 0) GUICtrlSetData(-1, $transparency) $optionsBtn_okay = GUICtrlCreateButton("OK", 136, 160, 75, 25) $options = TrayCreateItem("Settings") $about = TrayCreateItem("About") TrayCreateItem("") ; Create a separator line. $exit = TrayCreateItem("Exit") While 1 Local $tMsg = TrayGetMsg() Switch $tMsg Case $options GUISetState(@SW_SHOW, $optionsGUI) Case $about MsgBox(0, "About", "OnTopPeekThrough" & @CRLF & @CRLF & _ "Press" & $Hotkey & "to toggle" & @CRLF & _ "Or double tap for Options" & @CRLF & @CRLF & _ "By: AutoIt V3") Case $exit Exit EndSwitch Local $gMsg = GUIGetMsg() Switch $gMsg Case $optionsBtn_okay If GUICtrlRead($RadioON) = $GUI_CHECKED Then IniWrite($inifile, "AOT", "True", 1) ElseIf GUICtrlRead($RadioOFF) = $GUI_CHECKED Then IniWrite($inifile, "AOT", "True", 0) EndIf IniWrite($inifile, "Transparency", "Value", GUICtrlRead($tlabel)) GUISetState(@SW_HIDE, $optionsGUI) Case $tSlider $val = GUICtrlRead($tSlider) GUICtrlSetData($tlabel, $val) WinSetTrans($optionsGUI,"",$val) Sleep(666) WinSetTrans($optionsGUI,"",255) Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $optionsGUI) EndSwitch WEnd Func TapTimer() $TapCount += 1 Sleep(500) Switch $TapCount Case 2 GUISetState(@SW_SHOW, $optionsGUI) WinSetOnTop($optionsGUI, "", 1) WinSetTrans($optionsGUI, "", 255) $TapCount = 0 Case 1 OnTop() $TapCount = 0 Case Else GUISetState(@SW_SHOW, $optionsGUI) WinSetOnTop($optionsGUI, "", 1) WinSetTrans($optionsGUI, "", 255) $TapCount = 0 EndSwitch EndFunc ;==>TapTimer Func OnTop() If $Toggle = 0 Then $Toggle = 1 Set() Else $Toggle = 0 Unset() EndIf EndFunc ;==>OnTop Func Set() $WinTitle = WinGetTitle("[active]") WinSetOnTop($WinTitle, "", 1) WinSetTrans($WinTitle, "", $val) EndFunc ;==>Set Func Unset() $WinTitle = WinGetTitle("[active]") WinSetOnTop($WinTitle, "", 0) WinSetTrans($WinTitle, "", 255) EndFunc ;==>Unset
  2. Very nice, thank you. I know the Hotkey thing is sloppy, but I didn't see another way to go about having the delay for opening the options. Think I'll turn that into a double tap instead of holding it. The double tap method I'm gonna use is still choppy, but also I need to work out some more issues. It doesn't seem to be saving the transparency setting properly, also it is applying the transparency setting to the Settings GUI. Pretty sure some of that if not all is coming from the way I setup the Hotkey. I'll work it out, then post what I did when I'm done.
  3. Well yeah, but one problem leads to another, and then I got new ideas for it while fixing those.
  4. I think I need to start over, get a fresh look at what's in my head. See how I really want this to work, as it is I went for something simple and kept tweaking.
  5. apparently i didnt entirely fix it.
  6. Managed to fix the slider. Now working on radio buttons.
  7. Don't see why it won't keep the settings when Options() gets called, keeps reverting to unchecked radios and slider at 100 of 255. It should be reading the INI for those values each time it's called. #NoTrayIcon #include <Misc.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. HotKeySet("^{SPACE}", "TapTimer") If FileExists(".\OTPT.ini") Then Sleep(1000) Else IniWrite("OTPT.ini", "AOT", "True", "1" & @CRLF) IniWrite("OTPT.ini", "Transparency", "Value", "204" & @CRLF & @CRLF & "Max Transparency Value = 255") EndIf $Toggle = 0 $AOT = IniRead("OTPT.ini", "AOT", "True", "1") $Transparency = IniRead("OTPT.ini", "Transparency", "Value", "204") TrayMenu() Func TrayMenu() TrayCreateItem("Settings") TrayItemSetOnEvent(-1, "Options") TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") TrayCreateItem("") ; Create a separator line. TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Options") ; Display the About MsgBox when the tray icon is double clicked on with the primary mouse button. TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. EndFunc ;==>TrayMenu While 1 Sleep(100) ; An idle loop. WEnd Func TapTimer() HotKeySet("^{SPACE}") $TapTime = 0 While _IsPressed("20") Sleep(1000) $TapTime += 1 WEnd If $TapTime < 3 Then OnTop() Sleep(500) Else Options() Sleep(500) EndIf HotKeySet("^{SPACE}", "TapTimer") EndFunc ;==>TapTimer Func Options() $Form1 = GUICreate("Settings", 290, 142) $Radio1 = GUICtrlCreateRadio("", 119, 32, 17, 17) If $AOT = 1 Then GUICtrlSetData($Radio1, $GUI_CHECKED, $GUI_CHECKED) Else GUICtrlSetData($Radio1, $GUI_UNCHECKED, $GUI_UNCHECKED) EndIf $Radio2 = GUICtrlCreateRadio("", 168, 32, 17, 17) $Label1 = GUICtrlCreateLabel("ON", 96, 32, 20, 17) $Label2 = GUICtrlCreateLabel("OFF", 142, 30, 24, 17) $Slider = GUICtrlCreateSlider(13, 72, 255, 25) GUICtrlSetData(-1, $Transparency) GUICtrlSetLimit(-1, 255, 0) $Label3 = GUICtrlCreateLabel("-", 8, 72, 15, 17) $Label4 = GUICtrlCreateLabel("+", 269, 70, 10, 17) $Label5 = GUICtrlCreateLabel("Always On Top", 102, 3, 89, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Transparency", 106, 56, 81, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $OK = GUICtrlCreateButton("OK", 128, 104, 33, 33) GUISetState(@SW_SHOW) WinSetOnTop("Settings", "", 1) While 1 WinActivate("Settings") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) ExitLoop Case $OK While GUICtrlRead($Radio1) = $GUI_UNCHECKED And GUICtrlRead($Radio2) = $GUI_UNCHECKED Sleep(100) ToolTip("Please Select ON/OFF State") WinActivate("Settings") WEnd If GUICtrlGetState($Radio1) = $GUI_CHECKED Then $AOT = 1 $Transparency = GUICtrlRead($Slider) Else $AOT = 0 $Transparency = GUICtrlRead($Slider) EndIf IniWrite("OTPT.ini", "AOT", "True", $AOT) IniWrite("OTPT.ini", "Transparency", "Value", $Transparency) ToolTip("") GUISetState(@SW_HIDE) ExitLoop EndSwitch WEnd EndFunc ;==>Options Func About() MsgBox($MB_OK, "About", "OnTopPeekThrough" & @CRLF & @CRLF & _ "Press CTRL+SPACE to toggle" & @CRLF & _ "Or hold 3 seconds for Options" & @CRLF & @CRLF & _ "By: XiaolinDraconis") EndFunc ;==>About Func OnTop() If $Toggle = 0 Then $Toggle = 1 Set() Else $Toggle = 0 Unset() EndIf EndFunc ;==>OnTop Func Set() $WinTitle = WinGetTitle("[active]") WinSetOnTop($WinTitle, "", 1) WinSetTrans($WinTitle, "", $Transparency) EndFunc ;==>Set Func Unset() $WinTitle = WinGetTitle("[active]") WinSetOnTop($WinTitle, "", 0) WinSetTrans($WinTitle, "", 255) EndFunc ;==>Unset Func ExitScript() Exit EndFunc ;==>ExitScript
  8. #NoTrayIcon #include <Misc.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. HotKeySet("^{SPACE}", "TapTimer") If FileExists(".\OTPT.ini") Then Sleep(1000) Else IniWrite("OTPT.ini", "AOT", "True", "1" & @CRLF) IniWrite("OTPT.ini", "Transparency", "Value", "204" & @CRLF & @CRLF & "Max Transparency Value = 255") EndIf $Toggle = 0 $AOT = IniRead("OTPT.ini", "AOT", "True", "1") $Transparency = IniRead("OTPT.ini", "Transparency", "Value", "204") TrayMenu() Func TrayMenu() TrayCreateItem("Settings") TrayItemSetOnEvent(-1, "Options") TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") TrayCreateItem("") ; Create a separator line. TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Options") ; Display the About MsgBox when the tray icon is double clicked on with the primary mouse button. TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. EndFunc ;==>TrayMenu While 1 Sleep(100) ; An idle loop. WEnd Func TapTimer() HotKeySet("^{SPACE}") $TapTime = 0 While _IsPressed("20") Sleep(1000) $TapTime += 1 WEnd If $TapTime < 3 Then OnTop() Sleep(500) Else Options() Sleep(500) EndIf HotKeySet("^{SPACE}", "TapTimer") EndFunc ;==>TapTimer Func Options() $Form1 = GUICreate("Settings", 290, 142) $Radio1 = GUICtrlCreateRadio("", 119, 32, 17, 17) If $AOT = 1 Then GUICtrlSetData($Radio1, $GUI_CHECKED, $GUI_CHECKED) Else GUICtrlSetData($Radio1, $GUI_UNCHECKED, $GUI_UNCHECKED) EndIf $Radio2 = GUICtrlCreateRadio("", 168, 32, 17, 17) $Label1 = GUICtrlCreateLabel("ON", 96, 32, 20, 17) $Label2 = GUICtrlCreateLabel("OFF", 142, 30, 24, 17) $Slider = GUICtrlCreateSlider(13, 72, 255, 25) GUICtrlSetData(-1, $Transparency) GUICtrlSetLimit(-1, 255, 0) $Label3 = GUICtrlCreateLabel("-", 8, 72, 15, 17) $Label4 = GUICtrlCreateLabel("+", 269, 70, 10, 17) $Label5 = GUICtrlCreateLabel("Always On Top", 102, 3, 89, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Transparency", 106, 56, 81, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $OK = GUICtrlCreateButton("OK", 128, 104, 33, 33) GUISetState(@SW_SHOW) WinSetOnTop("Settings", "", 1) While 1 WinActivate("Settings") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) ExitLoop Case $OK While GUICtrlRead($Radio1) = $GUI_UNCHECKED And GUICtrlRead($Radio2) = $GUI_UNCHECKED Sleep(100) ToolTip("Please Select ON/OFF State") WinActivate("Settings") WEnd If GUICtrlGetState($Radio1) = $GUI_CHECKED Then $AOT = 1 $Transparency = GUICtrlRead($Slider) Else $AOT = 0 $Transparency = GUICtrlRead($Slider) EndIf IniWrite("OTPT.ini", "AOT", "True", $AOT) IniWrite("OTPT.ini", "Transparency", "Value", $Transparency) ToolTip("") GUISetState(@SW_HIDE) ExitLoop EndSwitch WEnd EndFunc ;==>Options Func About() MsgBox($MB_OK, "About", "OnTopPeekThrough" & @CRLF & @CRLF & _ "Press CTRL+SPACE to toggle" & @CRLF & _ "Or hold 3 seconds for Options" & @CRLF & @CRLF & _ "By: XiaolinDraconis") EndFunc ;==>About Func OnTop() If $Toggle = 0 Then $Toggle = 1 Set() Else $Toggle = 0 Unset() EndIf EndFunc ;==>OnTop Func Set() $WinTitle = WinGetTitle("[active]") WinSetOnTop($WinTitle, "", 1) WinSetTrans($WinTitle, "", $Transparency) EndFunc ;==>Set Func Unset() $WinTitle = WinGetTitle("[active]") WinSetOnTop($WinTitle, "", 0) WinSetTrans($WinTitle, "", 255) EndFunc ;==>Unset Func ExitScript() Exit EndFunc ;==>ExitScript My apologies.
  9. Yeah I noticed that bit immediately after posting the snippet with that line in it. If you could prevent me from making a new thread, I'm now trying to understand why my slider keeps reverting to 100 and no radio is checked even though it should be reading those settings from the variables. $Form1 = GUICreate("Settings", 290, 142) $Radio1 = GUICtrlCreateRadio("", 119, 32, 17, 17) If $AOT = 1 Then GUICtrlSetData($Radio1,$GUI_CHECKED,$GUI_CHECKED) Else GUICtrlSetData($Radio1,$GUI_UNCHECKED,$GUI_UNCHECKED) EndIf $Radio2 = GUICtrlCreateRadio("", 168, 32, 17, 17) $Label1 = GUICtrlCreateLabel("ON", 96, 32, 20, 17) $Label2 = GUICtrlCreateLabel("OFF", 142, 30, 24, 17) $Slider = GUICtrlCreateSlider(13, 72, 255, 25) GUICtrlSetData(-1, $Transparency) GUICtrlSetLimit(-1, 255, 0) $Label3 = GUICtrlCreateLabel("-", 8, 72, 15, 17) $Label4 = GUICtrlCreateLabel("+", 269, 70, 10, 17) $Label5 = GUICtrlCreateLabel("Always On Top", 102, 3, 89, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Transparency", 106, 56, 81, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $OK = GUICtrlCreateButton("OK", 128, 104, 33, 33) GUISetState(@SW_SHOW)
  10. Func TapTimer() HotKeySet("^{SPACE}") $TapTime = 0 While _IsPressed("20") Sleep(1000) $TapTime += 1 WEnd If $TapTime < 3 Then OnTop() Sleep(500) Else Options() Sleep(500) EndIf HotKeySet("^{SPACE}", "OnTop") EndFunc ;==>TapTimer Once again it works as expected, but only once. Holding the hotkey again simply rapid fires the OnTop() function. I don't see how it can since the first line in TapTimer() is set to disable the hotkey.
  11. "If calling this function repeatedly, you should open 'user32.dll' and pass the handle. Make sure to close the handle at end of script using DllClose." Derped once again. Ok then, apparently I still don't understand, I used the DLLCall but to no avail. Updated OP with altered (still fail) code
  12. Just realized I need to add something to the options, redefine HotKey. Oh boy... I'll handle that after this issue gets sorted.
  13. Works perfectly now, only feature I'm still working on is being able to change the hotkey.
  14. If CTRL+Space are pressed for less than 3 seconds it makes the active window always on top and transparent, longer than that it will open the settings dialog. Toggles with each tap.
×
×
  • Create New...