Sign in to follow this  
Followers 0
InunoTaishou

Changing Variables from items clicked in Menus

2 posts in this topic

Making a menu and I'm wanting to modify the size, weight and font name using the options from the menu. I feel like I'm close but not close enough....

#include <ButtonConstants.au3>
#include <GuiButton.au3>
#include <GuiMenu.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <Constants.au3>
#include <File.au3>
#include <Array.au3>
#include <Misc.au3>
#include <Date.au3>
#include <EditConstants.au3>
 
; AutoIt Options and Default Hot Keys
AutoitSetOption("WinTitleMatchMode",2)
AutoitSetOption("SendKeyDelay",0)
AutoitSetOption("GUIResizeMode", 1)
HotKeySet("{PRINTSCREEN}","Reset_Flag")
HotKeySet("{F1}","Help")
Hotkeyset ("{Esc}", "CloseProc")
 
; Variables
Local $string[] = ["Select", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Delete", "End", "Home", "Insert", "PgUp", "PgDwn"]
local $hidden = False
Local $flag = 0, $help_flag = 0, $num = 20
Local $size = 13, $weight = 400, $attribute = "", $fontname = ""
Local $DLL = "user32.dll", $path = @DocumentsCommonDir & "\", $iniFile = "Hot Key Settings.ini", $logPath = @DocumentsCommonDir & "\Logs\"
Local $iniData = "Password=" & @LF & "lsusb=" & @LF & "Reboot=" & @LF & "Tail-f=" & @LF & "DVR Login=" & @LF & "Bill Acceptor Script="
Local $menu_array = _FileLIstToArray(@WindowsDir & "\Fonts\")
 
; The GUI
GuiCreate("Hotkeys",500,300,-1,-1,BitOr($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
Local $text_menu = GUIctrlCreateMenu("&Text Properties")
Local $font_menu = GUICtrlCreateMenu("Font", $text_menu, 1)
Local $size_menu = GUICtrlCreateMenu("&Text Size",$text_menu, 1)
Local $weight_menu = GUICtrlCreateMenu("Weight",$text_menu, 2)
GUICtrlCreateMenuItem("",$text_menu,3)
GUICtrlCreateLabel("Password Key:",5,5,75,15)
GUICtrlSetResizing(-1,802)
GUICtrlCreateLabel("lsusb Key:",5,30,75,15)
GUICtrlSetResizing(-1,802)
GUICtrlCreateLabel("Reboot Key:",5,55,75,15)
GUICtrlSetResizing(-1,802)
GUICtrlCreateLabel("Tail-f Key:",5,80,75,15)
GUICtrlSetResizing(-1,802)
GUICtrlCreateLabel("DVR login:",5,105,75,15)
GUICtrlSetResizing(-1,802)
GUICtrlCreateLabel("Bill Acceptor:",5,130,75,15)
GUICtrlSetResizing(-1,802)
$notes = GUICtrlCreateEdit("",160,5,330,245)
GUICtrlSetResizing(-1,$GUI_DOCKLEFT)
GUICtrlSetFont($notes,$size,$weight,$attribute,$fontname)
 
; Give Menu Items Options
For $i = 0 To UBound($menu_array) - 1
   GUICtrlCreateMenuItem($menu_array[$i],$font_menu)
Next
 
For $i = 10 To 20
   GUICtrlCreateMenuItem($i,$size_menu)
Next
 
For $i = 400 To 1500 Step +100
   GUICtrlCreateMenuItem($i,$weight_menu)
Next
 
; Fill drop down boxes with available hot keys
$pw = GUICtrlCreateCombo("Select",80,5,75,15,$CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,802)
For $i = 0 To UBound($string) - 1
   GuiCtrlSetData($pw,$string[$i])
Next
$lsUsb = GUICtrlCreateCombo("Select",80,30,75,15,$CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,802)
For $i = 0 To UBound($string) - 1
   GuiCtrlSetData($lsUsb,$string[$i])
Next
$reboot = GUICtrlCreateCombo("Select",80,55,75,15,$CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,802)
For $i = 0 To UBound($string) - 1
   GuiCtrlSetData($reboot,$string[$i])
Next
$tail = GUICtrlCreateCombo("Select",80,80,75,15,$CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,802)
For $i = 0 To UBound($string) - 1
   GuiCtrlSetData($tail,$string[$i])
Next
$login = GUICtrlCreateCombo("Select",80,105,75,15,$CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,802)
For $i = 0 To UBound($string) - 1
   GuiCtrlSetData($login,$string[$i])
Next
$bill_acceptor = GUICtrlCreateCombo("Select",80,130,75,15,$CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,802)
For $i = 0 To UBound($string) - 1
   GuiCtrlSetData($bill_acceptor,$string[$i])
Next
 
If FileExists($path & $iniFile) Then ; Create and load saved settings
   If IniRead($path & $iniFile,"Hot Keys", "Password","") <> "" Then GuiCtrlSetData($pw,IniRead($path & $iniFile,"Hot Keys","Password",""))
   If iniRead($path & $iniFile, "Hot Keys", "lsusb","") <> "" Then GuiCtrlSetData($lsUsb,IniRead($path & $iniFile,"Hot Keys","lsusb",""))
   If iniRead($path & $iniFile, "Hot Keys", "Reboot","") <> "" Then GuiCtrlSetData($reboot,IniRead($path & $iniFile,"Hot Keys","Reboot",""))
   If iniRead($path & $iniFile, "Hot Keys", "Tail-f","") <> "" Then GuiCtrlSetData($tail,IniRead($path & $iniFile,"Hot Keys","Tail-f",""))
   If iniRead($path & $iniFile, "Hot Keys", "DVR Login","") <> "" Then GuiCtrlSetData($login,IniRead($path & $iniFile,"Hot Keys","DVR Login",""))
   If iniRead($path & $iniFile, "Hot Keys", "Bill Acceptor Script","") <> "" Then GuiCtrlSetData($bill_acceptor,IniRead($path & $iniFile,"Hot Keys","Bill Acceptor Script",""))
Else
   IniWrite($path & $iniFile, "Hot Keys", "", "")
   IniWriteSection($path & $iniFile, "Hot Keys", $iniData)
EndIf
GUISetState(@SW_Show)
 
While 1 ; The Main Loop
   If GUICtrlRead($pw) <> "Select" Then
 HotKeySet("{" & GUICtrlRead($pw) & "}", "PW")
   EndIf
   If GUICtrlRead($lsUsb) <> "Select" Then
 HotKeySet("{" & GUICtrlRead($lsUsb) & "}", "lsUsb")
   EndIf
   If GUICtrlRead($reboot) <> "Select" Then
 HotKeySet("{" & GUICtrlRead($reboot) & "}", "reboot")
   EndIf
   If GUICtrlRead($tail) <> "Select" Then
 HotKeySet("{" & GUICtrlRead($tail) & "}", "tail")
   EndIf
   If GUICtrlRead($login) <> "Select" Then
 HotKeySet("{" & GUICtrlRead($login) & "}", "Login")
   EndIf
   If GUICtrlRead($bill_acceptor) <> "Select" Then
 HotKeySet("{" & GUICtrlRead($bill_acceptor) & "}", "bill_acceptor")
   EndIf
 
   Switch GUIGetMsg()
 Case $GUI_Event_Close
_Exit()
 Case $font_menu
$fontname = $font_menu
GUICtrlSetFont($notes,$size,$weight,$attribute,$fontname)
 Case $size_menu
$size = $size_menu
MsgBOx("","",$size & " " & $size2)
GUICtrlSetFont($notes,$size,$weight,$attribute,$fontname)
 Case $weight_menu
$weight = $weight_menu
GUICtrlSetFont($notes,$size,$weight,$attribute,$fontname)
   EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Had to rush that post. I'm wanting to use the items created under

Local $font_menu = GUICtrlCreateMenu("Font", $text_menu, 1) 
Local $size_menu = GUICtrlCreateMenu("&Text Size",$text_menu, 1) 
Local $weight_menu = GUICtrlCreateMenu("Weight",$text_menu, 2)

 

TO modify the values

Local $size = 13, $weight = 400, $fontname = ""

 

And I'm creating the menu items with this

For $i = 0 To UBound($menu_array) - 1
   GUICtrlCreateMenuItem($menu_array[$i],$font_menu) 
Next   
For $i = 10 To 20
   GUICtrlCreateMenuItem($i,$size_menu) 
Next   
For $i = 400 To 1500 Step +100    GUICtrlCreateMenuItem($i,$weight_menu) 
Next

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0