Jump to content

Recommended Posts

Posted

Good day,

I would greatly appreciate it is someone would peruse the following script...to ensure that I am on the right track.
• I "kind' fig'urd" this out myself - but only with the assistance of pixelsearch and ioa747!! Many thanks to you both!!

Spoiler
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $Form1, $sCol1Row1, $sCol1Row2
Global $Form2, $sOption1Button
Global $Form3, $sOption2Button
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $Form1 = GUICreate("Form 1", 120, 45, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    $sCol1Row1 = GUICtrlCreateButton("Enable [F10]", 10, 10, 100, 25)
    GUICtrlSetOnEvent($sCol1Row1, "EnableF10")
    ; -----------------
    $Form2 = GUICreate("Form 2", 75, 15, -1, 400, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x3D3D3D)
    $sOption1Button = GUICtrlCreateLabel("[F10]", 0, 0, 75, 15, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sOption1Button, "_ColRow")
    ; -----------------
    $Form3 = GUICreate("Form 3", 75, 15, -1, 400, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x3D3D3D)
    $sOption2Button = GUICtrlCreateLabel("[F12]", 0, 0, 75, 15, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sOption2Button, "_ColRow")
    ; -----------------------------------------------
    GUISwitch($Form1)
    GUISetState(@SW_SHOW)
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func EnableF10()
    GUISetState(@SW_HIDE, $Form1)
    GUISwitch($Form2)
    MsgBox($MB_OK, "", "The [F10] label is now enabled...", 1)
    GUISetState(@SW_SHOW)
EndFunc   ;==>EnableF10
; -----------------------------------------------
Func EnableF12()
    GUISetState(@SW_HIDE, $Form1)
    MsgBox($MB_OK, "", "The [F12] label is now enabled...", 1)
    GUISwitch($Form3)
    GUISetState(@SW_SHOW)
EndFunc   ;==>EnableF12
; -----------------------------------------------
Func _ColRow()
;~  ConsoleWrite("@GUI_CtrlId=" & @GUI_CtrlId & @CRLF)
    Switch @GUI_CtrlId
        Case $sOption1Button
            GUISetState(@SW_HIDE, $Form2)
            EnableF12()
            GUISwitch($Form1)
        Case $sOption2Button
            GUISetState(@SW_HIDE, $Form3)
            GUISwitch($Form1)
            GUISetState(@SW_SHOW, $Form1)
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            MsgBox($MB_OK, "GUI Event", "Exiting...", 1)
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------

 

 

Posted (edited)

I find it okay, the only thing I found is an extra $sCol1Row2 in Global

Edit:
I found some other extra things too. 
here is a more organized version :)

Spoiler
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $Form1, $sCol1Row1 ;, $sCol1Row2
Global $Form2, $sOption1Button
Global $Form3, $sOption2Button
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $Form1 = GUICreate("Form 1", 120, 45, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    $sCol1Row1 = GUICtrlCreateButton("Enable [F10]", 10, 10, 100, 25)
    GUICtrlSetOnEvent($sCol1Row1, "_ColRow") ; ⚠  from "EnableF10" to
    ; -----------------
    $Form2 = GUICreate("Form 2", 75, 15, -1, 400, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUISetBkColor(0x3D3D3D)
    $sOption1Button = GUICtrlCreateLabel("[F10]", 0, 0, 75, 15, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sOption1Button, "_ColRow")
    ; -----------------
    $Form3 = GUICreate("Form 3", 75, 15, -1, 400, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUISetBkColor(0x3D3D3D)
    $sOption2Button = GUICtrlCreateLabel("[F12]", 0, 0, 75, 15, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sOption2Button, "_ColRow")
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------

    While 1
        Sleep(10)
    WEnd

EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
;~  ConsoleWrite("@GUI_CtrlId=" & @GUI_CtrlId & @CRLF)
    Switch @GUI_CtrlId
        Case $sCol1Row1 ; Form1 -> Form2 [F10]
            GUISetState(@SW_HIDE, $Form1)
            GUISetState(@SW_SHOW, $Form2)
            ; GUISwitch($Form2)
            ToolTip("The [F10] label is now enabled...", @DesktopWidth / 2, @DesktopHeight / 3)
            Sleep(1000)
            ToolTip("")

        Case $sOption1Button ; Form2 [F10] -> Form3 [F12]
            GUISetState(@SW_HIDE, $Form2)
            GUISetState(@SW_SHOW, $Form3)
            ; GUISwitch($Form3)
            ToolTip("The [F12] label is now enabled...", @DesktopWidth / 2, @DesktopHeight / 3)
            Sleep(1000)
            ToolTip("")

        Case $sOption2Button ; Form3 [F12] -> Form 1
            GUISetState(@SW_HIDE, $Form3)
            GUISetState(@SW_SHOW, $Form1)
            ; GUISwitch($Form1)

    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            ToolTip("Exiting...", @DesktopWidth / 2, @DesktopHeight / 3)
            Sleep(1000)
            ToolTip("")
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------

 

 

Edited by ioa747

I know that I know nothing

  • Solution
Posted (edited)

I organized them this way so you can have a quick overview of what is visible and what is not.
because in the EnableF12() function, when you call it, the first thing it does is
GUISetState(@SW_HIDE, $Form1)
while Form1 is already hidden

Edit:
GUISwitch() is needed if you are creating a new control, so that the control knows which form it will sit on.

Edited by ioa747

I know that I know nothing

Posted (edited)

ioa747,

Man I wish that I could think the way you do!?! [Click_Me]

As you know, I have three script that i employ...all three of which I have had to update as the result of employing OnEvent in my menu.
• EnableP7HotKeyLabel, EnableF10Label and EnableP8HotKeyLabel.

With your recent offering, I have been able to strip-down the EnableF10Label to accommodate the EnableP8HotKeyLabel script...

Spoiler
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $Form1, $sCol1Row1
Global $Form2, $sOption1Button
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $Form1 = GUICreate("Form 1", 120, 45, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    $sCol1Row1 = GUICtrlCreateButton("Enable P8 HotKey", 10, 10, 100, 25)
    GUICtrlSetOnEvent($sCol1Row1, "_ColRow")
    ; -----------------
    $Form2 = GUICreate("Form 2", 75, 15, -1, 400, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x3D3D3D)
    $sOption1Button = GUICtrlCreateLabel("P8 HotKey", 0, 0, 75, 15, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sOption1Button, "_ColRow")
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $sCol1Row1
            GUISetState(@SW_HIDE, $Form1)
            GUISetState(@SW_SHOW, $Form2)
            MsgBox($MB_OK, "", "The P8 HotKey label is now enabled...", 1)
        Case $sOption1Button
            GUISetState(@SW_HIDE, $Form2)
            GUISetState(@SW_SHOW, $Form1)
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            MsgBox($MB_OK, "GUI Event", "Exiting...", 1)
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------

 

I DO HOPE your realize, ioa747, just how much I appreciate your efforts on my behalf!
• Most of  my scripts are predicated by "Update provided by ioa747, with sincere gratitude..."

Credit due, where credit is - and must be, deserved...

Edited by mr-es335

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...