diff --git a/Settings.exe b/Settings.exe new file mode 100644 index 0000000..5977c67 Binary files /dev/null and b/Settings.exe differ diff --git a/SimpleR.exe b/SimpleR.exe new file mode 100644 index 0000000..e4167e6 Binary files /dev/null and b/SimpleR.exe differ diff --git a/source/Include/InitialSetup.au3 b/source/Include/InitialSetup.au3 new file mode 100644 index 0000000..02d49c4 --- /dev/null +++ b/source/Include/InitialSetup.au3 @@ -0,0 +1,254 @@ +#include-once +#include ".\MetroGUI_UDF.au3" +#include ".\_GUIDisable.au3" ; For dim effects when msgbox is displayed +#include ".\IsPressed_UDF.au3" +#include +#include +#include +#include +#include + +AutoItSetOption("GUICloseOnESC", 0) + +;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe + +;Set Theme +_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more + +;Create resizable Metro GUI +$Form1 = _Metro_CreateGUI("Welcome to SimpleR", 800, 500, -1, -1, True) + +;Add/create control buttons to the GUI +$Control_Buttons = _Metro_AddControlButtons(True, False, False, False, False) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True + +;Set variables for the handles of the GUI-Control buttons. (Above function always returns an array this size and in this order, no matter which buttons are selected.) +$GUI_CLOSE_BUTTON = $Control_Buttons[0] +$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1] +$GUI_RESTORE_BUTTON = $Control_Buttons[2] +$GUI_MINIMIZE_BUTTON = $Control_Buttons[3] +$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4] +$GUI_FSRestore_BUTTON = $Control_Buttons[5] +$GUI_MENU_BUTTON = $Control_Buttons[6] + + +#Region Startpage +$s1_welcomeTo = GUICtrlCreateLabel("Welcome to", 40, 70, 720, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($s1_welcomeTo, 768 + 8) +GUICtrlSetColor($s1_welcomeTo, $COLOR_WHITE) +GUICtrlSetFont($s1_welcomeTo, 20, "", "", "Segoe UI") + +$s1_simpler = GUICtrlCreateLabel("SimpleR", 40, 110, 720, 80, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($s1_simpler, 768 + 8) +GUICtrlSetColor($s1_simpler, $COLOR_WHITE) +GUICtrlSetFont($s1_simpler, 40, "", "", "Segoe UI") + + +$s1_description = GUICtrlCreateLabel("The convenient way to play RotMG.", 40, 200, 720, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($s1_description, 768 + 8) +GUICtrlSetColor($s1_description, $COLOR_WHITE) +GUICtrlSetFont($s1_description, 20, "", "", "Segoe UI") + + +$s1_btnletsgo = _Metro_CreateButtonEx("Let's go!", 300, 400, 200, 50, $ButtonBKColor, $ButtonTextColor, "Arial", 16) +GUICtrlSetResizing($s1_btnletsgo, 768 + 8) + +#EndRegion Startpage + + +#Region FlashPage +$s2_Almost = GUICtrlCreateLabel("We are almost ready to play. " & @CRLF & "Before we can start, we need to download Adobe Flash Projector.", 40, 70, 720, 200, $SS_CENTER) +GUICtrlSetResizing($s2_Almost, 768 + 8) +GUICtrlSetColor($s2_Almost, $COLOR_WHITE) +GUICtrlSetFont($s2_Almost, 20, "", "", "Segoe UI") + +$s2_pleaseChoose = GUICtrlCreateLabel("Select version", 220, 260, 120, 20) +GUICtrlSetResizing($s2_pleaseChoose, 768 + 8) +GUICtrlSetColor($s2_pleaseChoose, $COLOR_WHITE) +GUICtrlSetFont($s2_pleaseChoose, 14, "", "", "Segoe UI") + +Global $fpversions = "Flashplayer_26_sa.exe|Flashplayer_25_sa.exe|Flashplayer_24_sa.exe|Flashplayer_23_sa.exe|Flashplayer_22_sa.exe|Flashplayer_21_sa.exe|Flashplayer_20_sa.exe" & _ + "|Flashplayer_19_sa.exe|Flashplayer_18_sa.exe|Flashplayer_17_sa.exe|Flashplayer_16_sa.exe|Flashplayer_15_sa.exe|Flashplayer_14_sa.exe (common choice)|Flashplayer_13_sa.exe|Flashplayer_12_sa.exe|Flashplayer_11_sa.exe|Flashplayer_10_sa.exe" + +Local $s2_version = GUICtrlCreateCombo("Flashplayer_27_sa.exe (recommended)", 350, 260, 250, 20, $CBS_DROPDOWNLIST) +GUICtrlSetFont($s2_version, 10, "", "", "Segoe UI") +GUICtrlSetData($s2_version, $fpversions, "Flashplayer_27_sa.exe (recommended)") + +$s2_alreadyHave = GUICtrlCreateLabel("Click here if you have already downloaded a copy of flash projector.", 220, 300, 400, 20, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($s2_alreadyHave, 768 + 8) +GUICtrlSetColor($s2_alreadyHave, $COLOR_WHITE) +GUICtrlSetFont($s2_alreadyHave, 9, "", "", "Segoe UI") + +$s2_startDL = _Metro_CreateButtonEx("Download", 300, 400, 200, 50, $ButtonBKColor, $ButtonTextColor, "Arial", 16) +GUICtrlSetResizing($s2_startDL, 768 + 8) + +#EndRegion FlashPage + +#Region DLprocess +$s3_dltext = GUICtrlCreateLabel("Downloading... ", 150, 100, 140, 50, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($s3_dltext, 768 + 8) +GUICtrlSetColor($s3_dltext, $COLOR_WHITE) +GUICtrlSetFont($s3_dltext, 14, "", "", "Segoe UI") + +$s3_status = GUICtrlCreateLabel("##% #/# ", 440, 100, 400, 50, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($s3_status, 768 + 8) +GUICtrlSetColor($s3_status, $COLOR_WHITE) +GUICtrlSetFont($s3_status, 14, "", "", "Segoe UI") + +$s3_pbar = _Metro_CreateProgress(150, 150, 500, 26) + +$s3_tip = GUICtrlCreateLabel("Tip: To make the custom cursor work, please change the game option under Graphics -> Custom Cursor to 'OFF' ", 150, 200, 500, 50) +GUICtrlSetResizing($s3_tip, 768 + 8) +GUICtrlSetColor($s3_tip, $COLOR_WHITE) +GUICtrlSetFont($s3_tip, 14, "", "", "Segoe UI") + +#EndRegion DLprocess + +#Region FinalPage + + +$s4_doneText = GUICtrlCreateLabel("Done! " & @CRLF & "Check out the settings (recommended) " & @CRLF & "or start playing the game c:", 40, 70, 720, 120, $SS_CENTER) +GUICtrlSetResizing($s4_doneText, 768 + 8) +GUICtrlSetColor($s4_doneText, $COLOR_WHITE) +GUICtrlSetFont($s4_doneText, 20, "", "", "Segoe UI") + +$s4_settings = _Metro_CreateButtonEx("Settings", 100, 300, 200, 50, $ButtonBKColor, $ButtonTextColor, "Arial", 16) +GUICtrlSetResizing($s4_settings, 768 + 8) + +$s4_play = _Metro_CreateButtonEx("Play", 500, 300, 200, 50, $ButtonBKColor, $ButtonTextColor, "Arial", 16) +GUICtrlSetResizing($s4_play, 768 + 8) + +#EndRegion FinalPage + + +Func _Welcome() + _InitialHide() + _ShowStartpage() + + GUISetState(@SW_SHOW) + While 1 + + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON + _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! + Exit + Case $s1_btnletsgo + _InitialHide() + _ShowFlashPage() + Case $s2_alreadyHave + _GUIDisable($Form1, 0, 30) + $r = FileOpenDialog("Please choose the flash projector file", @ScriptDir, "Executables (*.exe)", 0, "", $Form1) + If $r <> "" Then + FileCopy($r, @ScriptDir & "\data\flash.exe", 8) + If Not @error Then + MsgBox(0, "Success", "A copy was created at " & @ScriptDir & "\data\flash.exe") + _InitialHide() + + _ShowFinalPage() + EndIf + EndIf + _GUIDisable($Form1, 0, 30) + Case $s2_startDL + $v = GUICtrlRead($s2_version) + $v = StringTrimLeft($v, 12) + $v = StringTrimRight($v, StringLen($v) - 2) + _InitialHide() + _ShowDL() + _StartDL($v) + Case $s4_settings + Run($pathSettings) + _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! + Exit + Case $s4_play + _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! + Return 0 + EndSwitch + + WEnd +EndFunc ;==>_Welcome + + +Func _InitialHide() + GUICtrlSetState($s1_welcomeTo, 32) + GUICtrlSetState($s1_simpler, 32) + GUICtrlSetState($s1_description, 32) + GUICtrlSetState($s1_btnletsgo, 32) + GUICtrlSetState($s2_Almost, 32) + GUICtrlSetState($s2_pleaseChoose, 32) + GUICtrlSetState($s2_version, 32) + GUICtrlSetState($s2_alreadyHave, 32) + GUICtrlSetState($s2_startDL, 32) + + GUICtrlSetState($s3_dltext, 32) + GUICtrlSetState($s3_pbar[0], 32) + GUICtrlSetState($s3_status, 32) + GUICtrlSetState($s3_tip, 32) + + GUICtrlSetState($s4_doneText, 32) + GUICtrlSetState($s4_settings, 32) + GUICtrlSetState($s4_play, 32) + +EndFunc ;==>_InitialHide + +Func _ShowStartpage() + GUICtrlSetState($s1_welcomeTo, 16) + GUICtrlSetState($s1_simpler, 16) + GUICtrlSetState($s1_description, 16) + GUICtrlSetState($s1_btnletsgo, 16) +EndFunc ;==>_ShowStartpage + + +Func _ShowFlashPage() + GUICtrlSetState($s2_Almost, 16) + GUICtrlSetState($s2_pleaseChoose, 16) + GUICtrlSetState($s2_version, 16) + GUICtrlSetState($s2_alreadyHave, 16) + GUICtrlSetState($s2_startDL, 16) +EndFunc ;==>_ShowFlashPage + +Func _ShowDL() + GUICtrlSetState($s3_dltext, 16) + GUICtrlSetState($s3_pbar[0], 16) + GUICtrlSetState($s3_status, 16) + GUICtrlSetState($s3_tip, 16) +EndFunc ;==>_ShowDL + +Func _StartDL($fp_version = 27) + + $FileURL = "https://fpdownload.macromedia.com/pub/flashplayer/updaters/" & $fp_version & "/flashplayer_" & $fp_version & "_sa.exe" + + If Not FileExists(@ScriptDir & "\data)") Then + DirCreate(@ScriptDir & "\data") + EndIf + $FileName = @ScriptDir & "\data\flash.exe" + $FileSize = InetGetSize($FileURL) + $TotalSize = InetGetSize($FileURL) + $flashDL = InetGet($FileURL, $FileName, 0, 1) + + While (InetGetInfo($flashDL, 2)) = False + $stat = InetGetInfo($flashDL, 0) + $percent = $stat / $TotalSize * 100 + $percent = Ceiling($percent) + _Metro_SetProgress($s3_pbar, $percent) + GUICtrlSetData($s3_status, $percent & "% " & Round($stat / 1024 / 1024, 1) & " MB/" & Round($TotalSize / 1024 / 1024, 1) & " MB") + Sleep(100) + WEnd + _Metro_SetProgress($s3_pbar, 1100) + GUICtrlSetData($s3_status, "100" & "% " & Round($TotalSize / 1024 / 1024, 1) & " MB/" & Round($TotalSize / 1024 / 1024, 1) & " MB") + If Not @error Then + _InitialHide() + _ShowFinalPage() + EndIf + +EndFunc ;==>_StartDL + + + +Func _ShowFinalPage() + GUICtrlSetState($s4_doneText, 16) + GUICtrlSetState($s4_settings, 16) + GUICtrlSetState($s4_play, 16) +EndFunc ;==>_ShowFinalPage + + diff --git a/source/Include/IsPressed_UDF.au3 b/source/Include/IsPressed_UDF.au3 new file mode 100644 index 0000000..d08195e --- /dev/null +++ b/source/Include/IsPressed_UDF.au3 @@ -0,0 +1,378 @@ +#comments-start ----------------------------------------------------------------------------------- + Title: IsPressed Library UDF + Filename: IsPressed UDF.au3 + Description: Multiple _IsPressed functions based on original _IsPressed function + Author: FireFox + Version: 02.03.00 + Last Update: 12/06/2013 + Requirements: AutoIt v3.2 +, Developed/Tested on WindowsXP Familly Service Pack 3;Windows 7 + Notes: All _IsPressed functions works without have to specify the dll User32 + + Special thanks ezzetabi (original _IsPressed function) + Valuater for __KeyPressCheck ; __GetKeyType functions + MrCreator for _IsWheelKeyScroll function +#comments-end ------------------------------------------------------------------------------------- + +#include-once +#include ;_IsPressed func + +Global $IsWheelKeyScroll = False ;Declare WheelScroll false +OnAutoItExitRegister("OnAutoItExit") + +; #FUNCTION# =================================================================== +; Name : None +; Description: Opens 'user32.dll' +;=============================================================================== +$hUser32 = DllOpen('user32.dll') + + +; #FUNCTION# =================================================================== +; Name : _IsAnyKeyPressed +; Description: Returns 1 if anykey is pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): Thanks to Manadar for parameters +;=============================================================================== +Func _IsAnyKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(1, 221, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsAnyKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsOrKeyPressed +; Description: Returns 1 if anykey specified is pressed +; Parameter(s): $HexKey = Hexadecimal key(s) (keys are separated by '|') +; $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsOrKeyPressed($HexKey, $vDLL = 'user32.dll') + Local $nb, $sHexKey = StringSplit($HexKey, '|', 1) + + For $nb = 1 To UBound($sHexKey) - 1 + If __KeyPressCheck(1, 1, $sHexKey[$nb], $vDLL) Then Return 1 + Next + Return 0 +EndFunc ;==>_IsOrKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsAndKeyPressed +; Description: Returns 1 if all keys specified are pressed +; Parameter(s): $HexKey = Hexadecimal key(s) (keys are separated by '|') +; $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsAndKeyPressed($HexKey, $vDLL = 'user32.dll') + Local $sHexKey = StringSplit($HexKey, '|', 1) + + For $nb = 1 To UBound($sHexKey) - 1 + If Not __KeyPressCheck(1, 1, $sHexKey[$nb], $vDLL) Then Return 0 + Next + Return 1 +EndFunc ;==>_IsAndKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsAlphaKeyPressed +; Description: Returns 1 if anyalpha keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsAlphaKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(48, 90, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsAlphaKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsNumKeyPressed +; Description: Returns 1 if anynumeric keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsNumKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(96, 105, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsNumKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsAlphaNumKeyPressed +; Description: Returns 1 if anynumeric or anyalpha keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsAlphaNumKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(65, 105, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsAlphaNumKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsFuncKeyPressed +; Description: Returns 1 if anyfunction keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; $Extended = 1 then Include F13 to F24 keys +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsFuncKeyPressed($vDLL = 'user32.dll', $Extended = 1) + If __KeyPressCheck(112, 123, -1, $vDLL) Then Return 1 + If $Extended = 1 Then + If __KeyPressCheck(124, 135, -1, $vDLL) Then Return 1 + EndIf + Return 0 +EndFunc ;==>_IsFuncKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsArrowKeyPressed +; Description: Returns 1 if anyarrow keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsArrowKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(37, 40, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsArrowKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsMouseKeyPressed +; Description: Returns 1 if anymouse keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _IsMouseKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(1, 6, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsMouseKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsWheelKeyScroll +; Description: Returns wheel mouse key scrolled up or down +; Parameter(s): None +; Requirement(s): __WheelKeyScroll +; $IsWheelKeyScroll = False +; $aKey_Hooks[3] +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): MrCreator, FireFox +; Note(s): Thanks to MrCreator +;=============================================================================== +Func _IsWheelKeyScroll() + Local Const $WH_MOUSE_LL = 14 + + Local $hCallback_KeyHook = DllCallbackRegister('__WheelKeyScroll_Callback', 'int', 'int;ptr') + Local $hM_Module = DllCall('kernel32.dll', 'hwnd', 'GetModuleHandle', 'ptr', 0) + + Local $hM_Hook = DllCall('user32.dll', 'hwnd', 'SetWindowsHookEx', 'int', $WH_MOUSE_LL, _ + 'ptr', DllCallbackGetPtr($hCallback_KeyHook), 'hwnd', $hM_Module[0], 'dword', 0) + + Sleep(100) ;Wait some moments until the variable is set by callback function + + If IsPtr($hCallback_KeyHook) Then + DllCallbackFree($hCallback_KeyHook) + $hCallback_KeyHook = 0 + EndIf + + If IsArray($hM_Hook) And $hM_Hook[0] > 0 Then + DllCall('user32.dll', 'int', 'UnhookWindowsHookEx', 'hwnd', $hM_Hook[0]) + $hM_Hook[0] = 0 + EndIf + + If $IsWheelKeyScroll = True Then + $IsWheelKeyScroll = False + Return 1 + EndIf +EndFunc ;==>_IsWheelKeyScroll + +Func __WheelKeyScroll_Callback($nCode, $wParam) + Local Const $MOUSE_WheelSCROLL_EVENT = 522 + Local $iEvent = BitAND($wParam, 0xFFFF) + + $IsWheelKeyScroll = ($iEvent = $MOUSE_WheelSCROLL_EVENT) + + Return 0 +EndFunc ;==>__WheelKeyScroll_Callback + + +; #FUNCTION# =================================================================== +; Name : _IsTimeKeyPressed +; Description: Returns pressed time of specified key +; Parameter(s): $sHexKey= Hexadecimal key +; $format = format of return time 'ms' or 'sec' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns time +; On Failure - Returns -1 +; Author(s): FireFox +; Note(s): All other keys than other functions +;=============================================================================== +Func _IsTimeKeyPressed($sHexKey, $format = 'ms', $vDLL = 'user32.dll') + If _IsPressed($sHexKey) Then + $Init = TimerInit() + While _IsPressed($sHexKey) + $DiffKey = TimerDiff($Init) + WEnd + If $format = 'ms' Then Return $DiffKey + If $format = 'sec' Then Return ($DiffKey / 1000) + EndIf + Return -1 +EndFunc ;==>_IsTimeKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _IsSpecialKeyPressed +; Description: Returns 1 if anyspecial keys are pressed +; Parameter(s): $vDLL = 'user32.dll' +; Requirement(s): __KeyPressCheck +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): FireFox +; Note(s): All other keys than other functions +;=============================================================================== +Func _IsSpecialKeyPressed($vDLL = 'user32.dll') + If __KeyPressCheck(8, 36, -1, $vDLL) Then Return 1 + If __KeyPressCheck(41, 46, -1, $vDLL) Then Return 1 + If __KeyPressCheck(91, 92, -1, $vDLL) Then Return 1 + If __KeyPressCheck(106, 111, -1, $vDLL) Then Return 1 + If __KeyPressCheck(136, 221, -1, $vDLL) Then Return 1 + Return 0 +EndFunc ;==>_IsSpecialKeyPressed + + +; #FUNCTION# =================================================================== +; Name : _GetKeyByHex +; Description: Returns Alpha key for specified Hexadecimal key +; Parameter(s): $sHexKey = Hexadecimal key +; Requirement(s): __GetKeyType +; Return Value(s): On Success - Returns Aplha Key +; On Failure - Returns -1 +; Author(s): FireFox +; Note(s): None +;=============================================================================== +Func _GetKeyByHex($sHexKey) + Return __GetKeyType($sHexKey) +EndFunc ;==>_GetKeyByHex + + +; #FUNCTION# =================================================================== +; Name : _GetKeyByAlpha +; Description: Returns Hexadecimal key for specified Alpha key +; Parameter(s): $sAlphaKey = Alphabetic key +; Requirement(s): __GetKeyType +; Return Value(s): On Success - Returns Hexadecimal Key +; On Failure - Returns -1 +; Author(s): FireFox +; Note(s): Thanks to AlmarM for idea +;=============================================================================== +Func _GetKeyByAlpha($sAlphaKey) + Return __GetKeyType($sAlphaKey, 1) +EndFunc ;==>_GetKeyByAlpha + + +#Region Internal +; #FUNCTION# =================================================================== +; Name : OnAutoItExit +; Description: Close 'user32.dll' +;=============================================================================== +Func OnAutoItExit() + DllClose($hUser32) +EndFunc ;==>OnAutoItExit + + +; #FUNCTION# =================================================================== +; Name : __KeyPressCheck +; Description: Check if specified keys are pressed +; Parameter(s): sHexKey - Key to check for +; Requirement(s): None +; Return Value(s): On Success - Returns 1 +; On Failure - Returns 0 +; Author(s): Valuater +; Note(s): Thanks Valuater... 8) +;=============================================================================== +Func __KeyPressCheck($iStart, $iFinish, $iHexKey = -1, $vDLL = 'user32.dll') + Local $ikey, $ia_R + For $ikey = $iStart To $iFinish + If $iHexKey == -1 Then $ia_R = DllCall($vDLL, 'int', 'GetAsyncKeyState', 'int', '0x' & Hex($ikey, 2)) + If $iHexKey <> -1 Then $ia_R = DllCall($vDLL, 'int', 'GetAsyncKeyState', 'int', '0x' & $iHexKey) + If Not @error And BitAND($ia_R[0], 0x8000) = 0x8000 Then Return 1 + Next + Return 0 +EndFunc ;==>__KeyPressCheck + + +; #FUNCTION# =================================================================== +; Name : __GetKeyType +; Description: Returns Hexadecimal or Aplha key for specified key +; Parameter(s): $Type = 0 Return Alpha +; 1 Return Hexadecimal +; Requirement(s): None +; Return Value(s): On Success - Returns Key +; On Failure - Returns 0 +; Author(s): Valuater, FireFox +; Note(s): Thanks Valuater... 8) +;=============================================================================== +Func __GetKeyType($iKeyIn, $Type = 0) + If $iKeyIn = '' Then Return -1 + + Local $s_String = '01LeftMouse|02RightMouse|04MiddleMouse|05X1Mouse|06X2Mouse|08BACKSPACE|09TAB|0CCLEAR|' & _ + '0DENTER|10SHIFT|11CTRL|12ALT|13PAUSE|14CAPS LOCK|1BESC|20SPACEBAR|21PAGE UP|22PAGE DOWN|' & _ + '23END|24HOME|25LEFT|26UP|27RIGHT|28DOWN|29SELECT|2APRINT|2BEXECUTE|2CPRINT SCREEN|2DINS|2EDEL|' & _ + '300|311|322|333|344|355|366|377|388|399|41A|42B|43C|44D|45E|46F|47G|48H|49I|4AJ|4BK|4CL|4DM|4EN|' & _ + '4FO|50P|51Q|52R|53S|54T|55U|56V|57W|58X|59Y|5AZ|5BLeft Windows|5CRight Windows|60Num 0|61Num 1|' & _ + '62Num 2|63Num 3|64Num 4|65Num 5|66Num 6|67Num 7|68Num 8|69Num 9|6AMultiply|6BAdd|' & _ + '6CSeparator|6DSubtract|6EDecimal|6FDivide|70F1|71F2|72F3|73F4|74F5|75F6|76F7|77F8|78F9|' & _ + '79F10|7AF11|7BF12|7CF13|7DF14|7EF15|7FF16|80HF17|81HF18|82HF19|83HF20|84HF21|85HF22|' & _ + '86HF23|87HF24|90NUM LOCK|91SCROLL LOCK|A0Left SHIFT|A1Right SHIFT|A2Left CTRL|A3Right CTRL|' & _ + 'A4Left MENU|A5Right Menu|BA;|BB=|BC,|BD-|BE.|BF/|C0`|DB[|DC\|DD]' + + If $Type == 0 Then + $iKeyIn = StringTrimLeft($s_String, (StringInStr($s_String, $iKeyIn) + StringLen($iKeyIn) - 1)) + $s_String = StringLeft($iKeyIn, (StringInStr($iKeyIn, '|') - 1)) + ElseIf $Type == 1 Then + $iKeyIn = StringLeft($s_String, StringInStr($s_String, $iKeyIn) - 1) + $s_String = StringTrimLeft($iKeyIn, StringInStr($iKeyIn, '|', 2, -1)) + EndIf + If $s_String <> '' Then + Return $s_String + EndIf + Return -1 +EndFunc ;==>__GetKeyType +#EndRegion Internal diff --git a/source/Include/LoadSettings.au3 b/source/Include/LoadSettings.au3 new file mode 100644 index 0000000..c13ec10 --- /dev/null +++ b/source/Include/LoadSettings.au3 @@ -0,0 +1,316 @@ +#include-once +#include +#include +#include +#include ".\SimpleR_Constants.au3" + + +#Region Functions +Func GetGeneral($uselocal=1) + Local $array + Local $bFileExists = FileExists($pathGeneral) + If $bFileExists And $uselocal=1 Then + $array = _LoadFromCSV2D($pathGeneral) + Else + $array = DefaultGeneral() + _SaveToCSV($pathGeneral, $array) + EndIf + Return $array +EndFunc + +Func GetPaths($uselocal=1) + Local $array + Local $bFileExists = FileExists($pathPaths) + If $bFileExists Then + $array = _LoadFromCSV2D($pathPaths) + Else + $array = DefaultPaths() + _SaveToCSV($pathPaths, $array) + EndIf + + For $i = 0 to Ubound($array, 1) -1 + + $array[$i][1] = _PathConvert($array[$i][1]) + Next + Return $array +EndFunc + +Func GetMacros($uselocal=1) + Local $array + Local $bFileExists = FileExists($pathMacros) + If $bFileExists And $uselocal=1 Then + $array = _LoadFromCSV2D($pathMacros) + Else + $array = DefaultMacros() + _SaveToCSV($pathMacros, $array) + EndIf + Return $array +EndFunc + + + +Func GetIngame($uselocal=1) + Local $array + Local $bFileExists = FileExists($pathIngame) + If $bFileExists And $uselocal=1 Then + $array = _LoadFromCSV2D($pathIngame) + Else + $array = DefaultIngame() + _SaveToCSV($pathIngame, $array) + EndIf + Return $array +EndFunc + +Func GetHotkeys($uselocal=1) + Local $array + Local $bFileExists = FileExists($pathHotkeys) + If $bFileExists And $uselocal=1 Then + $array = _LoadFromCSV2D($pathHotkeys) + Else + $array = DefaultHotkeys() + _SaveToCSV($pathHotkeys, $array) + EndIf + Return $array +EndFunc + + + +#Region DefaultSettings +Func DefaultGeneral() + Local $SettingsGeneral[][] = [ _ + ["bTesting", "0"], _ + ["bAGCLoader", "0"], _ + ["bUseMacros", "1"], _ + ["bUseHotkeys", "1"], _ + ["bCustomCursor", "1"], _ + ["bKongregate", "0"], _ + ["bEnableScreenshots", "1"], _ + ["bCursorOnScreenshot", "1"], _ + ["bKeepWindowFocused", "0"], _ + ["bLaunchAdditionalProgram", "0"], _ + ["bEnableAnchor", "1"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["bReserved1", "reserved"], _ + ["sWindowName", "SimpleR Realm of the Mad God"], _ + ["sDefaultAnchor", "Kalle"], _ + ["sKongregateParameters", "?kongregate_username=USERNAME&kongregate_user_id=USERID&kongregate_game_auth_token=TOKEN&kongregate_api_path=PATH"], _ + ["sAdditionalProgramPath", "C:\temp"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"]] + Return $SettingsGeneral +EndFunc + +Func DefaultPaths() + Local $SettingsPaths[][] = [ _ + ["sFlashFile", "\data\flash.exe"], _ + ["sCustomCursorPath", "\data\Cursors\rotmg.cur"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"], _ + ["sReserved1", "reserved"]] + Return $SettingsPaths +EndFunc + +Func DefaultMacros() + Local $SettingsMacros[][] = [ _ + ["Macro1", "1", "F1", "He lives and reigns and conquers the world."], _ + ["Macro2", "1", "F2", "black"], _ + ["Macro3", "1", "F3", "/pause"], _ + ["Macro4", "1", "F4", "TRAAAAAAAAAAAAIIIIIIIIIIIIIIIINNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"], _ + ["MacroR", "0", "Key", "text"]] + Return $SettingsMacros +EndFunc + +Func DefaultIngame() + Local $SettingsIngame[][] = [ _ + ["Chat", "1", "ENTER"], _ + ["Ability", "1", "SPACEBAR"], _ + ["Command", "1", "/"], _ + ["Tell", "1", "TAB"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"], _ + ["reserved", "0", "Key"]] + + Return $SettingsIngame +EndFunc + +Func DefaultHotkeys() + Local $SettingsHotkeys[][] = [ _ + ["ResetSize", "1", "F6"], _ + ["43Maximize", "1", "F7"], _ + ["Screenshot", "1", "Print Screen"], _ + ["SetAnchor", "1", "F8"], _ + ["TPAnchor", "1", "F9"], _ + ["IgnorePM", "1", "F11"], _ + ["ToggleFocus", "0", "Num 9"], _ + ["ActualFullscreen", "0", "F12"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"], _ + ["HotkeyR", "0", "Key"]] + Return $SettingsHotkeys +EndFunc + + +#EndRegion + + +Func _PathConvert($path) + If StringInStr($path,":\")<>0 Then + ConsoleWrite ("Absolute path") + Else + $path = @ScriptDir & $path + EndIf + + Return $path +EndFunc + +Func _LoadFromCSV2D($csvSource) + Local $result + _FileReadToArray($csvSource, $result, 4, ";-") + + If @error Then + SetError(-1) + Return -1 + EndIf + + If IsArray($result) Then + Return $result + Else + SetError(-1) + Return -1 + EndIf +EndFunc + +Func _LoadFromCSV($csvSource) + Local $result + _FileReadToArray($csvSource, $result, $FRTA_NOCOUNT) + + If @error Then + SetError(-1) + Return -1 + EndIf + + If IsArray($result) Then + Return $result + Else + SetError(-1) + Return -1 + EndIf +EndFunc + +Func _SaveToCSV($csvSource, $array) + + _FileWriteFromArray($csvSource, $array, Default, Default , ";-") + + If @error Then + SetError(-1) + Return -1 + EndIf + + If IsArray($array) Then + Return $array + Else + SetError(-1) + Return -1 + EndIf + +EndFunc + +Func _ClearKeys($array, $type = 0) + For $i = Ubound($array, 1) -1 to 0 Step -1 + If ($array[$i][1]) = 1 Then + If $type = 0 Then + $array[$i][2]=_GetKeyByAlpha($array[$i][2]) + EndIf + + Else + _ArrayDelete($array, $i) + EndIf + Next + Return $array +EndFunc + +Func _Compare2DArrays($arrayOLD, $arrayNEW) + For $i = 0 To UBound($arrayOLD)-1 + + For $j = 0 To UBound($arrayOLD,2)-1 + If $arrayOLD[$i][$j] <> $arrayNEW[$i][$j] Then + Return 1 + EndIf + Next + Next + Return 0 +EndFunc + +Func _ConvertPath($path, $dir=@ScriptDir) + Local $length = StringLen($dir) + If (StringInStr($path, $dir)) Then + $path=StringTrimLeft($path,$length) + EndIf + Return $path +EndFunc + + +Func _ResetSettings() + Local $array = GetGeneral(0) + $array = GetPaths(0) + $array = GetMacros(0) + $array = GetIngame(0) + $array = GetHotkeys(0) +EndFunc + +#EndRegion + diff --git a/source/Include/MetroGUI_UDF.au3 b/source/Include/MetroGUI_UDF.au3 new file mode 100644 index 0000000..30b16aa --- /dev/null +++ b/source/Include/MetroGUI_UDF.au3 @@ -0,0 +1,3574 @@ +; #UDF# ======================================================================================================================= +; Name ..........: MetroGUI UDF +; Description ...: Create borderless GUIs with modern buttons, checkboxes, toggles, radios MsgBoxes and progressbars. +; Version .......: v5.1.0.0 +; Author ........: BB_19 +; =============================================================================================================================== + +#include-once +#include "MetroThemes.au3" +#include "MetroUDF-Required\StringSize.au3" +#include +#include +#include +#include +#include "MetroUDF-Required\SSCtrlHover.au3" + +_GDIPlus_Startup() +Opt("WinWaitDelay", 0) ;Required for faster WinActivate when using the fullscreen mode + +;Global Variables +Global $Font_DPI_Ratio = _GetFontDPI_Ratio()[2], $gDPI = _GDIPlus_GraphicsGetDPIRatio() +Global $iHoverReg[0], $iGUI_LIST[0] +Global $iMsgBoxTimeout = 0 ;internal msgbox counter +Global $GUI_TOP_MARGIN = Number(29 * $gDPI, 1) + Number(10 * $gDPI, 1) +Global Const $m_hDll = DllCallbackRegister('_iEffectControl', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') +Global Const $m_pDll = DllCallbackGetPtr($m_hDll) +OnAutoItExitRegister('_iMExit') +Global Const $bMarg = 4 * $gDPI ;Border margin + +;Options +Global $HIGHDPI_SUPPORT = False ;Enables HighDPI support +Global $ControlBtnsAutoMode = True ;Enables the automated fullscreen toggle on button click +Global $mOnEventMode = False + +;Check OnEventMode +If Opt("GUIOnEventMode", 0) Then + Opt("GUIOnEventMode", 1) + $mOnEventMode = True +EndIf + +#Region Metro Functions Overview +;========================================MAIN GUI================================================== +;_Metro_CreateGUI - Creates a borderless Metro-Style GUI +;_SetTheme - Sets the GUI color scheme from the included MetroThemes.au3 +;_Metro_AddControlButtons - Adds the selected control buttons to the gui. (Close,Maximize,Minimize,Fullscreen Toogle, Menu button) +;_Metro_GUIDelete - Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +;_Metro_EnableHighDPIScaling - Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp. +;_Metro_EnableOnEventMode - Allows using the MetroUDF with OnEventMode enabled +;_Metro_SetGUIOption - Allows to set different options like dragmove, resize and min. resize width/height. +;_Metro_FullscreenToggle - Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +;_Metro_AddControlButton_Back - Creates a back button on the left+top side of the gui. +;_Metro_MenuStart - Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +;_Metro_RightClickMenu - Shows/creates a rightclick menu window with the provided button names. + +;==========================================Buttons================================================= +;_Metro_CreateButton - Creates metro style buttons. Hovering creates a frame around the buttons. +;_Metro_CreateButtonEx - Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +;_Metro_CreateButtonEx2 - Creates a button with slightly rounded corners and no frame. Hovering changes the button color to a lighter color. +;_Metro_DisableButton - Disables a metro button and adds a grayed out look to it. +;_Metro_EnableButton - Enables a metro button and removes grayed out look of it. + +;==========================================Toggles================================================= +;_Metro_CreateToggle - Creates a Windows 10 style toggle with a text on the right side.(NEW Style) +;_Metro_CreateToggleEx - Creates a Windows 8 style toggle with a text on the right side. +;_Metro_ToggleIsChecked - Checks if a toggle is checked or not. Returns True or False. +;_Metro_ToggleCheck - Checks/Enables a toggle. +;_Metro_ToggleUnCheck - Unchecks/Disables a toggle. +;_Metro_ToggleSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;===========================================Radios================================================= +;_Metro_CreateRadio - Creates a metro style radio. +;_Metro_CreateRadioEx - Creates a metro style radio with colored checkmark. +;_Metro_RadioCheck - Checks the selected radio and unchecks all other radios in the selected group. +;_Metro_RadioIsChecked - Checks if the radio in a specific group is selected. + +;==========================================Checkboxes============================================== +;_Metro_CreateCheckbox - Creates a modern looking checkbox. +;_Metro_CreateCheckboxEx - Creates a classic-style checkbox with the default black white colors. +;_Metro_CreateCheckboxEx2 - Creates a modern rounded checkbox. +;_Metro_CheckboxIsChecked - Checks if a checkbox is checked. Returns True or False. +;_Metro_CheckboxCheck - Checks a checkbox. +;_Metro_CheckboxUncheck - Unchecks a checkbox. +; Metro_CheckboxSwitch - Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks + +;=============================================MsgBox=============================================== +;_Metro_MsgBox - Creates a MsgBox with a OK button and displays the text. _GUIDisable($GUI, 0, 30) should be used before, so the MsgBox is better visible and afterwards _GUIDisable($GUI). + +;=============================================Progress============================================= +;_Metro_CreateProgress - Creates a simple progressbar. +;_Metro_SetProgress - Sets the progress in % of a progressbar. + +;=============================================Other============================================= +; _Metro_InputBox - Creates a simple modern input box +; _Metro_AddHSeperator - Adds a horizontal seperator line to the GUI +; _Metro_AddVSeperator - Adds a vertical seperator line to the GUI + +#EndRegion Metro Functions Overview + + +#Region MetroGUI=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateGUI +; Description ...: Creates a modern borderless GUI with the colors of the selected theme. +; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $AllowResize = False[, $ParentGUI = ""]]]]) +; Parameters ....: $Title - Title of the window +; $Width - Width +; $Height - Height +; $Left - [optional] Window pos X. Default is -1. +; $Top - [optional] Window pos Y. Default is -1. +; $AllowResize - [optional] True/False. Default is False. ;Enables resizing + drag move for the gui. +; $ParentGUI - [optional] Handle to the parent gui. Default is "". +; Return values .: Handle to the created gui +; Example .......: _Metro_CreateGUI("Example", 500, 300, -1, -1, True) +; =============================================================================================================================== +Func _Metro_CreateGUI($Title, $Width, $Height, $Left = -1, $Top = -1, $AllowResize = False, $ParentGUI = "") + Local $GUI_Return + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + Local $gID + If $AllowResize Then + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Else + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme + $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI) + $gID = _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + EndIf + _WinAPI_SetWindowSubclass($GUI_Return, $m_pDll, 1010, $gID) + WinMove($GUI_Return, "", Default, Default, $Width, $Height) + + + If Not $ParentGUI Then + Local $Center_GUI = _GetDesktopWorkArea($GUI_Return) + If ($Left = -1) And ($Top = -1) Then + WinMove($GUI_Return, "", ($Center_GUI[2] - $Width) / 2, ($Center_GUI[3] - $Height) / 2, $Width, $Height) + EndIf + Else + If ($Left = -1) And ($Top = -1) Then + Local $GUI_NewPos = _WinPos($ParentGUI, $Width, $Height) + WinMove($GUI_Return, "", $GUI_NewPos[0], $GUI_NewPos[1], $Width, $Height) + EndIf + EndIf + + GUISetBkColor($GUIThemeColor) + + _CreateBorder($GUI_Return, $Width, $Height, $GUIBorderColor) + + Return ($GUI_Return) +EndFunc ;==>_Metro_CreateGUI + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetGUIOption +; Description ...: Allows to set different options like dragmove, resize and min. resize width/height. +; Syntax ........: _Metro_SetGUIOption($mGUI[, $AllowDragMove = False[, $AllowResize = False[, $Win_MinWidth = ""[, +; $Win_MinHeight = ""]]]]) +; Parameters ....: $mGUI - a map. +; $AllowDragMove - [optional] Allow dragmove (Moving GUI by holding leftclick). Default is False. +; $AllowResize - [optional] Allow resizing of the GUI. Default is False. +; $Win_MinWidth - [optional] Min. width of the GUI in px (For resizing). Default is "". +; $Win_MinHeight - [optional] Min. height of the GUI in px(For resizing). Default is "". +; Example .......: _Metro_SetGUIOption($Form1, True, True, 400, 300) +; =============================================================================================================================== +Func _Metro_SetGUIOption($mGUI, $AllowDragMove = False, $AllowResize = False, $Win_MinWidth = "", $Win_MinHeight = "") + Local $iGui_Count + ;Check if Gui is already registered + For $iGUIs = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$iGUIs][0] = $mGUI Then + $iGui_Count = $iGUIs + ExitLoop + EndIf + Next + + If ($iGui_Count == "") Then + $iGui_Count = UBound($iGUI_LIST) + ReDim $iGUI_LIST[$iGui_Count + 1][16] + EndIf + + $iGUI_LIST[$iGui_Count][0] = $mGUI + $iGUI_LIST[$iGui_Count][1] = $AllowDragMove ;Drag + $iGUI_LIST[$iGui_Count][2] = $AllowResize ;Resize + + If $AllowResize Then + If $Win_MinWidth = "" Then + $Win_MinWidth = WinGetPos($mGUI, "") + If @error Then + $Win_MinWidth = 80 * $gDPI + Else + $Win_MinWidth = $Win_MinWidth[2] + EndIf + EndIf + If $Win_MinHeight = "" Then + $Win_MinHeight = WinGetPos($mGUI, "") + If @error Then + $Win_MinHeight = 50 * $gDPI + Else + $Win_MinHeight = $Win_MinHeight[3] + EndIf + EndIf + $iGUI_LIST[$iGui_Count][3] = $Win_MinWidth ;Set Min Width of the Window + $iGUI_LIST[$iGui_Count][4] = $Win_MinHeight ;Set Min Height of the Window + EndIf + + Return $iGui_Count +EndFunc ;==>_Metro_SetGUIOption + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_GUIDelete +; Description ...: Destroys all created metro buttons,checkboxes,radios etc., deletes the GUI and reduces memory usage. +; Syntax ........: _Metro_GUIDelete($GUI) +; Parameters ....: $GUI - Handle to the gui to be deleted +; =============================================================================================================================== +Func _Metro_GUIDelete($GUI) + GUISetState(@SW_HIDE, $GUI) ;To prevent visible delay when the gui is being deleted + _WinAPI_RemoveWindowSubclass($GUI, $m_pDll, 1010) + GUIDelete($GUI) + + ;Remove from Global GUI List + Local $CLEANED_GUI_LIST[0] + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + If $iGUI_LIST[$i_HR][0] <> $GUI Then + ReDim $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) + 1][16] + For $i_Hx = 0 To 11 Step +1 + $CLEANED_GUI_LIST[UBound($CLEANED_GUI_LIST) - 1][$i_Hx] = $iGUI_LIST[$i_HR][$i_Hx] + Next + EndIf + Next + $iGUI_LIST = $CLEANED_GUI_LIST + +;~ _ReduceMemory() +EndFunc ;==>_Metro_GUIDelete + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iControlDelete +; Description ...: Internal function that will free resources and remove the control from the Hover REG +; Syntax ........: _iControlDelete($hControl) +; Parameters ....: $hControl - a handle value. +; =============================================================================================================================== +Func _iControlDelete($hControl) + + For $i = 0 To UBound($iHoverReg) - 1 + If $iHoverReg[$i][0] = $hControl Then + Switch ($iHoverReg[$i][3]) + Case "5", "7" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + Case "6" + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + _WinAPI_DeleteObject($iHoverReg[$i][7]) + _WinAPI_DeleteObject($iHoverReg[$i][8]) + _WinAPI_DeleteObject($iHoverReg[$i][9]) + _WinAPI_DeleteObject($iHoverReg[$i][10]) + _WinAPI_DeleteObject($iHoverReg[$i][11]) + _WinAPI_DeleteObject($iHoverReg[$i][12]) + _WinAPI_DeleteObject($iHoverReg[$i][13]) + _WinAPI_DeleteObject($iHoverReg[$i][14]) + Case Else + _WinAPI_DeleteObject($iHoverReg[$i][5]) + _WinAPI_DeleteObject($iHoverReg[$i][6]) + EndSwitch + ;Empty array index + For $i2 = 0 To UBound($iHoverReg, 2) - 1 + $iHoverReg[$i][$i2] = "" + Next + ExitLoop + EndIf + Next +EndFunc ;==>_iControlDelete + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButtons +; Description ...: Creates the selected control buttons for a metro style gui. +; Syntax ........: _Metro_AddControlButtons([$CloseBtn = True[, $MaximizeBtn = True[, $MinimizeBtn = True[, $FullScreenBtn = True[, +; $MenuBtn = False]]]]]) +; Parameters ....: $CloseBtn - [optional] True/False. Default is True. ;Adds a close button +; $MaximizeBtn - [optional] True/False. Default is True. ;Adds a maximize/restore button +; $MinimizeBtn - [optional] True/False. Default is True. ;Adds a minimize button +; $FullScreenBtn - [optional] True/False. Default is True. ;Adds a fullscreen toggle button +; $MenuBtn - [optional] True/False. Default is False.;Adds a Menu Button that can be used with _Metro_MenuStart + +; $GUI_BG_Color - [optional] Custom color for the background of the buttons. Example: "0x000000", Default is $GUIThemeColor of the selected theme +; $GUI_Font_Color - [optional] Custom color for the text color of the buttons. Example: "0xFFFFFF", Default is $FontThemeColor of the selected theme +; Return values .: Array with size 7 that contains all handles of the created control buttons. Note: Array size is always the same and so is the order of the handles even if not all buttons are created. See below: +; Array[0] = Close button +; Array[1] = Maximize button +; Array[2] = Restore button +; Array[3] = Minimize button +; Array[4] = Fullscreen ON button +; Array[5] = Fullscreen OFF button +; Array[6] = Menu button +; Example .......: _Metro_AddControlButtons(True, True, True, True, True) +; =============================================================================================================================== +Func _Metro_AddControlButtons($CloseBtn = True, $MaximizeBtn = True, $MinimizeBtn = True, $FullScreenBtn = False, $MenuBtn = False, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $ButtonsToCreate_Array[5] + $ButtonsToCreate_Array[0] = $CloseBtn + $ButtonsToCreate_Array[1] = $MaximizeBtn + $ButtonsToCreate_Array[2] = $MinimizeBtn + $ButtonsToCreate_Array[3] = $FullScreenBtn + $ButtonsToCreate_Array[4] = $MenuBtn + + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + + Return _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color, $GUI_Font_Color, False, $tMargin) +EndFunc ;==>_Metro_AddControlButtons + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableHighDPIScaling +; Description ...: Enables high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp +; Syntax ........: _Metro_EnableHighDPIScaling() +; =============================================================================================================================== +Func _Metro_EnableHighDPIScaling($Enable = True) + $HIGHDPI_SUPPORT = $Enable +EndFunc ;==>_Metro_EnableHighDPIScaling + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableOnEventMode +; Description ...: Allows using the UDF with OnEventMode enabled. +; Syntax ........: _Metro_EnableOnEventMode([$Enable = True]) +; =============================================================================================================================== +Func _Metro_EnableOnEventMode($Enable = True) + $mOnEventMode = $Enable +EndFunc ;==>_Metro_EnableOnEventMode + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_FullscreenToggle +; Description ...: Toggles between fullscreen and normal window. NOTE: $AllowResize has to be set True when creating a gui and this also requires the creation of a fullscreen control button. +; Syntax ........: _Metro_FullscreenToggle($mGUI, $Control_Buttons_Array) +; Parameters ....: $mGUI - Handle to the GUI. +; $Control_Buttons_Array - Array containing the control button handles as returned from _Metro_AddControlButtons. +; Note2 .........: Fullscreen toggle only works with ONE gui at the same time. You can't create 2 Guis which are toggled to fullscreen at the same time. They will interfere with each other. +; =============================================================================================================================== +Func _Metro_FullscreenToggle($mGUI) + GUISetState(@SW_SHOW, $mGUI) ;Fixes a bug that occurs when using multiple child windows + Local $iGui_Count = _iGetGUIID($mGUI) + + If ($iGui_Count == "") Then + ConsoleWrite("Fullscreen-Toggle failed: GUI not registered. Not created with _Metro_CreateGUI ?" & @CRLF) + Return SetError(1) ; + EndIf + If Not $iGUI_LIST[$iGui_Count][2] Then + ConsoleWrite("Fullscreen-Toggle failed: GUI is not registered for resizing. Please use _Metro_SetGUIOption to enable resizing." & @CRLF) + Return SetError(2) ; + EndIf + + Local $mWin_State = WinGetState($mGUI) + Local $tRET = _WinAPI_GetWindowPlacement($mGUI) + Local $FullScreenPOS = _GetDesktopWorkArea($mGUI, True) + Local $CurrentPos = WinGetPos($mGUI) + + Local $MaxBtn = _iGetCtrlHandlebyType("3", $mGUI) + Local $RestoreBtn = _iGetCtrlHandlebyType("4", $mGUI) + Local $FullScreenBtn = _iGetCtrlHandlebyType("9", $mGUI) + Local $FullscreenRsBtn = _iGetCtrlHandlebyType("10", $mGUI) + + + If $iGUI_LIST[$iGui_Count][11] Then ;Already in fullscreen -> Restore + $iGUI_LIST[$iGui_Count][11] = False ;Remove fullscreen state + If (BitAND($iGUI_LIST[$iGui_Count][9], 32) = 32) Then ; If previous state was maximized + GUISetState(@SW_MAXIMIZE) + $tRET = $iGUI_LIST[$iGui_Count][10] + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][5], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][6], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][7], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $iGUI_LIST[$iGui_Count][8], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 16) + EndIf + Else + WinMove($mGUI, "", $iGUI_LIST[$iGui_Count][5], $iGUI_LIST[$iGui_Count][6], $iGUI_LIST[$iGui_Count][7], $iGUI_LIST[$iGui_Count][8]) + If $MaxBtn Then + GUICtrlSetState($RestoreBtn, 32) + GUICtrlSetState($MaxBtn, 16) + EndIf + EndIf + + GUICtrlSetState($FullscreenRsBtn, 32) + GUICtrlSetState($FullScreenBtn, 16) + + Else ;Not in fullscreen mode -> Enter fullscreen mode + + If (BitAND($mWin_State, 32) = 32) Then ; If window is maximized + ;Replace array with current window position with the currently saved restore/normal position + $CurrentPos[0] = DllStructGetData($tRET, "rcNormalPosition", 1) + $CurrentPos[1] = DllStructGetData($tRET, "rcNormalPosition", 2) + $CurrentPos[2] = DllStructGetData($tRET, "rcNormalPosition", 3) + $CurrentPos[3] = DllStructGetData($tRET, "rcNormalPosition", 4) + + ;Set new fullscreen position + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0], 1) ; left + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1], 2) ; top + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[0] + $FullScreenPOS[2], 3) ; right + DllStructSetData($tRET, "rcNormalPosition", $FullScreenPOS[1] + $FullScreenPOS[3], 4) ; bottom + _WinAPI_SetWindowPlacement($mGUI, $tRET) + Sleep(50) + $iGUI_LIST[$iGui_Count][10] = $tRET + GUISetState(@SW_RESTORE) + Else + Sleep(50) + WinMove($mGUI, "", $FullScreenPOS[0], $FullScreenPOS[1], $FullScreenPOS[2], $FullScreenPOS[3]) + EndIf + $iGUI_LIST[$iGui_Count][11] = True ;Fullscreen state + GUICtrlSetState($FullScreenBtn, 32) + If $MaxBtn Then + GUICtrlSetState($MaxBtn, 32) + GUICtrlSetState($RestoreBtn, 32) + EndIf + GUICtrlSetState($FullscreenRsBtn, 16) + $iGUI_LIST[$iGui_Count][5] = $CurrentPos[0] + $iGUI_LIST[$iGui_Count][6] = $CurrentPos[1] + $iGUI_LIST[$iGui_Count][7] = $CurrentPos[2] + $iGUI_LIST[$iGui_Count][8] = $CurrentPos[3] + $iGUI_LIST[$iGui_Count][9] = $mWin_State + ;Workaround for the Windows 10 bug(or feature as MS would call it) that causes the taskbar to be on top of the GUI even when it is in fullscreen mode (Thx @MS for breaking stuff with every update) + WinActivate("[CLASS:Shell_TrayWnd]") + WinActivate($mGUI) + + EndIf +EndFunc ;==>_Metro_FullscreenToggle + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddControlButton_Back +; Description ...: Creates a back button on the left+top side of the gui. +; Syntax ........: _Metro_AddControlButton_Back([, $GUI_BG_Color = $GUIThemeColor[, $GUI_Font_Color = $FontThemeColor]]) +; Parameters ....: $GUI_BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $GUI_Font_Color - [optional] Text color. Default is $FontThemeColor. +; Return values .: Handle to the button +; Remarks .......: If a menu control button is visible, then it has to be hidden first before showing this button, as they are on the same position. +; Example .......: _Metro_AddControlButton_Back() +; =============================================================================================================================== +Func _Metro_AddControlButton_Back($GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = $FontThemeColor, $tMargin = 2) + Local $cbDPI = _HighDPICheck() + Local $CurrentGUI = GetCurrentGUI() + + ;Set Colors + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + $GUI_Font_Color = "0xFF" & Hex($GUI_Font_Color, 6) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + Local $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + + Local $FrameSize = Round(1 * $cbDPI) + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +60), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + Else + Local $hPen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), Round(1 * $cbDPI)) ;inactive + EndIf + _GDIPlus_PenSetStartCap($hPen, 0x03) + _GDIPlus_PenSetStartCap($hPen1, 0x03) + ;Create Button Array + Local $Control_Button_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + + ;Create GuiPics and set hover states + + $Control_Button_Array[1] = False ; Hover state + $Control_Button_Array[2] = False ; Set inactive state + $Control_Button_Array[3] = "0" ; Type + $Control_Button_Array[15] = GetCurrentGUI() + + ;Create Graphics + Local $Control_Button_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Control_Button_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4) + Local $Control_Button_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + + ;Create Back Button + + ;Calc size+pos + Local $mpX = $CBw / 2.95, $mpY = $CBh / 2.1 + Local $apos1 = cAngle($mpX, $mpY, 135, 12 * $cbDPI) + Local $apos2 = cAngle($mpX, $mpY, 45, 12 * $cbDPI) + + ;Add arrow + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic1[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic2[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen) ;l + + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos1[0], $apos1[1], $hPen1) ;r + _GDIPlus_GraphicsDrawLine($Control_Button_Graphic3[0], $mpX, $mpY, $apos2[0], $apos2[1], $hPen1) ;l + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen1) + + ;Create bitmap handles and set graphic + $Control_Button_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Control_Button_Array[5] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic1) + $Control_Button_Array[6] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic2, False) + $Control_Button_Array[7] = _iGraphicCreateBitmapHandle($Control_Button_Array[0], $Control_Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Control_Button_Array[0], 768 + 32 + 2) + + _cHvr_Register($Control_Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Control_Button_Array), $CurrentGUI) + Return $Control_Button_Array[0] +EndFunc ;==>_Metro_AddControlButton_Back + + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MenuStart +; Description ...: Shows/creates a menu window that slides in from the right side of the gui. (Similar to Android menus or Windows 10 calculator app) +; Syntax ........: _Metro_MenuStart($mGUI, $Metro_MenuBtn, $mWidth, $ButtonsArray) +; Parameters ....: $mGUI - Handle to the gui. +; $Metro_MenuBtn - Handle to the menu button that is returned by _Metro_AddControlButtons. (this would be $Array[6] returned by _Metro_AddControlButtons function) +; $mWidth - Width of the Menu +; $ButtonsArray - An array containing button names to be created. +; Example: Local $MenuButtonsArray[4] = ["Settings","About","Contact","Exit"] ; id 0 = Settings, 1 = About, 2 = Contact, 3 = Exit +; $bFont - [optional] Custom font for the buttons. Default "Arial" +; $bFontSize - [optional] Custom font size for the buttons. Default 9 +; $bFontStyle - [optional] Custom font style for the buttons. Default 1 +; Return values .: index of the clicked button from $ButtonsArray or @error and value "none" if nothing is clicked. Example: Users selects "Exit" button in the menu, so this function would return "3". +; =============================================================================================================================== +Func _Metro_MenuStart($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $Metro_MenuBtn = _iGetCtrlHandlebyType("8", $mGUI) + If Not $Metro_MenuBtn Then Return SetError(1) + GUICtrlSetState($Metro_MenuBtn, 128) + + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + + Local $blockclose = True + Local $mPos = WinGetPos($mGUI) + Local $cMarginR = Number(2 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $mGuiHeight = $mPos[3] - ($cMarginR * 2) - $CBh + Local $mGuiWidth = $mWidth * $cbDPI + Local $mGuiX = $mPos[0] + $cMarginR, $mGuiY = $mPos[1] + $cMarginR + $CBh + Local $AnimStep = $mGuiWidth / 10, $mGuiWidthAnim = $AnimStep + Local $MenuForm = GUICreate("", $mGuiWidthAnim, $mGuiHeight, $mGuiX, $mGuiY, $WS_POPUP, $WS_EX_MDICHILD, $mGUI) + Local $ButtonStep = (30 * $cbDPI) + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], 0, $ButtonStep * $iB + ($iB * 2), $mGuiWidth - $cMarginR, 30 * $cbDPI, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + + GUISetState(@SW_SHOW, $MenuForm) + + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim + $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If Not $blockclose Then + If Not WinActive($MenuForm) Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $i = 0 To 8 Step +1 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return SetError(1, 0, "none") + EndIf + Else + $blockclose = False + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + $mPos = WinGetPos($mGUI) + $mGuiX = $mPos[0] + $cMarginR + $mGuiY = $mPos[1] + $cMarginR + $CBh + For $if = 0 To 8 Step +2 + $mGuiWidthAnim = $mGuiWidthAnim - $AnimStep + WinMove($MenuForm, "", $mGuiX, $mGuiY, $mGuiWidthAnim, $mGuiHeight) + Sleep(1) + Next + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + GUICtrlSetState($Metro_MenuBtn, 64) + Return $iB + EndIf + Next + WEnd + +EndFunc ;==>_Metro_MenuStart + + +Func _iCreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1) + Local $Button_Array[16] + + If Not $HIGHDPI_SUPPORT Then + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Set Colors + $BG_Color = StringReplace($BG_Color, "0x", "0xFF") + $Font_Color = StringReplace($Font_Color, "0x", "0xFF") + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, -12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, -25), "0x", "0xFF") + Else + Local $BG_ColorD = StringReplace(_AlterBrightness($GUIThemeColor, +12), "0x", "0xFF") + $BG_Color = StringReplace(_AlterBrightness($GUIThemeColor, +25), "0x", "0xFF") + EndIf + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_ColorD, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 802) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] +EndFunc ;==>_iCreateMButton + + + +Func _Metro_RightClickMenu($mGUI, $mWidth, $ButtonsArray, $bFont = "Segoe UI", $bFontSize = 9, $bFontStyle = 0) + Local $mPos = MouseGetPos() + Local $iButtonsArray[UBound($ButtonsArray)] + Local $cbDPI = _HighDPICheck() + Local $ButtonStep = (25 * $cbDPI) + Local $cMarginR = Number(2 * $cbDPI, 1) + + Local $DesktopSize = _GetDesktopWorkArea($mGUI, False) + If @error Then Return + ;Fix position if it is offscreen + Local $mHeight = UBound($ButtonsArray) * $ButtonStep + (2 * UBound($ButtonsArray)) + If $mPos[0] + $mWidth > $DesktopSize[2] Then + $mPos[0] = $mPos[0] - ($mPos[0] + $mWidth - $DesktopSize[2] + 2) + EndIf + If $mPos[1] + $mHeight > $DesktopSize[3] Then + $mPos[1] = $mPos[1] - ($mPos[1] + $mHeight - $DesktopSize[3] + 2) + EndIf + Local $MenuForm = GUICreate("", $mWidth, $mHeight, $mPos[0], $mPos[1], $WS_POPUP, 0, $mGUI) + + If StringInStr($GUI_Theme_Name, "Light") Then + GUISetBkColor(_AlterBrightness($GUIThemeColor, -10), $MenuForm) + Else + GUISetBkColor(_AlterBrightness($GUIThemeColor, +10), $MenuForm) + EndIf + For $iB = 0 To UBound($ButtonsArray) - 1 Step +1 + $iButtonsArray[$iB] = _iCreateMButton($ButtonsArray[$iB], $cMarginR / 2, $ButtonStep * $iB + ($iB * 2), $mWidth - $cMarginR, $ButtonStep, $GUIThemeColor, $FontThemeColor, $bFont, $bFontSize, $bFontStyle) + Next + GUISetState(@SW_SHOW, $MenuForm) + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily disable oneventmode + + While 1 + If Not WinActive($MenuForm) Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return SetError(1, 0, "none") + EndIf + Local $imsg = GUIGetMsg() + For $iB = 0 To UBound($iButtonsArray) - 1 Step +1 + If $imsg = $iButtonsArray[$iB] Then + GUIDelete($MenuForm) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;reactivate oneventmode + Return $iB + EndIf + Next + WEnd +EndFunc ;==>_Metro_RightClickMenu + + + + + + +Func _iCreateControlButtons($ButtonsToCreate_Array, $GUI_BG_Color = $GUIThemeColor, $GUI_Font_Color = "0xFFFFFF", $CloseButtonOnStyle = False, $tMargin = 2) + ;HighDPI Support + Local $cbDPI = _HighDPICheck() + + ;Set Colors + ;========================================================================= + Local $FrameSize = Round(1 * $cbDPI), $Hover_BK_Color + + If StringInStr($GUI_Theme_Name, "Light") Then + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, -20), "0x", "0xFF") + Else + $Hover_BK_Color = StringReplace(_AlterBrightness($GUI_BG_Color, +20), "0x", "0xFF") + EndIf + Local $hPen = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen2 = _GDIPlus_PenCreate($GUI_Font_Color, Round(1 * $cbDPI)) + Local $hPen3 = _GDIPlus_PenCreate("0xFFFFFFFF", Round(1 * $cbDPI)) + If StringInStr($GUI_Theme_Name, "Light") Then + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, +90), "0x", "0xFF"), $FrameSize) ;inactive + Else + Local $hPen4 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUI_Font_Color, -80), "0x", "0xFF"), $FrameSize) ;inactive + EndIf + Local $hPen5 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness("0xFFFFFF", -80), "0x", "0xFF"), $FrameSize) ;inactive style 2 + + If $GUI_BG_Color <> 0 Then + $GUI_BG_Color = "0xFF" & Hex($GUI_BG_Color, 6) + EndIf + Local $hBrush = _GDIPlus_BrushCreateSolid($GUI_BG_Color), $hBrush2 = _GDIPlus_BrushCreateSolid($Hover_BK_Color) + + ;========================================================================= + + ;Create Button Arrays + Local $Control_Buttons[16] + Local $Button_Close_Array[16] + Local $Button_Minimize_Array[16] + Local $Button_Maximize_Array[16] + Local $Button_Restore_Array[16] + Local $Button_Menu_Array[16] + Local $Button_FullScreen_Array[16] + Local $Button_FSRestore_Array[16] + + ;Calc Sizes + Local $CBw = Number(45 * $cbDPI, 1) + Local $CBh = Number(29 * $cbDPI, 1) + Local $cMarginR = Number($tMargin * $cbDPI, 1) + Local $CurrentGUI = GetCurrentGUI() + + Local $Win_POS = WinGetPos($CurrentGUI) + Local $PosCount = 0 + + ;Create GuiPics and set hover states + If $ButtonsToCreate_Array[0] Then + $PosCount = $PosCount + 1 + $Button_Close_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Close_Array[1] = False ; Hover state + $Button_Close_Array[2] = False ; Inactive Color state + $Button_Close_Array[3] = "0" ; Type + $Button_Close_Array[15] = $CurrentGUI + EndIf + + + + If $ButtonsToCreate_Array[1] Then + $PosCount = $PosCount + 1 + $Button_Maximize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Maximize_Array[1] = False + $Button_Maximize_Array[2] = False ; Inactive Color state + $Button_Maximize_Array[3] = "3" + $Button_Maximize_Array[8] = True ;Visible state + $Button_Maximize_Array[15] = $CurrentGUI + + $Button_Restore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Restore_Array[1] = False + $Button_Restore_Array[2] = False ;Inactive Color state + $Button_Restore_Array[3] = "4" + $Button_Restore_Array[8] = True ;Visible state + $Button_Restore_Array[15] = $CurrentGUI + If $ButtonsToCreate_Array[3] Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[2] Then + $PosCount = $PosCount + 1 + $Button_Minimize_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_Minimize_Array[1] = False + $Button_Minimize_Array[2] = False ; Inactive Color state + $Button_Minimize_Array[3] = "0" + $Button_Minimize_Array[15] = $CurrentGUI + EndIf + + If $ButtonsToCreate_Array[3] Then + $PosCount = $PosCount + 1 + $Button_FullScreen_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FullScreen_Array[1] = False + $Button_FullScreen_Array[2] = False ; Inactive Color state + $Button_FullScreen_Array[3] = "9" + $Button_FullScreen_Array[15] = $CurrentGUI + + If $Button_FSRestore_Array[15] <> $CurrentGUI Then + $Button_FSRestore_Array[0] = GUICtrlCreatePic("", $Win_POS[2] - $cMarginR - ($CBw * $PosCount), $cMarginR, $CBw, $CBh) + $Button_FSRestore_Array[1] = False + $Button_FSRestore_Array[2] = False ; Inactive Color state + $Button_FSRestore_Array[3] = "10" + $Button_FSRestore_Array[15] = $CurrentGUI + EndIf + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[0] = GUICtrlCreatePic("", $cMarginR, $cMarginR, $CBw, $CBh) + $Button_Menu_Array[1] = False + $Button_Menu_Array[2] = False ; Inactive Color state + $Button_Menu_Array[3] = "8" + $Button_Menu_Array[15] = $CurrentGUI + EndIf + + ;Create Graphics + If $ButtonsToCreate_Array[0] Then + Local $Button_Close_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4), $Button_Close_Graphic2 = _iGraphicCreate($CBw, $CBh, "0xFFE81123", 4, 4), $Button_Close_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 4, 4) + EndIf + If $ButtonsToCreate_Array[1] Then + Local $Button_Maximize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Maximize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Maximize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_Restore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Restore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Restore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[2] Then + Local $Button_Minimize_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Minimize_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Minimize_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[3] Then + Local $Button_FullScreen_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FullScreen_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FullScreen_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + Local $Button_FSRestore_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_FSRestore_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_FSRestore_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + If $ButtonsToCreate_Array[4] Then + Local $Button_Menu_Graphic1 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4), $Button_Menu_Graphic2 = _iGraphicCreate($CBw, $CBh, $Hover_BK_Color, 0, 4), $Button_Menu_Graphic3 = _iGraphicCreate($CBw, $CBh, $GUI_BG_Color, 0, 4) + EndIf + + ;Set close button BG color style + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsClear($Button_Close_Graphic1[0], "0xFFB52231") ; + _GDIPlus_GraphicsClear($Button_Close_Graphic3[0], "0xFFB52231") ; + EndIf + + ;Create Close Button========================================================================================================== + If $ButtonsToCreate_Array[0] Then + If $CloseButtonOnStyle Then + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) + Else + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) + EndIf + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) + _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) + EndIf + ;============================================================================================================================= + + ;Create Maximize & Restore Button============================================================================================= + If $ButtonsToCreate_Array[1] Then + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic1[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic2[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawRect($Button_Maximize_Graphic3[0], Round(17 * $cbDPI), 9 * $cbDPI, 9 * $cbDPI, 9 * $cbDPI, $hPen4) + + Local $kWH = Round(7 * $cbDPI), $resmargin = Round(2 * $cbDPI) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic1[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen2) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush2) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic2[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen2) + + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI) + $resmargin, (11 * $cbDPI) - $resmargin, $kWH, $kWH, $hPen4) + _GDIPlus_GraphicsFillRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hBrush) + _GDIPlus_GraphicsDrawRect($Button_Restore_Graphic3[0], Round(17 * $cbDPI), 11 * $cbDPI, $kWH, $kWH, $hPen4) + EndIf + ;============================================================================================================================= + + + ;Create Minimize Button======================================================================================================= + If $ButtonsToCreate_Array[2] Then + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic1[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic2[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen2) + _GDIPlus_GraphicsDrawLine($Button_Minimize_Graphic3[0], 18 * $cbDPI, 14 * $cbDPI, 27 * $cbDPI, 14 * $cbDPI, $hPen4) + EndIf + ;============================================================================================================================= + + ;Create FullScreen / Fullscreen Restore Button================================================================================ + If $ButtonsToCreate_Array[3] Then + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.3) + Local $LowerLinePos[2], $UpperLinePos + $LowerLinePos[0] = Round($CBw / 2.9) + $LowerLinePos[1] = Round($CBh / 1.5) + $UpperLinePos = cAngle($LowerLinePos[0], $LowerLinePos[1], 135, $CBw / 2.5) + $UpperLinePos[0] = Round($UpperLinePos[0]) + $UpperLinePos[1] = Round($UpperLinePos[1]) + + ;Add arrow1 + Local $apos1 = cAngle($LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, 180, 5 * $cbDPI) + Local $apos2 = cAngle($LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, 90, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] - $Cutpoint, $LowerLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + + ;Add arrow2 + $apos1 = cAngle($UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, 270, 5 * $cbDPI) + $apos2 = cAngle($UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, 0, 5 * $cbDPI) + + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen) ;l + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] + $Cutpoint, $UpperLinePos[1] + $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $UpperLinePos[0] - $Cutpoint, $UpperLinePos[1] - $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;l + + ;Add line + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic1[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic2[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_FullScreen_Graphic3[0], $LowerLinePos[0] + $Cutpoint, $LowerLinePos[1] - $Cutpoint, $UpperLinePos[0], $UpperLinePos[1], $hPen4) ;r + + + ;============================================================================================================================= + + + ;Calc size+pos arrow 1 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX = Round($CBw / 2, 0), $mpY = Round($CBh / 2.35, 0) + $apos1 = cAngle($mpX - $Cutpoint, $mpY - $Cutpoint, 90, 4 * $cbDPI) + $apos2 = cAngle($mpX + $Cutpoint, $mpY + $Cutpoint, 180, 4 * $cbDPI) + Local $apos4 = cAngle($mpX + $Cutpoint, $mpY - $Cutpoint, 135, 8 * $cbDPI) + + ;Add arrow1 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX - $Cutpoint, $mpY - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;h + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;v + + ;Calc size+pos arrow2 + $Cutpoint = ($FrameSize * 0.3) + Local $mpX1 = Round($CBw / 2.2, 0), $mpY1 = Round($CBh / 2, 0) + $apos1 = cAngle($mpX1 - $Cutpoint, $mpY1 - $Cutpoint, 360, 4 * $cbDPI) + $apos2 = cAngle($mpX1 + $Cutpoint, $mpY1 + $Cutpoint, 270, 4 * $cbDPI) + Local $apos3 = cAngle($mpX1 - $Cutpoint, $mpY1 + $Cutpoint, 315, 8 * $cbDPI) + + ;Add arrow2 + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen) ;h + + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 - $Cutpoint, $apos1[0], $apos1[1], $hPen4) ;v + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 + $Cutpoint, $mpY1 + $Cutpoint, $apos2[0], $apos2[1], $hPen4) ;h + + ;Add lines + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic1[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic2[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX1 - $Cutpoint, $mpY1 + $Cutpoint, $apos3[0] + $Cutpoint, $apos3[1] - $Cutpoint, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_FSRestore_Graphic3[0], $mpX + $Cutpoint, $mpY - $Cutpoint, $apos4[0] - $Cutpoint, $apos4[1] + $Cutpoint, $hPen4) + + EndIf + ;============================================================================================================================= + + + ;Create Menu Button=========================================================================================================== + If $ButtonsToCreate_Array[4] Then + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) ;r + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic1[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) ;r + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic2[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen) + + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9, ($CBw / 3) * 2, $CBh / 2.9, $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 4), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 4), $hPen4) + _GDIPlus_GraphicsDrawLine($Button_Menu_Graphic3[0], $CBw / 3, $CBh / 2.9 + ($FrameSize * 8), ($CBw / 3) * 2, $CBh / 2.9 + ($FrameSize * 8), $hPen4) + EndIf + ;============================================================================================================================= + + ;Release resources + _GDIPlus_PenDispose($hPen) + _GDIPlus_PenDispose($hPen2) + _GDIPlus_PenDispose($hPen3) + _GDIPlus_PenDispose($hPen4) + _GDIPlus_PenDispose($hPen5) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrush2) + + ;Create bitmap handles + If $ButtonsToCreate_Array[0] Then + $Button_Close_Array[5] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic1) + $Button_Close_Array[6] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic2, False) + $Button_Close_Array[7] = _iGraphicCreateBitmapHandle($Button_Close_Array[0], $Button_Close_Graphic3, False) + GUICtrlSetResizing($Button_Close_Array[0], 768 + 32 + 4) + $Control_Buttons[0] = $Button_Close_Array[0] + _cHvr_Register($Button_Close_Array[0], "_iHoverOff", "_iHoverOn", '', "", _iAddHover($Button_Close_Array), $CurrentGUI) + EndIf + If $ButtonsToCreate_Array[1] Then + $Button_Maximize_Array[5] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic1) + $Button_Maximize_Array[6] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic2, False) + $Button_Maximize_Array[7] = _iGraphicCreateBitmapHandle($Button_Maximize_Array[0], $Button_Maximize_Graphic3, False) + $Button_Restore_Array[5] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic1) + $Button_Restore_Array[6] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic2, False) + $Button_Restore_Array[7] = _iGraphicCreateBitmapHandle($Button_Restore_Array[0], $Button_Restore_Graphic3, False) + GUICtrlSetResizing($Button_Maximize_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_Restore_Array[0], 768 + 32 + 4) + + $Control_Buttons[1] = $Button_Maximize_Array[0] + $Control_Buttons[2] = $Button_Restore_Array[0] + GUICtrlSetState($Button_Restore_Array[0], 32) + + _cHvr_Register($Button_Maximize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Maximize_Array), $CurrentGUI) + _cHvr_Register($Button_Restore_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Restore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[2] Then + $Button_Minimize_Array[5] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic1) + $Button_Minimize_Array[6] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic2, False) + $Button_Minimize_Array[7] = _iGraphicCreateBitmapHandle($Button_Minimize_Array[0], $Button_Minimize_Graphic3, False) + GUICtrlSetResizing($Button_Minimize_Array[0], 768 + 32 + 4) + $Control_Buttons[3] = $Button_Minimize_Array[0] + _cHvr_Register($Button_Minimize_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Minimize_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[3] Then + $Button_FullScreen_Array[5] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic1) + $Button_FullScreen_Array[6] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic2, False) + $Button_FullScreen_Array[7] = _iGraphicCreateBitmapHandle($Button_FullScreen_Array[0], $Button_FullScreen_Graphic3, False) + + $Button_FSRestore_Array[5] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic1) + $Button_FSRestore_Array[6] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic2, False) + $Button_FSRestore_Array[7] = _iGraphicCreateBitmapHandle($Button_FSRestore_Array[0], $Button_FSRestore_Graphic3, False) + + GUICtrlSetResizing($Button_FullScreen_Array[0], 768 + 32 + 4) + GUICtrlSetResizing($Button_FSRestore_Array[0], 768 + 32 + 4) + GUICtrlSetState($Button_FSRestore_Array[0], 32) + + $Control_Buttons[4] = $Button_FullScreen_Array[0] + $Control_Buttons[5] = $Button_FSRestore_Array[0] + _cHvr_Register($Button_FullScreen_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FullScreen_Array), $CurrentGUI) + _cHvr_Register($Button_FSRestore_Array[0], "_iHoverOff", "_iHoverOn", "_iFullscreenToggleBtn", "", _iAddHover($Button_FSRestore_Array), $CurrentGUI) + EndIf + + If $ButtonsToCreate_Array[4] Then + $Button_Menu_Array[5] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic1) + $Button_Menu_Array[6] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic2, False) + $Button_Menu_Array[7] = _iGraphicCreateBitmapHandle($Button_Menu_Array[0], $Button_Menu_Graphic3, False) + GUICtrlSetResizing($Button_Menu_Array[0], 768 + 32 + 2) + $Control_Buttons[6] = $Button_Menu_Array[0] + _cHvr_Register($Button_Menu_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Menu_Array), $CurrentGUI) + EndIf + + Return $Control_Buttons +EndFunc ;==>_iCreateControlButtons + +#EndRegion MetroGUI=========================================================================================== + + + +#Region MetroButtons=========================================================================================== +; =============================================================================================================================== +; Name ..........: _Metro_CreateButton +; Description ...: Creates metro style buttons. Hovering creates a frame around the buttons. +; Syntax ........: _Metro_CreateButton($Text, $Left, $Top, $Width, $Height[, $BGColor = $ButtonBKColor[, +; $FontColor = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1 $FrameColor = "0xFFFFFF"]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BGColor - [optional] Button background color. Default is $ButtonBKColor. +; $FontColor - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButton("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(4 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;For GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] +EndFunc ;==>_Metro_CreateButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx +; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + ;Calculate Framesize + Local $FrameSize = Round(2 * $btnDPI) + If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1 + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize) + Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Add frame + _GDIPlus_GraphicsDrawRect($Button_Graphic1[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor) + _GDIPlus_GraphicsDrawRect($Button_Graphic3[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor) + _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + ;Register Hover funcs + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateButtonEx2 +; Description ...: Creates a button without a frame and slightly rounded corners. Hovering changes the button color to a lighter color. +; Syntax ........: _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[, +; $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[, +; $FrameColor = "0xFFFFFF"]]]]]]) +; Parameters ....: $Text - Text of the button. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Button background color. Default is $ButtonBKColor. +; $Font_Color - [optional] Font colore. Default is $ButtonTextColor. +; $Font - [optional] Font. Default is "Arial". +; $Fontsize - [optional] Fontsize. Default is 12.5. +; $FontStyle - [optional] Fontstyle. Default is 1. +; $FrameColor - [optional] Button frame color. Default is "0xFFFFFF". +; Return values .: Handle to the button. +; Example .......: _Metro_CreateButtonEx2("Button 1",50,50,120,34) +; =============================================================================================================================== + +Func _Metro_CreateButtonEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") + Local $Button_Array[16] + + Local $btnDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + $Button_Array[1] = False ; Set hover OFF + $Button_Array[3] = "2" ; Type + $Button_Array[15] = GetCurrentGUI() + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Font_Color1 = _AlterBrightness($Font_Color, 7) + Else + Local $Font_Color1 = _AlterBrightness($Font_Color, -15) + EndIf + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + $Font_Color1 = "0xFF" & Hex($Font_Color1, 6) + $FrameColor = "0xFF" & Hex($FrameColor, 6) + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid($Font_Color1) + Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF")) + + ;Create Button graphics + Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Default + Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Hover + Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5) ;Disabled + + Local $iRadius = 3, $Margin = ($iRadius / 2) * $gDPI + Local $iWidth = $Width - ($Margin * 2), $iHeight = $Height - ($Margin * 2) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $Margin + $iWidth - ($iRadius * 2), $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, $Margin, $Margin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + Local $hBrush = _GDIPlus_BrushCreateSolid($BG_Color) + Local $hBrushHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($BG_Color, +25), "0x", "0xFF")) + _GDIPlus_GraphicsFillPath($Button_Graphic1[0], $hPath, $hBrush) + _GDIPlus_GraphicsFillPath($Button_Graphic2[0], $hPath, $hBrushHover) + _GDIPlus_GraphicsFillPath($Button_Graphic3[0], $hPath, $hBrush) + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw button text + _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor1) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush_BTN_FontColorDis) + _GDIPlus_BrushDispose($hBrush) + _GDIPlus_BrushDispose($hBrushHover) + _GDIPlus_PathDispose($hPath) + + ;Set graphic and return Bitmap handle + $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1) + $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False) + $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Button_Array[0], 768) + + _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array)) + Return $Button_Array[0] + +EndFunc ;==>_Metro_CreateButtonEx2 + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_DisableButton +; Description ...: Disables a Button and makes the font grayed out to indicate that the button is disabled. +; Syntax ........: _Metro_DisableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; Example .......: _Metro_DisableButton($Button1) +; =============================================================================================================================== +Func _Metro_DisableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 128) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][7])) + EndIf + Next +EndFunc ;==>_Metro_DisableButton + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_EnableButton +; Description ...: Enables a metro style button and reverts the grayed out font style. +; Syntax ........: _Metro_EnableButton($mButton) +; Parameters ....: $mButton - Handle to the button. +; =============================================================================================================================== +Func _Metro_EnableButton($mButton) + Local $CurrentGUI = GetCurrentGUI() + GUICtrlSetState($mButton, 64) + For $i_BTN = 0 To (UBound($iHoverReg) - 1) + If ($iHoverReg[$i_BTN][0] = $mButton) And ($iHoverReg[$i_BTN][15] = $CurrentGUI) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i_BTN][0], 0x0172, 0, $iHoverReg[$i_BTN][5])) + EndIf + Next +EndFunc ;==>_Metro_EnableButton + + +#EndRegion MetroButtons=========================================================================================== + +#Region Metro Toggles=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle(NEW WIN10 Style) +; Description ...: Creates a Windows 10 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $Text1 = $Text + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Not (Mod($Height, 2) = 0) Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + ;HighDPI Support + Local $pDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Not (Mod($Height, 2) = 0) Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;Calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Not (Mod($TopMargCalc, 2) = 0) Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargCalc1 = Number(12 * $pDPI, 1) + If Not (Mod($TopMargCalc1, 2) = 0) Then $TopMargCalc1 = $TopMargCalc1 + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $TopMarginCircle = Number((($Height - $TopMargCalc1) / 2), 1) + Local $iRadius = 10 * $pDPI + Local $hFWidth = Number(50 * $pDPI, 1) + If Not (Mod($hFWidth, 2) = 0) Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Not (Mod($togSizeW, 2) = 0) Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Not (Mod($togSizeH, 2) = 0) Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +65), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +70), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $BrushInnerUC = _GDIPlus_BrushCreateSolid($BG_Color) + Local $BrushCircleUC = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BrushCircleHoverUC = _GDIPlus_BrushCreateSolid($BoxFrameCol1) + Local $hPenDefaultUC = _GDIPlus_PenCreate($Font_Color, 2 * $pDPI) + Local $hPenHoverUC = _GDIPlus_PenCreate($BoxFrameCol1, 2 * $pDPI) + + ;Checked + Local $BrushInnerC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Local $BrushInnerCHover = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) + Local $BrushCircleC = _GDIPlus_BrushCreateSolid(StringReplace($ButtonTextColor, "0x", "0xFF")) + Local $hPenDefaultC = _GDIPlus_PenCreate(StringReplace($ButtonBKColor, "0x", "0xFF"), 2 * $pDPI) + Local $hPenHoverC = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF"), 2 * $pDPI) + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) + + ;Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth + (10 * $pDPI), 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + Local $hPath1 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath1, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath1, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath1) + _GDIPlus_GraphicsFillPath($Toggle_Graphic1[0], $hPath1, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic1[0], $hPath1, $hPenDefaultUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic1[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleUC) + + ;Default hover state + Local $hPath2 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath2, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath2, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath2) + _GDIPlus_GraphicsFillPath($Toggle_Graphic9[0], $hPath2, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic9[0], $hPath2, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic9[0], 6 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep1 + Local $hPath3 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath3, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath3, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath3) + _GDIPlus_GraphicsFillPath($Toggle_Graphic2[0], $hPath3, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic2[0], $hPath3, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic2[0], 10 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep2 + Local $hPath4 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath4, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath4, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath4) + _GDIPlus_GraphicsFillPath($Toggle_Graphic3[0], $hPath4, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic3[0], $hPath4, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic3[0], 14 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep3 + Local $hPath5 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath5, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath5, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath5) + _GDIPlus_GraphicsFillPath($Toggle_Graphic4[0], $hPath5, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic4[0], $hPath5, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic4[0], 18 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep4 + Local $hPath6 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath6, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath6, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath6) + _GDIPlus_GraphicsFillPath($Toggle_Graphic5[0], $hPath6, $BrushInnerUC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic5[0], $hPath6, $hPenHoverUC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic5[0], 22 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleHoverUC) + + ;CheckedStep5 + Local $hPath7 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath7, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath7, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath7) + _GDIPlus_GraphicsFillPath($Toggle_Graphic6[0], $hPath7, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic6[0], $hPath7, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic6[0], 26 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;CheckedStep6 + Local $hPath8 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath8, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath8, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath8) + _GDIPlus_GraphicsFillPath($Toggle_Graphic7[0], $hPath8, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic7[0], $hPath8, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic7[0], 30 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state + Local $hPath9 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath9, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath9, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath9) + _GDIPlus_GraphicsFillPath($Toggle_Graphic8[0], $hPath9, $BrushInnerC) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic8[0], $hPath9, $hPenDefaultC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic8[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Final checked state hover + Local $hPath10 = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath10, 0 + $hFWidth - ($iRadius * 2), $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin + (20 * $pDPI) - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath10, 1 * $pDPI, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath10) + _GDIPlus_GraphicsFillPath($Toggle_Graphic10[0], $hPath10, $BrushInnerCHover) + _GDIPlus_GraphicsDrawPath($Toggle_Graphic10[0], $hPath10, $hPenHoverC) + _GDIPlus_GraphicsFillEllipse($Toggle_Graphic10[0], 34 * $pDPI, $TopMarginCircle, 12 * $pDPI, 12 * $pDPI, $BrushCircleC) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($BrushInnerUC) + _GDIPlus_BrushDispose($BrushCircleUC) + _GDIPlus_BrushDispose($BrushCircleHoverUC) + _GDIPlus_BrushDispose($BrushInnerC) + _GDIPlus_BrushDispose($BrushInnerCHover) + _GDIPlus_BrushDispose($BrushCircleC) + _GDIPlus_PenDispose($hPenDefaultUC) + _GDIPlus_PenDispose($hPenHoverUC) + _GDIPlus_PenDispose($hPenDefaultC) + _GDIPlus_PenDispose($hPenHoverC) + _GDIPlus_PathDispose($hPath1) + _GDIPlus_PathDispose($hPath2) + _GDIPlus_PathDispose($hPath3) + _GDIPlus_PathDispose($hPath4) + _GDIPlus_PathDispose($hPath5) + _GDIPlus_PathDispose($hPath6) + _GDIPlus_PathDispose($hPath7) + _GDIPlus_PathDispose($hPath8) + _GDIPlus_PathDispose($hPath9) + _GDIPlus_PathDispose($hPath10) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set Control Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style toggle with a text on the right side. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $Text - Text to be displayed on the right side of the GUI. +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateToggleEX($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Local $pDPI = _HighDPICheck(), $Text1 = $Text + + If $Height < 20 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 20px for metro toggles.") + EndIf + If $Width < 46 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. width for metro toggles must be at least 46px without any text!") + EndIf + If Mod($Height, 2) <> 0 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The toggle height should be an even number to prevent any misplacing.") + EndIf + + ;HighDPI Support + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Height, 2) <> 0 Then $Height = $Height + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + ;Create Toggle Array + Local $Toggle_Array[16] + $Toggle_Array[1] = False ; Hover + $Toggle_Array[2] = False ; Checked State + $Toggle_Array[3] = "6" ; Type + $Toggle_Array[15] = GetCurrentGUI() + + ;calc pos/sizes + Local $TopMargCalc = Number(20 * $pDPI, 1) + If Mod($TopMargCalc, 2) <> 0 Then $TopMargCalc = $TopMargCalc + 1 + Local $TopMargin = Number((($Height - $TopMargCalc) / 2), 1) + Local $hFWidth = Number(50 * $pDPI, 1) + If Mod($hFWidth, 2) <> 0 Then $hFWidth = $hFWidth + 1 + Local $togSizeW = Number(46 * $pDPI, 1) + If Mod($togSizeW, 2) <> 0 Then $togSizeW = $togSizeW + 1 + Local $togSizeH = Number(20 * $pDPI, 1) + If Mod($togSizeH, 2) <> 0 Then $togSizeH = $togSizeH + 1 + Local $tog_calc1 = Number(2 * $pDPI, 1) + Local $tog_calc2 = Number(3 * $pDPI, 1) + Local $tog_calc3 = Number(11 * $pDPI, 1) + Local $tog_calc5 = Number(6 * $pDPI, 1) + + ;Set Colors + $BG_Color = "0xFF" & Hex($BG_Color, 6) + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $Brush_BTN_FontColor1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, +45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, +35), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, +60), "0x", "0xFF") + Else + Local $BoxFrameCol = StringReplace(_AlterBrightness($Font_Color, -45), "0x", "0xFF") + Local $BoxFrameCol1 = StringReplace(_AlterBrightness($Font_Color, -55), "0x", "0xFF") + Local $Font_Color1 = StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF") + EndIf + + ;Unchecked + Local $Brush1 = _GDIPlus_BrushCreateSolid($BoxFrameCol) ;Inner + Local $Brush2 = _GDIPlus_BrushCreateSolid($BoxFrameCol1) ;Outerframe + Local $Brush3 = _GDIPlus_BrushCreateSolid($Font_Color1) ;InnerHover + ;Checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;Inner + Local $Brush5 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, -10), "0x", "0xFF")) ;Outerframe + Local $Brush6 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +15), "0x", "0xFF")) ;InnerHover + + ;Create graphics + Local $Toggle_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic5 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic6 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic7 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic8 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic9 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5), $Toggle_Graphic10 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) + + ;Set font + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, 0) + Local $tLayout = _GDIPlus_RectFCreate($hFWidth, 0, $Width - $hFWidth, $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + + ;Draw text + If StringInStr($Text, "|@|") Then + $Text1 = StringRegExp($Text, "\|@\|(.+)", 1) + If Not @error Then $Text1 = $Text1[0] + $Text = StringRegExp($Text, "^(.+)\|@\|", 1) + If Not @error Then $Text = $Text[0] + EndIf + + + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic5[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic6[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic7[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic8[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic9[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Toggle_Graphic10[0], $Text1, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Default state + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) ; Toggle Background + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush1) ;Toggle Inner + _GDIPlus_GraphicsFillRect($Toggle_Graphic1[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) ; Toggle Slider + + ;Default hover state + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic9[0], 0, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep1 + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic2[0], 5 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep2 + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic3[0], 10 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep3 + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush2) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush3) + _GDIPlus_GraphicsFillRect($Toggle_Graphic4[0], 15 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep4 + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic5[0], $togSizeH, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep5 + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic6[0], 25 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;CheckedStep6 + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic7[0], 30 * $pDPI, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush4) + _GDIPlus_GraphicsFillRect($Toggle_Graphic8[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Final checked state hover + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], 0, $TopMargin, $togSizeW, $togSizeH, $Brush5) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $tog_calc2, $TopMargin + $tog_calc2, $togSizeW - $tog_calc5, $togSizeH - $tog_calc5, $Brush6) + _GDIPlus_GraphicsFillRect($Toggle_Graphic10[0], $togSizeW - $tog_calc3, $TopMargin, $tog_calc3, $togSizeH, $Brush_BTN_FontColor1) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush_BTN_FontColor1) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_BrushDispose($Brush5) + _GDIPlus_BrushDispose($Brush6) + + ;Create bitmap handles and set graphics + $Toggle_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Toggle_Array[5] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic1) + $Toggle_Array[6] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic2, False) + $Toggle_Array[7] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic3, False) + $Toggle_Array[8] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic4, False) + $Toggle_Array[9] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic5, False) + $Toggle_Array[10] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic6, False) + $Toggle_Array[11] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic7, False) + $Toggle_Array[12] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic8, False) + $Toggle_Array[13] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic9, False) + $Toggle_Array[14] = _iGraphicCreateBitmapHandle($Toggle_Array[0], $Toggle_Graphic10, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Toggle_Array[0], 768) + + ;Add to GUI_HOVER_REG + _cHvr_Register($Toggle_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Toggle_Array)) + + Return $Toggle_Array[0] +EndFunc ;==>_Metro_CreateToggleEX + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggle +; Description ...: Creates a Windows 10 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggle($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggle($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggle + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateToggleEx +; Description ...: Creates a Windows 8 style on/off toggle with custom "enable/disable" text. +; Syntax ........: _Metro_CreateToggle($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"]]]]) +; Parameters ....: +; $OnText - Text to be displayed when the toggle is checked +; $OffText - Text to be displayed when the toggle is unchecked +; $Left - Left pos +; $Top - Top pos. +; $Width - Width +; $Height - Height +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; Return values .: Handle to the toggle. +; =============================================================================================================================== +Func _Metro_CreateOnOffToggleEx($OnText, $OffText, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11") + Return _Metro_CreateToggleEX($OffText & "|@|" & $OnText, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize) +EndFunc ;==>_Metro_CreateOnOffToggleEx + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleIsChecked +; Description ...: Checks if a toggle is checked +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_ToggleIsChecked($Toggle) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleSwitch +; Description ...: Triggers Toggle Check/Uncheck and returns the current state of the toggle. -> Should only be used to handle user clicks +; Syntax ........: _Metro_ToggleIsChecked($Toggle) +; Parameters ....: $Toggle - Handle of the toggle. +; Return values .: True / False (State = Checked / Unchecked) +; =============================================================================================================================== +Func _Metro_ToggleSwitch($Toggle) + If _Metro_ToggleIsChecked($Toggle) Then + _Metro_ToggleUnCheck($Toggle) + Return False + Else + _Metro_ToggleCheck($Toggle) + Return True + EndIf +EndFunc ;==>_Metro_ToggleSwitch + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleUnCheck +; Description ...: Unchecks a toggle +; Syntax ........: _Metro_ToggleUnCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle +; $NoAnimation - [optional] True/False. Default is False. - Unchecks the toggle instantly without animation +; =============================================================================================================================== +Func _Metro_ToggleUnCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 12 To 6 Step -1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][13])) + EndIf + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = False + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleUnCheck + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_ToggleCheck +; Description ...: Checks a toggle +; Syntax ........: _Metro_ToggleCheck($Toggle[, $NoAnimation = False]) +; Parameters ....: $Toggle - Handle to the toggle. +; $NoAnimation - [optional] True/False. Default is False. - Checks the Toggle instantly without an animation and prevents hover effect from getting stuck. Should be used always when creating a gui with a checked toggle before the gui is shown. +; =============================================================================================================================== +Func _Metro_ToggleCheck($Toggle, $NoAnimation = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Toggle Then + If Not $iHoverReg[$i][2] Then + If Not $NoAnimation Then + For $i2 = 6 To 11 Step +1 + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][$i2])) + Sleep(1) + Next + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Toggle, 0x0172, 0, $iHoverReg[$i][12])) + EndIf + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + ExitLoop + EndIf + EndIf + Next +EndFunc ;==>_Metro_ToggleCheck +#EndRegion Metro Toggles=========================================================================================== + + +#Region MetroRadio=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadio +; Description ...: Creates a metro style radio. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22, $ExStyle = False) + If $Height < 22 And $RadioCircleSize > 21 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 22px for metro radios.") + EndIf + + ;HighDPI Support + Local $rDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width - 1 + If Mod($Height, 2) <> 0 Then $Height = $Height - 1 + $RadioCircleSize = $RadioCircleSize * $gDPI + If Mod($RadioCircleSize, 2) <> 0 Then $RadioCircleSize = $RadioCircleSize - 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Radio_Array[16] + $Radio_Array[1] = False ; Hover + $Radio_Array[2] = False ; Checkmark + $Radio_Array[3] = "7" ; Type + $Radio_Array[4] = $RadioGroup ; Radiogroup + $Radio_Array[15] = GetCurrentGUI() + + ;Set position + Local $TopMargin = ($Height - $RadioCircleSize) / 2 + + ;Set Colors + If $BG_Color <> 0 Then $BG_Color = "0xFF" & Hex($BG_Color, 6) + + $Font_Color = "0xFF" & Hex($Font_Color, 6) + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + Local $BoxFrameCol = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) + If $ExStyle Then + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) + Else + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF")) + EndIf + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) + + ;Create graphics + Local $Radio_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Radio_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Radio_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Radio_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($RadioCircleSize + (4 * $rDPI), 0, $Width - $RadioCircleSize + (4 * $rDPI), $Height) + _GDIPlus_StringFormatSetAlign($hFormat, 0) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw radio text + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Radio_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Add Circle Background + Local $radSize1 = 1 * $rDPI + Local $radSize2 = 5 * $rDPI + Local $radSize3 = 11 * $rDPI + + ;Default state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic1[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + + ;Default hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic3[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + + ;Checked state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush1) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic2[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Checked hover state + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], 0, $TopMargin, $RadioCircleSize - $radSize1, $RadioCircleSize - $radSize1, $Brush3) + _GDIPlus_GraphicsFillEllipse($Radio_Graphic4[0], $radSize2, $TopMargin + $radSize2, $RadioCircleSize - $radSize3, $RadioCircleSize - $radSize3, $Brush2) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + + ;Create bitmap handles and set graphics + $Radio_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Radio_Array[5] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic1) + $Radio_Array[7] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic2, False) + $Radio_Array[6] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic3, False) + $Radio_Array[8] = _iGraphicCreateBitmapHandle($Radio_Array[0], $Radio_Graphic4, False) + + ;Set GUI Resizing + GUICtrlSetResizing($Radio_Array[0], 768) + + ;Add Hover effects + _cHvr_Register($Radio_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Radio_Array)) + Return $Radio_Array[0] +EndFunc ;==>_Metro_CreateRadio + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateRadioEx +; Description ...: Creates a metro style radio with colored checkmark. +; Syntax ........: _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $RadioGroup - A radiogroup to assign the radio to. You can use numbers or any text. +; $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $$RadioCircleSize - [optional] Custom circle size for radio. +; Return values .: Handle to the radio. +; =============================================================================================================================== +Func _Metro_CreateRadioEx($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $RadioCircleSize = 22) + Return _Metro_CreateRadio($RadioGroup, $Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, $RadioCircleSize, True) +EndFunc ;==>_Metro_CreateRadioEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioCheck +; Description ...: Checks the selected radio and unchecks all other radios in the same radiogroup. +; Syntax ........: _Metro_RadioCheck($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - The group that the radio has been assigned to. +; $Radio - Handle to the radio. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the radio is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_RadioCheck($RadioGroup, $Radio, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + $iHoverReg[$i][1] = True + $iHoverReg[$i][2] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][8])) + EndIf + Else + If $iHoverReg[$i][4] = $RadioGroup Then + $iHoverReg[$i][2] = False + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$i][0], 0x0172, 0, $iHoverReg[$i][5])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_RadioCheck +#EndRegion MetroRadio=========================================================================================== + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_RadioIsChecked +; Description ...: Checks if a metro radio is checked. +; Syntax ........: _Metro_RadioIsChecked($RadioGroup, $Radio) +; Parameters ....: $RadioGroup - Radio group +; $Radio - Handle to the radio +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_RadioIsChecked($RadioGroup, $Radio) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Radio Then + If $iHoverReg[$i][4] = $RadioGroup Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + EndIf + Next + Return False +EndFunc ;==>_Metro_RadioIsChecked + + +#Region MetroCheckbox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckbox +; Description ...: Creates a metro style checkbox +; Syntax ........: _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; $cb_style - [optional] Creates a checkbox with the old design. You can also use _Metro_CreateCheckboxEx to do so. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0, $cb_style = 1) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(22 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize + + If $cb_style = 0 Then + $FrameSize = $chbh / 7 + Else + $FrameSize = $chbh / 8 + EndIf + + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + If $cb_style = 0 Then + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush3 = $Brush1 + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush4 = $Brush2 ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_CheckMark_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + Else + Local $Brush1 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Color, "0x", "0xFF")) ;default + Local $Brush2 = _GDIPlus_BrushCreateSolid(StringReplace($CB_Radio_Hover_Color, "0x", "0xFF")) ;default hover + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + EndIf + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + Local $iRadius = Round(2 * $chDPI) + Local $hPath = _GDIPlus_PathCreate() + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin, $iRadius * 2, $iRadius * 2, 270, 90) + _GDIPlus_PathAddArc($hPath, $chbh - ($iRadius * 2), $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin + $chbh - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) + _GDIPlus_PathAddArc($hPath, 0, $TopMargin, $iRadius * 2, $iRadius * 2, 180, 90) + _GDIPlus_PathCloseFigure($hPath) + + _GDIPlus_GraphicsFillPath($Checkbox_Graphic1[0], $hPath, $Brush1) ;Default state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic3[0], $hPath, $Brush2) ;Default hover state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic2[0], $hPath, $Brush3) ;Checked state + _GDIPlus_GraphicsFillPath($Checkbox_Graphic4[0], $hPath, $Brush4) ;Checked hover state + + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.60 + Local $mpY = $TopMargin + $chbh / 1.3 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 1.35) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Brush1) + _GDIPlus_BrushDispose($Brush2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckbox + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx +; Description ...: Creates a checkbox with the old black and white style. +; Syntax ........: _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, $Font_Color = $FontThemeColor[, +; $Font = "Segoe UI"[, $Fontsize = "11"[, $FontStyle = 0[, $cb_style = 1]]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + Return _Metro_CreateCheckbox($Text, $Left, $Top, $Width, $Height, $BG_Color, $Font_Color, $Font, $Fontsize, $FontStyle, 0) +EndFunc ;==>_Metro_CreateCheckboxEx + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateCheckboxEx2 +; Description ...: Creates a modern rounded checkbox +; Syntax ........: _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height[, $BG_Color = $GUIThemeColor[, +; $Font_Color = $FontThemeColor[, $Font = "Segoe UI"[, $FontSize = "11"[, $FontStyle = 0]]]]]) +; Parameters ....: $Text - Text. +; $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $BG_Color - [optional] Background color. Default is $GUIThemeColor. +; $Font_Color - [optional] Font color. Default is $FontThemeColor. +; $Font - [optional] Font. Default is "Segoe UI". +; $FontSize - [optional] Fontsize. Default is "11". +; $FontStyle - [optional] Fontstyle. Default is 0. +; Return values .: Handle to the Checkbox +; =============================================================================================================================== +Func _Metro_CreateCheckboxEx2($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Segoe UI", $Fontsize = "11", $FontStyle = 0) + If $Height < 24 Then + If (@Compiled = 0) Then MsgBox(48, "Metro UDF", "The min. height is 24px for metro checkboxes.") + EndIf + + ;HighDPI Support + Local $chDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + If Mod($Width, 2) <> 0 Then $Width = $Width + 1 + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $Checkbox_Array[16] + $Checkbox_Array[1] = False ; Hover + $Checkbox_Array[2] = False ; Checkmark + $Checkbox_Array[3] = "5" ; Type + $Checkbox_Array[15] = GetCurrentGUI() + + ;Calc Box position etc. + Local $chbh = Round(24 * $chDPI) + Local $TopMargin = ($Height - $chbh) / 2 + Local $CheckBox_Text_Margin = $chbh + ($TopMargin * 1.3) + Local $FrameSize = $chbh / 15 + Local $BoxFrameSize = 2 + + ;Set Colors, Create Brushes and Pens + If $BG_Color <> 0 Then + $BG_Color = "0xFF" & Hex($BG_Color, 6) + EndIf + $Font_Color = "0xFF" & Hex($Font_Color, 6) + + + Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color) + + If StringInStr($GUI_Theme_Name, "Light") Then + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, -100), "0x", "0xFF"), $FrameSize) + Else + Local $Pen1 = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($GUIThemeColor, +85), "0x", "0xFF"), $FrameSize) + EndIf + + + Local $Pen2 = _GDIPlus_PenCreate(StringReplace($Font_Color, "0x", "0xFF"), $FrameSize) ;checked + Local $Brush3 = _GDIPlus_BrushCreateSolid(StringReplace($ButtonBKColor, "0x", "0xFF")) ;checked + Local $Brush4 = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($ButtonBKColor, +10), "0x", "0xFF")) ;checked hover + Local $PenX = _GDIPlus_PenCreate(StringReplace($CB_Radio_Color, "0x", "0xFF"), $FrameSize) ;CheckmarkColor + + + ;Create graphics + Local $Checkbox_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default state + Local $Checkbox_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked state + Local $Checkbox_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;default hover state + Local $Checkbox_Graphic4 = _iGraphicCreate($Width, $Height, $BG_Color, 5, 5) ;checked hover state + + ;Create font, Set font options + Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle) + Local $tLayout = _GDIPlus_RectFCreate($CheckBox_Text_Margin, 0, $Width - $CheckBox_Text_Margin, $Height) + + _GDIPlus_StringFormatSetAlign($hFormat, 1) + _GDIPlus_StringFormatSetLineAlign($hFormat, 1) + $tLayout.Y = 1 + + ;Draw checkbox text + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + _GDIPlus_GraphicsDrawStringEx($Checkbox_Graphic4[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor) + + ;Draw rounded box + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic1[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen1) ;Default state + _GDIPlus_GraphicsDrawEllipse($Checkbox_Graphic3[0], 0 + ($FrameSize / 2), $TopMargin + ($FrameSize / 2), $chbh - ($FrameSize), $chbh - ($FrameSize), $Pen2) ;Default hover state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic2[0], 0, $TopMargin, $chbh, $chbh, $Brush3) ;Checked state + _GDIPlus_GraphicsFillEllipse($Checkbox_Graphic4[0], 0, $TopMargin, $chbh, $chbh, $Brush4) ;Checked hover state + + ;Calc size+pos + Local $Cutpoint = ($FrameSize * 0.70) / 2 + Local $mpX = $chbh / 2.4 + Local $mpY = $TopMargin + $chbh / 1.45 + Local $apos1 = cAngle($mpX - $Cutpoint, $mpY, 135, $chbh / 2) + Local $apos2 = cAngle($mpX, $mpY - $Cutpoint, 225, $chbh / 4.3) + + + ;Add check mark + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic2[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $PenX) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic4[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $PenX) + + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen1) ;r + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic1[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen1) ;l + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX - $Cutpoint, $mpY, $apos1[0], $apos1[1], $Pen2) + _GDIPlus_GraphicsDrawLine($Checkbox_Graphic3[0], $mpX, $mpY - $Cutpoint, $apos2[0], $apos2[1], $Pen2) + + + ;Release created objects + _GDIPlus_FontDispose($hFont) + _GDIPlus_FontFamilyDispose($hFamily) + _GDIPlus_StringFormatDispose($hFormat) + _GDIPlus_BrushDispose($Brush_BTN_FontColor) + _GDIPlus_BrushDispose($Pen1) + _GDIPlus_BrushDispose($Pen2) + _GDIPlus_BrushDispose($Brush3) + _GDIPlus_BrushDispose($Brush4) + _GDIPlus_PenDispose($PenX) + + ;Create bitmap handles and set graphics + $Checkbox_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Checkbox_Array[5] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic1) + $Checkbox_Array[7] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic2, False) + $Checkbox_Array[6] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic3, False) + $Checkbox_Array[8] = _iGraphicCreateBitmapHandle($Checkbox_Array[0], $Checkbox_Graphic4, False) + + ;For GUI Resizing + GUICtrlSetResizing($Checkbox_Array[0], 768) + _cHvr_Register($Checkbox_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Checkbox_Array)) + Return $Checkbox_Array[0] +EndFunc ;==>_Metro_CreateCheckboxEx2 + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxIsChecked +; Description ...: Checks if a metro checkbox is checked. +; Syntax ........: _Metro_CheckboxIsChecked($Checkbox) +; Parameters ....: $Checkbox - Handle to the checkbox. +; Return values .: True / False +; =============================================================================================================================== +Func _Metro_CheckboxIsChecked($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + If $iHoverReg[$i][2] Then + Return True + Else + Return False + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxIsChecked + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxUnCheck +; Description ...: Unchecks a metro checkbox +; Syntax ........: _Metro_CheckboxUnCheck($Checkbox,) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; =============================================================================================================================== +Func _Metro_CheckboxUnCheck($Checkbox) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = False + $iHoverReg[$i][1] = True + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][6])) + EndIf + Next +EndFunc ;==>_Metro_CheckboxUnCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxCheck +; Description ...: Checks a metro checkbox +; Syntax ........: _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; $NoHoverEffect - Default = False, True = Prevents the hover effect from appearing/freezing -> Should be used anytime the checkbox is not "clicked" by the user but checked manually during startup +; =============================================================================================================================== +Func _Metro_CheckboxCheck($Checkbox, $NoHoverEffect = False) + For $i = 0 To (UBound($iHoverReg) - 1) Step +1 + If $iHoverReg[$i][0] = $Checkbox Then + $iHoverReg[$i][2] = True + $iHoverReg[$i][1] = True + If $NoHoverEffect Then + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][7])) + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($Checkbox, 0x0172, 0, $iHoverReg[$i][8])) + EndIf + EndIf + Next +EndFunc ;==>_Metro_CheckboxCheck + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CheckboxSwitch +; Description ...: Toggles between checked/unchecked state and then returns the current state. -> Should only be used to handle user clicks +; Syntax ........: _Metro_CheckboxSwitch($Checkbox) +; Parameters ....: $Checkbox - Handle to the Checkbox. +; Returns ---------: True = Checkbox is checked, False = Checkbox is not checked. +; =============================================================================================================================== +Func _Metro_CheckboxSwitch($Checkbox) + If _Metro_CheckboxIsChecked($Checkbox) Then + _Metro_CheckboxUnCheck($Checkbox) + Return False + Else + _Metro_CheckboxCheck($Checkbox) + Return True + EndIf +EndFunc ;==>_Metro_CheckboxSwitch + + + +#EndRegion MetroCheckbox=========================================================================================== + +#Region Metro MsgBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_MsgBox +; Description ...: Creates a metro style MsgBox +; Syntax ........: _Metro_MsgBox($Flag, $Title, $Text[, $mWidth = 600[, $FontSize = 14[, $ParentGUI = "", $Timeout = 0]]]) +; Parameters ....: $Flag - Flag / Possible button combinations - See Autoit help file for possible buttons combinations under MsgBox +; $Title - Title of the MsgBox. +; $Text - Text of the MsgBox. +; $mWidth - [optional] Width of the MsgBox. Use a value that matches the text length and font size. Default is 600. +; $FontSize - [optional] Fontsize. Default is 11. +; $ParentGUI - [optional] Parent GUI/Window to prevent multiple open windows in the taskbar for one program. Default is "". +; $Timeout - [optional] Timeout in seconds. Default is 0. +; +; Notes .......: _GUIDisable($GUI, 0, 30) should be used before starting the MsgBox, so the MsgBox is better visible on top of your GUI. You also have to call _GUIDisable($GUI) afterwards. +; =============================================================================================================================== +Func _Metro_MsgBox($Flag, $Title, $Text, $mWidth = 600, $Fontsize = 11, $ParentGUI = "", $Timeout = 0) + Local $1stButton, $2ndButton, $3rdButton, $1stButtonText = "-", $2ndButtonText = "-", $3rdButtonText = "-", $Buttons_Count = 1 + Switch $Flag + Case 0 ;OK + $Buttons_Count = 1 + $1stButtonText = "OK" + Case 1 ;OK / Cancel + $Buttons_Count = 2 + $1stButtonText = "OK" + $2ndButtonText = "Cancel" + Case 2 ;Abort / Retry / Ignore + $Buttons_Count = 3 + $1stButtonText = "Abort" + $2ndButtonText = "Retry" + $3rdButtonText = "Ignore" + Case 3 ;Yes / NO / Cancel + $Buttons_Count = 3 + $1stButtonText = "Yes" + $2ndButtonText = "No" + $3rdButtonText = "Cancel" + Case 4 ;Yes / NO + $Buttons_Count = 2 + $1stButtonText = "Yes" + $2ndButtonText = "No" + Case 5 ; Retry / Cancel + $Buttons_Count = 2 + $1stButtonText = "Retry" + $2ndButtonText = "Cancel" + Case 6 ; Cancel / Retry / Continue + $Buttons_Count = 3 + $1stButtonText = "Cancel" + $2ndButtonText = "Retry" + $3rdButtonText = "Continue" + Case Else + $Buttons_Count = 1 + $1stButtonText = "OK" + EndSwitch + + If ($Buttons_Count = 1) And ($mWidth < 180) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 180px for the selected message style/flag.") + If ($Buttons_Count = 2) And ($mWidth < 240) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 240px for the selected message style/flag.") + If ($Buttons_Count = 3) And ($mWidth < 360) Then MsgBox(16, "MetroUDF", "Error: Messagebox width has to be at least 360px for the selected message style/flag.") + + ;HighDPI Support + Local $msgbDPI = _HighDPICheck() + If $HIGHDPI_SUPPORT Then + $mWidth = Round($mWidth * $gDPI) + Else + $Fontsize = ($Fontsize / $Font_DPI_Ratio) + EndIf + + Local $LabelSize = _StringSize($Text, $Fontsize, 400, 0, "Arial", $mWidth - (30 * $msgbDPI)) + Local $mHeight = 120 + ($LabelSize[3] / $msgbDPI) + Local $MsgBox_Form = _Metro_CreateGUI($Title, $mWidth / $msgbDPI, $mHeight, -1, -1, False, $ParentGUI) + $mHeight = $mHeight * $msgbDPI + GUICtrlCreateLabel(" " & $Title, 2 * $msgbDPI, 2 * $msgbDPI, $mWidth - (4 * $msgbDPI), 30 * $msgbDPI, 0x0200, 0x00100000) + GUICtrlSetBkColor(-1, _AlterBrightness($GUIThemeColor, 30)) + GUICtrlSetColor(-1, $FontThemeColor) + _GUICtrlSetFont(-1, 11, 600, 0, "Arial", 5) + GUICtrlCreateLabel($Text, 15 * $msgbDPI, 50 * $msgbDPI, $LabelSize[2], $LabelSize[3], -1, 0x00100000) + GUICtrlSetBkColor(-1, $GUIThemeColor) + GUICtrlSetColor(-1, $FontThemeColor) + GUICtrlSetFont(-1, $Fontsize, 400, 0, "Arial", 5) + + Local $1stButton_Left = (($mWidth / $msgbDPI) - ($Buttons_Count * 100) - (($Buttons_Count - 1) * 20)) / 2 + Local $1stButton_Left1 = ($mWidth - ($Buttons_Count * (100 * $msgbDPI)) - (($Buttons_Count - 1) * (20 * $msgbDPI))) / 2 + Local $2ndButton_Left = $1stButton_Left + 120 + Local $3rdButton_Left = $2ndButton_Left + 120 + + GUICtrlCreateLabel("", 2 * $msgbDPI, $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + GUICtrlCreateLabel("", $mWidth - $1stButton_Left1 + (2 * $msgbDPI), $mHeight - (53 * $msgbDPI), $1stButton_Left1 - (4 * $msgbDPI), (50 * $msgbDPI), -1, 0x00100000) + + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $1stButton = _Metro_CreateButton($1stButtonText, $1stButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + Local $2ndButton = _Metro_CreateButton($2ndButtonText, $2ndButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 2 Then GUICtrlSetState($2ndButton, 32) + Local $3rdButton = _Metro_CreateButton($3rdButtonText, $3rdButton_Left, ($mHeight / $msgbDPI) - 50, 100, 34, $ButtonBKColor, $ButtonTextColor) + If $Buttons_Count < 3 Then GUICtrlSetState($3rdButton, 32) + + ;Set default btn. + Switch $Flag + Case 0, 1, 5 + GUICtrlSetState($1stButton, 512) + Case 2, 4, 6 + GUICtrlSetState($2ndButton, 512) + Case 3 + GUICtrlSetState($3rdButton, 512) + Case Else + GUICtrlSetState($1stButton, 512) + EndSwitch + GUISetAccelerators($aAccelKeys, $MsgBox_Form) + + GUISetState(@SW_SHOW) + + If $Timeout <> 0 Then + $iMsgBoxTimeout = $Timeout + AdlibRegister("_iMsgBoxTimeout", 1000) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + If $Timeout <> 0 Then + If $iMsgBoxTimeout <= 0 Then + AdlibUnRegister("_iMsgBoxTimeout") + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1) + EndIf + EndIf + Local $nMsg = GUIGetMsg() + Switch $nMsg + Case -3, $1stButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $1stButtonText + Case $2ndButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $2ndButtonText + Case $3rdButton + _Metro_GUIDelete($MsgBox_Form) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $3rdButtonText + Case $cEnter + _Metro_GUIDelete($MsgBox_Form) + Local $ReturnText + Switch $Flag + Case 0, 1, 5 + $ReturnText = $1stButtonText + Case 2, 4, 6 + $ReturnText = $2ndButtonText + Case 3 + $ReturnText = $3rdButtonText + Case Else + $ReturnText = $1stButtonText + EndSwitch + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $ReturnText + EndSwitch + WEnd +EndFunc ;==>_Metro_MsgBox + + +#EndRegion Metro MsgBox=========================================================================================== + + +#Region Metro InputBox=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_InputBox +; Description ...: Creates a metro-style Inputbox. +; Syntax ........: _Metro_InputBox($Promt[, $Font_Size = 11[, $DefaultText = ""[, $PW = False[, $EnableEnterHotkey = True[, +; $ParentGUI = ""]]]]]) +; Parameters ....: $Promt - Promt for the user. +; $Font_Size - [optional] Fontsize of the prompt. Default is 11. (Font Segoe UI) +; $DefaultText - [optional] Default value for the input control. +; $PW - [optional] True/False - Hides the input text for password input. Default is False. +; $EnableEnterHotkey - [optional] Allows confirming the entered text using the Enter key. Default is True. +; $ParentGUI - [optional] Assigns a parent GUI. Default is "". +; Return values .: @error 1 (cancled) or the text entered by the user. +; =============================================================================================================================== +Func _Metro_InputBox($Promt, $Font_Size = 11, $DefaultText = "", $PW = False, $EnableEnterHotkey = True, $ParentGUI = "") + Local $Metro_Input, $Metro_Input_GUI + If $ParentGUI = "" Then + $Metro_Input_GUI = _Metro_CreateGUI($Promt, 460, 170, -1, -1, False) + Else + $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 460, 170, -1, -1, False, $ParentGUI) + EndIf + _Metro_SetGUIOption($Metro_Input_GUI, True) + GUICtrlCreateLabel($Promt, 3 * $gDPI, 3 * $gDPI, 454 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) + GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") + GUICtrlSetColor(-1, $FontThemeColor) + If $PW Then + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI, 32) + Else + $Metro_Input = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 429 * $gDPI, 28 * $gDPI) + EndIf + GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") + + GUICtrlSetState($Metro_Input, 256) + Local $cEnter = GUICtrlCreateDummy() + Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] + Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 110, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + GUICtrlSetState($Button_Continue, 512) + Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 230, 120, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") + + GUISetState(@SW_SHOW) + + If $EnableEnterHotkey Then + GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) + EndIf + + If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode + + While 1 + $input_nMsg = GUIGetMsg() + Switch $input_nMsg + Case -3, $Button_Cancel + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return SetError(1, 0, "") + Case $Button_Continue, $cEnter + Local $User_Input = GUICtrlRead($Metro_Input) + If Not ($User_Input = "") Then + _Metro_GUIDelete($Metro_Input_GUI) + If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode + Return $User_Input + EndIf + EndSwitch + WEnd +EndFunc ;==>_Metro_InputBox + +#EndRegion Metro InputBox=========================================================================================== + + + +#Region Metro Progressbar=========================================================================================== +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_CreateProgress +; Description ...: Creates a simple progressbar. +; Syntax ........: _Metro_CreateProgress($Left, $Top, $Width, $Height[, $EnableBorder = False[, $Backgroud_Color = $CB_Radio_Color[, +; $Progress_Color = $ButtonBKColor]]]) +; Parameters ....: $Left - Left pos. +; $Top - Top pos. +; $Width - Width. +; $Height - Height. +; $EnableBorder - [optional] Enables a 1px border from each side for the progressbar. Default is False. +; $Backgroud_Color - [optional] Background color. Default is $CB_Radio_Color. +; $Progress_Color - [optional] Progress color. Default is $ButtonBKColor. +; Return values .: Array containing basic information about the progressbar that is required to set the % progress. +; =============================================================================================================================== +Func _Metro_CreateProgress($Left, $Top, $Width, $Height, $EnableBorder = False, $Backgroud_Color = $CB_Radio_Color, $Progress_Color = $ButtonBKColor) + Local $Progress_Array[8] + + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Height = Round($Height * $gDPI) + EndIf + $Progress_Array[1] = $Width + $Progress_Array[2] = $Height + $Progress_Array[3] = "0xFF" & Hex($Backgroud_Color, 6) + $Progress_Array[4] = "0xFF" & Hex($Progress_Color, 6) + $Progress_Array[5] = StringReplace($CB_Radio_Hover_Color, "0x", "0xFF") + $Progress_Array[7] = $EnableBorder + + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress_Array[5], 2) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Width, $Height, $Progress_Array[3], 1, 5) + + ;Draw Progressbar border + If $EnableBorder Then + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Width, $Height, $ProgressBGPen) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + + ;Create bitmap handles and set graphics + $Progress_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) + $Progress_Array[6] = _iGraphicCreateBitmapHandle($Progress_Array[0], $Progress_Graphic) + + ;For GUI Resizing + GUICtrlSetResizing($Progress_Array[0], 768) + + Return $Progress_Array +EndFunc ;==>_Metro_CreateProgress + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_SetProgress +; Description ...: Sets the progress in % of a progressbar. +; Syntax ........: _Metro_SetProgress(Byref $Progress, $Percent) +; Parameters ....: $Progress - Array of the progressbar that has been returned by _Metro_CreateProgress function. +; $Percent - A value from 0-100. (In %) +; =============================================================================================================================== +Func _Metro_SetProgress(ByRef $Progress, $Percent) + ;Set Colors + Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2) + Local $ProgressBGBrush = _GDIPlus_BrushCreateSolid($Progress[4]) + + ;Create Graphics + Local $Progress_Graphic = _iGraphicCreate($Progress[1], $Progress[2], $Progress[3], 1, 5) + + ;Draw Progressbar + If $Percent > 100 Then $Percent = 100 + If $Progress[7] Then + Local $ProgressWidth = (($Progress[1] - 2) / 100) * $Percent + _GDIPlus_GraphicsDrawRect($Progress_Graphic[0], 0, 0, $Progress[1], $Progress[2], $ProgressBGPen) + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 1, 1, $ProgressWidth, $Progress[2] - 2, $ProgressBGBrush) + Else + Local $ProgressWidth = (($Progress[1]) / 100) * $Percent + _GDIPlus_GraphicsFillRect($Progress_Graphic[0], 0, 0, $ProgressWidth, $Progress[2], $ProgressBGBrush) + EndIf + + ;Release created objects + _GDIPlus_PenDispose($ProgressBGPen) + _GDIPlus_BrushDispose($ProgressBGBrush) + + ;Create bitmap handles + Local $SetProgress = _iGraphicCreateBitmapHandle($Progress[0], $Progress_Graphic) + _WinAPI_DeleteObject($Progress[6]) + + $Progress[6] = $SetProgress +EndFunc ;==>_Metro_SetProgress +#EndRegion Metro Progressbar=========================================================================================== + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddHSeperator +; Description ...: Adds a horizontal seperator line to the GUI +; Syntax ........: _Metro_AddHSeperator($Left, $Top, $Width, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Width - Width +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddHSeperator($Left, $Top, $Width, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Width = Round($Width * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Width, $Size) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 2 + 4 + 32 + 512) + Return $Seperator +EndFunc ;==>_Metro_AddHSeperator + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _Metro_AddVSeperator +; Description ...: Adds a vertical seperator line to the GUI +; Syntax ........: _Metro_AddVSeperator($Left, $Top, $Height, $Size[, $Color = $GUIBorderColor]) +; Parameters ....: $Left - x Position. +; $Top - y Position +; $Height - Height +; $Size - Size of the line +; $Color - [optional] Color of the line. Default is $GUIBorderColor. +; Return values .: Handle to the Seperator +; =============================================================================================================================== +Func _Metro_AddVSeperator($Left, $Top, $Height, $Size, $Color = $GUIBorderColor) + If $HIGHDPI_SUPPORT Then + $Left = Round($Left * $gDPI) + $Top = Round($Top * $gDPI) + $Height = Round($Height * $gDPI) + $Size = Round($Size * $gDPI) + EndIf + Local $Seperator = GUICtrlCreateLabel("", $Left, $Top, $Size, $Height) + GUICtrlSetBkColor(-1, $Color) + GUICtrlSetState(-1, 128) + GUICtrlSetResizing(-1, 32 + 64 + 256 + 2) + Return $Seperator +EndFunc ;==>_Metro_AddVSeperator + + + +Func _iAddHover($Button_ADD) + ;Try to get an unused index from the hover reg array + Local $HRS + For $i = 0 To UBound($iHoverReg) - 1 Step +1 + If $iHoverReg[$i][0] = "" Then + $HRS = $i + ExitLoop + EndIf + Next + If $HRS == "" Then ;If there is no unused index, then redim array + $HRS = UBound($iHoverReg) + ReDim $iHoverReg[$HRS + 1][16] + EndIf + For $i = 0 To 15 + $iHoverReg[$HRS][$i] = $Button_ADD[$i] + Next + Return $HRS +EndFunc ;==>_iAddHover + +#EndRegion HoverEffects=========================================================================================== + +#Region Required_Funcs=========================================================================================== +Func _iGraphicCreate($hWidth, $hHeight, $BackgroundColor = 0, $Smoothingmode = 4, $TextCleartype = 0) + Local $Picture_Array[2] + $Picture_Array[1] = _GDIPlus_BitmapCreateFromScan0($hWidth, $hHeight, $GDIP_PXF32ARGB) + $Picture_Array[0] = _GDIPlus_ImageGetGraphicsContext($Picture_Array[1]) + _GDIPlus_GraphicsSetSmoothingMode($Picture_Array[0], $Smoothingmode) + _GDIPlus_GraphicsSetTextRenderingHint($Picture_Array[0], $TextCleartype) + If $BackgroundColor <> 0 Then _GDIPlus_GraphicsClear($Picture_Array[0], $BackgroundColor) + Return $Picture_Array +EndFunc ;==>_iGraphicCreate + +Func _iGraphicCreateBitmapHandle($hPicture, $Picture_Array, $hVisible = True) + Local $cBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Picture_Array[1]) + If $hVisible Then _WinAPI_DeleteObject(GUICtrlSendMsg($hPicture, 0x0172, 0, $cBitmap)) + _GDIPlus_GraphicsDispose($Picture_Array[0]) + _GDIPlus_BitmapDispose($Picture_Array[1]) + Return $cBitmap +EndFunc ;==>_iGraphicCreateBitmapHandle + +Func GetCurrentGUI() ;Thanks @binhnx + Local $dummyCtrl = GUICtrlCreateLabel("", 0, 0, 0, 0) + Local $hCurrent = _WinAPI_GetParent(GUICtrlGetHandle($dummyCtrl)) + GUICtrlDelete($dummyCtrl) + Return $hCurrent +EndFunc ;==>GetCurrentGUI + +Func _HighDPICheck() + If $HIGHDPI_SUPPORT Then + Return $gDPI + Else + Return 1 + EndIf +EndFunc ;==>_HighDPICheck + +Func cAngle($x1, $y1, $Ang, $Length) + Local $Return[2] + $Return[0] = $x1 + ($Length * Sin($Ang / 180 * 3.14159265358979)) + $Return[1] = $y1 + ($Length * Cos($Ang / 180 * 3.14159265358979)) + Return $Return +EndFunc ;==>cAngle + +Func _GUICtrlSetFont($icontrolID, $iSize, $iweight = 400, $iattribute = 0, $sfontname = "", $iquality = 5) + If $HIGHDPI_SUPPORT Then + GUICtrlSetFont($icontrolID, $iSize, $iweight, $iattribute, $sfontname, $iquality) + Else + GUICtrlSetFont($icontrolID, $iSize / $Font_DPI_Ratio, $iweight, $iattribute, $sfontname, $iquality) + EndIf +EndFunc ;==>_GUICtrlSetFont + +Func _GetFontDPI_Ratio() + Local $a1[3] + Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 + Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) + Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) + $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) + $iDPI = $aRet[0] + Select + Case $iDPI = 0 + $iDPI = 96 + $iDPIRat = 94 + Case $iDPI < 84 + $iDPIRat = $iDPI / 105 + Case $iDPI < 121 + $iDPIRat = $iDPI / 96 + Case $iDPI < 145 + $iDPIRat = $iDPI / 95 + Case Else + $iDPIRat = $iDPI / 94 + EndSelect + $a1[0] = 2 + $a1[1] = $iDPI + $a1[2] = $iDPIRat + Return $a1 +EndFunc ;==>_GetFontDPI_Ratio + + +Func _iMsgBoxTimeout() + $iMsgBoxTimeout -= 1 +EndFunc ;==>_iMsgBoxTimeout + +Func _ReduceMemory($i_PID = -1) + Local $ai_Return + If $i_PID <> -1 Then + Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) + DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) + Else + $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) + EndIf + Return $ai_Return[0] +EndFunc ;==>_ReduceMemory + +Func _AlterBrightness($StartCol, $adjust, $Select = 7) + Local $red = $adjust * (BitAND(1, $Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 + Local $grn = $adjust * (BitAND(2, $Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 + Local $blu = $adjust * (BitAND(4, $Select) <> 0) + BitAND($StartCol, 0x0000FF) + Return "0x" & Hex(String(limitCol($red) * 0x10000 + limitCol($grn) * 0x100 + limitCol($blu)), 6) +EndFunc ;==>_AlterBrightness +Func limitCol($cc) + If $cc > 255 Then Return 255 + If $cc < 0 Then Return 0 + Return $cc +EndFunc ;==>limitCol + + +Func _CreateBorder($mGUI, $guiW, $guiH, $bordercolor = 0xFFFFFF) + Local $cLeft, $cRight, $cTop, $cBottom + Local $gID = _iGetGUIID($mGUI) + + $cTop = GUICtrlCreateLabel("", 0, 0, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 544) + GUICtrlSetState(-1, 128) + $cBottom = GUICtrlCreateLabel("", 0, $guiH - 1, $guiW, 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 576) + GUICtrlSetState(-1, 128) + $cLeft = GUICtrlCreateLabel("", 0, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 2) + GUICtrlSetState(-1, 128) + $cRight = GUICtrlCreateLabel("", $guiW - 1, 1, 1, $guiH - 1) + GUICtrlSetColor(-1, $bordercolor) + GUICtrlSetBkColor(-1, $bordercolor) + GUICtrlSetResizing(-1, 256 + 4) + GUICtrlSetState(-1, 128) + If $gID <> "" Then + $iGUI_LIST[$gID][12] = $cTop + $iGUI_LIST[$gID][13] = $cBottom + $iGUI_LIST[$gID][14] = $cLeft + $iGUI_LIST[$gID][15] = $cRight + EndIf + +EndFunc ;==>_CreateBorder + +Func _WinPos($ParentWin, $Win_Wi, $Win_Hi) + Local $Win_SetPos[2] + $Win_SetPos[0] = "-1" + $Win_SetPos[1] = "-1" + Local $Win_POS = WinGetPos($ParentWin) + If Not @error Then + $Win_SetPos[0] = ($Win_POS[0] + (($Win_POS[2] - $Win_Wi) / 2)) + $Win_SetPos[1] = ($Win_POS[1] + (($Win_POS[3] - $Win_Hi) / 2)) + EndIf + Return $Win_SetPos +EndFunc ;==>_WinPos + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GDIPlus_GraphicsGetDPIRatio +; Description ...: +; Syntax ........: _GDIPlus_GraphicsGetDPIRatio([$iDPIDef = 96]) +; Parameters ....: $iDPIDef - [optional] An integer value. Default is 96. +; Return values .: None +; Author ........: UEZ +; Link ..........: http://www.autoitscript.com/forum/topic/159612-dpi-resolution-problem/?hl=%2Bdpi#entry1158317 +; Example .......: No +; =============================================================================================================================== +Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) + _GDIPlus_Startup() + Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) + If @error Then Return SetError(1, @extended, 0) + Local $aResult + #forcedef $__g_hGDIPDll, $ghGDIPDll + $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) + + If @error Then Return SetError(2, @extended, 0) + Local $iDPI = $aResult[2] + _GDIPlus_GraphicsDispose($hGfx) + _GDIPlus_Shutdown() + Return $iDPI / $iDPIDef +EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio +#EndRegion Required_Funcs=========================================================================================== + + + +;========================================================================NEW================================================================================= +Func _iHoverOn($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 5, 7 + If $iHoverReg[$vData][2] Then ;checkboxes and radios + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][8])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][6])) ;Default hover image + EndIf + Case "6" + If $iHoverReg[$vData][2] Then ;toggles + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][14])) ;Checked hover image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][13])) ;Default hover image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][6])) ;Button hover image + EndSwitch +EndFunc ;==>_iHoverOn + + + +Func _iHoverOff($idCtrl, $vData) + Switch $iHoverReg[$vData][3] + Case 0, 3, 4, 8, 9, 10 ;buttons + If WinActive($iHoverReg[$vData][15]) Then + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][7])) ;Inactive state + EndIf + Case 5, 7 ;checkboxes and radios + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][7])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case "6" ;Toggles + If $iHoverReg[$vData][2] Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][12])) ;Checked image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$vData][0], 0x0172, 0, $iHoverReg[$vData][5])) ;Default image + EndIf + Case Else + _WinAPI_DeleteObject(GUICtrlSendMsg($idCtrl, 0x0172, 0, $iHoverReg[$vData][5])) ;Button default image + EndSwitch +EndFunc ;==>_iHoverOff + + + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iGetCtrlHandlebyType +; Description ...: Internal function to get the handle of a control button using the GUI handle and Type +; =============================================================================================================================== +Func _iGetCtrlHandlebyType($Type, $hWnd) + For $i = 0 To UBound($iHoverReg) - 1 + If ($Type = $iHoverReg[$i][3]) And ($hWnd = $iHoverReg[$i][15]) Then Return $iHoverReg[$i][0] + Next + Return False +EndFunc ;==>_iGetCtrlHandlebyType + + +;====================================================================== Borderless UDF ========================================================================== + +Func _iEffectControl($hWnd, $imsg, $wParam, $lParam, $iID, $gID) + Switch $imsg + Case 0x00AF, 0x0085, 0x00AE, 0x0083, 0x0086 ;Prevent default non-client arena from drawing for borderless GUI effects + Return -1 + Case 0x031A ;Prevent rounded corners when theme changes + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(2, 4)) + _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $SWP_FRAMECHANGED + $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOREDRAW) + DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4)) + Return 0 + Case 0x0005 ;Maximize/Restore effects -> 2 = Maximized, 0 = Restored & Fix maximized position + If Not $iGUI_LIST[$gID][11] Then ;If not in fullscreen mode + Switch $wParam + Case 2 ;window maximized + Local $wSize = _GetDesktopWorkArea($hWnd) + Local $wPos = WinGetPos($hWnd) + WinMove($hWnd, "", $wPos[0] - 1, $wPos[1] - 1, $wSize[2], $wSize[3]) ;Fix Maximized pos + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide max button and show restore button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + Case 4 + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndSwitch + EndIf + Next + Case 0 ;window restored/pos change + For $iC = 0 To UBound($iHoverReg) - 1 ;Hide restore button and show max button + If $hWnd = $iHoverReg[$iC][15] Then + Switch $iHoverReg[$iC][3] + Case 3 + If Not $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 16) + $iHoverReg[$iC][8] = True + EndIf + Case 4 + If $iHoverReg[$iC][8] Then + GUICtrlSetState($iHoverReg[$iC][0], 32) + $iHoverReg[$iC][8] = False + EndIf + EndSwitch + EndIf + Next + EndSwitch + EndIf + Case 0x0024 ;Prevent Windows from misplacing the GUI when maximized. (Due to missing borders.) and set minimum window size. + Local $tMinMax = DllStructCreate("int;int;int;int;int;int;int;int;int;dword", $lParam) + Local $WrkSize = _GetDesktopWorkArea($hWnd) + DllStructSetData($tMinMax, 3, $WrkSize[2]) + DllStructSetData($tMinMax, 4, $WrkSize[3]) + DllStructSetData($tMinMax, 5, $WrkSize[0] + 1) + DllStructSetData($tMinMax, 6, $WrkSize[1] + 1) + ;Set win min size + DllStructSetData($tMinMax, 7, $iGUI_LIST[$gID][3]) + DllStructSetData($tMinMax, 8, $iGUI_LIST[$gID][4]) + Case 0x0084 ;Set mouse cursor for resizing etc. / Allow the upper GUI (28 pixel from top) to act as a control bar (doubleclick to maximize, move gui around..) + If $iGUI_LIST[$gID][2] And Not $iGUI_LIST[$gID][11] Then ;If resize is allowed and not in fullscreen mode + Local $iSide = 0, $iTopBot = 0, $Cur + Local $wPos = WinGetPos($hWnd) + Local $curInf = GUIGetCursorInfo($hWnd) + ;Check if Mouse is over Border, Margin = 5 + If Not @error Then + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + Else + $Cur = 0 + EndIf + If WinGetState($hWnd) <> 47 Then ;If not maximized + ;Set resize cursor and return the correct $HT for gui resizing + Local $Return_HT = 2, $Set_Cur = 2 + Switch $Cur + Case 1 + $Set_Cur = 13 + $Return_HT = 10 + Case 2 + $Set_Cur = 13 + $Return_HT = 11 + Case 3 + $Set_Cur = 11 + $Return_HT = 12 + Case 4 + $Set_Cur = 12 + $Return_HT = 13 + Case 5 + $Set_Cur = 10 + $Return_HT = 14 + Case 6 + $Set_Cur = 11 + $Return_HT = 15 + Case 7 + $Set_Cur = 10 + $Return_HT = 16 + Case 8 + $Set_Cur = 12 + $Return_HT = 17 + EndSwitch + GUISetCursor($Set_Cur, 1) + If $Return_HT <> 2 Then Return $Return_HT + EndIf + ;Return HTCAPTION if mouse is in the non-client area (28px from top) for doubleclick + drag + If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $wPos[1]) < (28 * $gDPI) Then Return $HTCAPTION + EndIf + Case 0x0201 ;Allow moving the GUI using LBUTTON down+drag + If $iGUI_LIST[$gID][1] And Not $iGUI_LIST[$gID][11] And Not (WinGetState($hWnd) = 47) Then + Local $aCurInfo = GUIGetCursorInfo($hWnd) + If ($aCurInfo[4] = 0) Then ; Mouse not over a control + ;Allow drag + DllCall("user32.dll", "int", "ReleaseCapture") + DllCall("user32.dll", "long", "SendMessageA", "hwnd", $hWnd, "int", 0x00A1, "int", 2, "int", 0) + Return 0 + EndIf + EndIf + Case 0x001C ;Set Active/Inactive color for control buttons when the app is being activated/deactivated + For $iC = 0 To UBound($iHoverReg) - 1 + Switch $iHoverReg[$iC][3] + Case 0, 3, 4, 8, 9, 10 + If $wParam Then + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][5])) ;Button default image + Else + _WinAPI_DeleteObject(GUICtrlSendMsg($iHoverReg[$iC][0], 0x0172, 0, $iHoverReg[$iC][7])) + EndIf + EndSwitch + Next + Case 0x0020 ;Reset cursor back to defaul to prevent from resize cursors getting stuck + If MouseGetCursor() <> 2 Then + Local $curInf = GUIGetCursorInfo($hWnd) + If Not @error And $curInf[4] <> 0 Then + Local $iSide = 0, $iTopBot = 0, $Cur = 0 + Local $wPos = WinGetPos($hWnd) + If $curInf[0] < $bMarg Then $iSide = 1 + If $curInf[0] > $wPos[2] - $bMarg Then $iSide = 2 + If $curInf[1] < $bMarg Then $iTopBot = 3 + If $curInf[1] > $wPos[3] - $bMarg Then $iTopBot = 6 + $Cur = $iSide + $iTopBot + If $Cur = 0 Then + If $curInf[4] <> $iGUI_LIST[$gID][12] And $curInf[4] <> $iGUI_LIST[$gID][13] And $curInf[4] <> $iGUI_LIST[$gID][14] And $curInf[4] <> $iGUI_LIST[$gID][15] Then ;If mouse not over border labels + GUISetCursor(2, 0, $hWnd) + EndIf + EndIf + EndIf + EndIf + EndSwitch + + Return DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $imsg, "wparam", $wParam, "lparam", $lParam)[0] +EndFunc ;==>_iEffectControl + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _iMExit +; Description ...: Removes all WindowSubclasses of all GUIs before exiting, in order to prevent a program crash +; =============================================================================================================================== +Func _iMExit() + For $i_HR = 0 To UBound($iGUI_LIST) - 1 Step +1 + _Metro_GUIDelete($iGUI_LIST[$i_HR][0]) + Next + DllCallbackFree($m_hDll) + _GDIPlus_Shutdown() +EndFunc ;==>_iMExit + +; #FUNCTION# ==================================================================================================================== +; Name ..........: _GetDesktopWorkArea +; Description ...: Calculate the desktop workarea for a specific window to maximize it. Supports multi display and taskbar detection. +; Syntax ........: _GetDesktopWorkArea($hWnd) +; Parameters ....: $hWnd - Handle to the window. +; Return values .: Array in following format: +; : [0] = X-Pos for maximizing +; : [1] = Y-Pos for maximizing +; : [2] = Max. Width +; : [3] = Max. Height +; Author ........: BB_19 +; Note ..........: The x/y position is not the real position of the window if you have multi display. It is just for setting the maximize info for WM_GETMINMAXINFO +; =============================================================================================================================== +Func _GetDesktopWorkArea($hWnd, $FullScreen = False) + Local $MonSizePos[4], $MonNumb = 1 + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + $MonSizePos[2] = @DesktopWidth + $MonSizePos[3] = @DesktopHeight + ;Get Monitors + Local $aPos, $MonList = _WinAPI_EnumDisplayMonitors() + If @error Then Return $MonSizePos + + ReDim $MonList[$MonList[0][0] + 1][5] + For $i = 1 To $MonList[0][0] + $aPos = _WinAPI_GetPosFromRect($MonList[$i][1]) + For $j = 0 To 3 + $MonList[$i][$j + 1] = $aPos[$j] + Next + Next + + ;Check on which monitor our window is + Local $GUI_Monitor = _WinAPI_MonitorFromWindow($hWnd) + ;Check on which monitor the taskbar is + Local $TaskbarMon = _WinAPI_MonitorFromWindow(WinGetHandle("[CLASS:Shell_TrayWnd]")) + ;Write the width and height info of the correct monitor into an array + For $iM = 1 To $MonList[0][0] Step +1 + If $MonList[$iM][0] = $GUI_Monitor Then + If $FullScreen Then + $MonSizePos[0] = $MonList[$iM][1] + $MonSizePos[1] = $MonList[$iM][2] + Else + $MonSizePos[0] = 0 + $MonSizePos[1] = 0 + EndIf + $MonSizePos[2] = $MonList[$iM][3] + $MonSizePos[3] = $MonList[$iM][4] + $MonNumb = $iM + EndIf + Next + ;Check if Taskbar autohide is enabled, if so then we will remove 1px from the correct side so that the taskbar will reapear when moving mouse to the side + Local $TaskBarAH = DllCall("shell32.dll", "int", "SHAppBarMessage", "int", 0x00000004, "ptr*", 0) + If Not @error Then + $TaskBarAH = $TaskBarAH[0] + Else + $TaskBarAH = 0 + EndIf + ;Check if Taskbar is on this Monitor, if so, then recalculate the position, max. width and height of the WorkArea + If $TaskbarMon = $GUI_Monitor Then + Local $TaskBarPos = WinGetPos("[CLASS:Shell_TrayWnd]") + If @error Then Return $MonSizePos + If $FullScreen Then Return $MonSizePos + ;Win 7 classic theme compatibility + If ($TaskBarPos[0] = $MonList[$MonNumb][1] - 2) Or ($TaskBarPos[1] = $MonList[$MonNumb][2] - 2) Then + $TaskBarPos[0] += 2 + $TaskBarPos[1] += 2 + $TaskBarPos[2] -= 4 + $TaskBarPos[3] -= 4 + EndIf + ;Recalc width/height and pos + If $TaskBarPos[2] = $MonSizePos[2] Then + If $TaskBarAH = 1 Then + If ($TaskBarPos[1] > 0) Then + $MonSizePos[3] -= 1 + Else + $MonSizePos[1] += 1 + $MonSizePos[3] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[3] = $MonSizePos[3] - $TaskBarPos[3] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[1] = $TaskBarPos[3] + Else + If $TaskBarAH = 1 Then + If ($TaskBarPos[0] > 0) Then + $MonSizePos[2] -= 1 + Else + $MonSizePos[0] += 1 + $MonSizePos[2] -= 1 + EndIf + Return $MonSizePos + EndIf + $MonSizePos[2] = $MonSizePos[2] - $TaskBarPos[2] + If ($TaskBarPos[0] = $MonList[$MonNumb][1]) And ($TaskBarPos[1] = $MonList[$MonNumb][2]) Then $MonSizePos[0] = $TaskBarPos[2] + EndIf + EndIf + Return $MonSizePos +EndFunc ;==>_GetDesktopWorkArea + +Func _iGetGUIID($mGUI) + For $iG = 0 To UBound($iGUI_LIST) - 1 + If $iGUI_LIST[$iG][0] = $mGUI Then + Return $iG + EndIf + Next + Return SetError(1, 0, "") ; +EndFunc ;==>_iGetGUIID + +Func _iFullscreenToggleBtn($idCtrl, $hWnd) + If $ControlBtnsAutoMode Then _Metro_FullscreenToggle($hWnd) +EndFunc ;==>_iFullscreenToggleBtn + diff --git a/source/Include/MetroThemes.au3 b/source/Include/MetroThemes.au3 new file mode 100644 index 0000000..fd4704a --- /dev/null +++ b/source/Include/MetroThemes.au3 @@ -0,0 +1,259 @@ +#include-once +#cs ---------------------------------------------------------------------------- + Author: BB_19 + Material Themes for MetroGUI UDF + If you want to create your own themes, check out flatcolors.net, you can find there many random material/flat colors :) +#ce ---------------------------------------------------------------------------- + +;#Set Default Theme +Global $GUIThemeColor = "0x13161C" ; GUI Background Color +Global $FontThemeColor = "0xFFFFFF" ; Font Color +Global $GUIBorderColor = "0x2D2D2D" ; GUI Border Color +Global $ButtonBKColor = "0x00796b" ; Metro Button BacKground Color +Global $ButtonTextColor = "0xFFFFFF" ; Metro Button Text Color +Global $CB_Radio_Color = "0xFFFFFF" ;Checkbox and Radio Color (Box/Circle) +Global $GUI_Theme_Name = "DarkTealV2" ;Theme Name (For internal usage) +Global $CB_Radio_Hover_Color = "0xD8D8D8" ; Checkbox and Radio Hover Color (Box/Circle) +Global $CB_Radio_CheckMark_Color = "0x1a1a1a" ; Checkbox and Radio checkmark color + +Func _SetTheme($ThemeSelect = "DarkTeal") + $GUI_Theme_Name = $ThemeSelect + Switch ($ThemeSelect) + Case "LightTeal" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTeal" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkTealV2" + $GUIThemeColor = "0x13161C" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x35635B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkRuby" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x712043" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightTeal" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x336058" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightCyan" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x0D5C63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnightBlue" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x1A4F70" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkMidnight" + $GUIThemeColor = "0x0A0D16" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x3C4D66" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlue" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkBlueV2" + $GUIThemeColor = "0x040D11" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x303030" + $ButtonBKColor = "0x1E648C" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightBlue" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x244E80" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightCyan" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkCyan" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00838f" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGray" + $GUIThemeColor = "0xcccccc" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x3F5863" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightGreen" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x2E7D32" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreen" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGreenV2" + $GUIThemeColor = "0x061319" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x242B47" + $ButtonBKColor = "0x5E8763" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightRed" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xc62828" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkGray" + $GUIThemeColor = "0x1B2428" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x4F6772" + $ButtonBKColor = "0x607D8B" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkAmber" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xffa000" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightOrange" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xBC5E05" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkOrange" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0xC76810" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPurple" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "DarkPurple" + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x512DA8" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case "LightPink" + $GUIThemeColor = "0xD7D7D7" + $FontThemeColor = "0x000000" + $GUIBorderColor = "0xD8D8D8" + $ButtonBKColor = "0xE91E63" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xE8E8E8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + Case Else + ConsoleWrite("Metro-UDF-Error: Theme not found, using default theme." & @CRLF) + $GUIThemeColor = "0x191919" + $FontThemeColor = "0xFFFFFF" + $GUIBorderColor = "0x2D2D2D" + $ButtonBKColor = "0x00796b" + $ButtonTextColor = "0xFFFFFF" + $CB_Radio_Color = "0xFFFFFF" + $CB_Radio_Hover_Color = "0xD8D8D8" + $CB_Radio_CheckMark_Color = "0x1a1a1a" + $GUI_Theme_Name = "DarkTealV2" + EndSwitch +EndFunc ;==>_SetTheme diff --git a/source/Include/MetroUDF-Required/SSCtrlHover.au3 b/source/Include/MetroUDF-Required/SSCtrlHover.au3 new file mode 100644 index 0000000..eb284f0 --- /dev/null +++ b/source/Include/MetroUDF-Required/SSCtrlHover.au3 @@ -0,0 +1,495 @@ +;====================================== +;~ Author : binhnx +;~ Created : 2014/10/20 +;====================================== +;~ Modified : BB_19 +;~ Last modified : 2017/10/07 +;====================================== + +#include-once +#include +#include +Local $_cHvr_aData[0] + + +Local Const $_cHvr_HDLLCOMCTL32 = _WinAPI_LoadLibrary('comctl32.dll') +Assert($_cHvr_HDLLCOMCTL32 <> 0, 'This UDF requires comctl32.dll') +Local Const $_cHvr_PDEFSUBCLASSPROC = _WinAPI_GetProcAddress($_cHvr_HDLLCOMCTL32, 'DefSubclassProc') +Local Const $_cHvr_PINTERNALSUBCLASS_DLL = DllCallbackRegister('_cHvr_iProc', 'NONE', 'HWND;UINT;WPARAM;LPARAM;DWORD') +Local Const $_cHvr_PINTERNALSUBCLASS = DllCallbackGetPtr($_cHvr_PINTERNALSUBCLASS_DLL) + +OnAutoItExitRegister("_cHvr_Finalize") +Local Const $_cHvr_TSUBCLASSEXE = Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86') +Local Const $_cHvr_HEXECUTABLEHEAP = DllCall('kernel32.dll', 'HANDLE', 'HeapCreate', 'DWORD', 0x00040000, 'ULONG_PTR', 0, 'ULONG_PTR', 0)[0] +Assert($_cHvr_HEXECUTABLEHEAP <> 0, 'Failed to create executable heap object') +Local Const $_cHvr_PSUBCLASSEXE = _cHvr_ExecutableFromStruct(Call(@AutoItX64 ? '_cHvr_CSCP_X64' : '_cHvr_CSCP_X86')) + + +Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') + Local $hWnd = GUICtrlGetHandle($idCtrl) + If (Not (IsHWnd($hWnd))) Then Return SetError(1, 0, -1) + Local $nIndex = _cHvr_GetNewIndex($hWnd) + Local $aData[13] + $aData[0] = $hWnd;Control Hwnd + $aData[1] = $idCtrl; Control handle + $aData[3] = $fnHovOff;Hover Off func + $aData[4] = $HoverData;Hover Off Data + $aData[5] = $fnHoverOn;Hover ON func + $aData[6] = $HoverData;Hover ON Data + $aData[7] = $fnRightClick;RClick func + $aData[8] = $ClickData; click data + $aData[9] = $fnClick;Click func + $aData[10] = $ClickData; click data + $aData[11] = $fnDblClk;DB click func + $aData[12] = $ClickData;DB click data + $_cHvr_aData[$nIndex] = $aData + _WinAPI_SetWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd, $nIndex) + Return $nIndex +EndFunc ;==>_cHvr_Register + +Func _cHvr_iProc($hWnd, $uMsg, $wParam, $lParam, $cIndex) + Switch $uMsg + Case 0x0200;Hover + GUISetCursor(2, 1) + _cHvr_cMove($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0201;Leftclick + _cHvr_cDown($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0202 + _cHvr_cUp($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Return False + Case 0x0203;Doubleclick + _cHvr_cDblClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0204;Rightclick + _cHvr_cRightClk($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x02A3;Hover leave + _cHvr_cLeave($_cHvr_aData[$cIndex], $hWnd, $uMsg, $wParam, $lParam) + Case 0x0082;Deleted + _cHvr_UnRegisterInternal($cIndex, $hWnd) + EndSwitch + Return True +EndFunc ;==>_cHvr_iProc + +Func _cHvr_cDown(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _WinAPI_SetCapture($hWnd) + _cHvr_CallFunc($aCtrlData, 9) +EndFunc ;==>_cHvr_cDown + +Func _cHvr_cMove(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + Local $bIn = _cHvr_IsInClient($hWnd, $lParam) + If Not $aCtrlData[2] Then + If $bIn Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 9) + EndIf + Else + If Not $bIn Then + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) + EndIf + EndIf + ElseIf Not $aCtrlData[2] Then + $aCtrlData[2] = 1 + _cHvr_CallFunc($aCtrlData, 5) + Local $tTME = DllStructCreate('DWORD;DWORD;HWND;DWORD') + DllStructSetData($tTME, 1, DllStructGetSize($tTME)) + DllStructSetData($tTME, 2, 2) ;$TME_LEAVE + DllStructSetData($tTME, 3, $hWnd) + DllCall('user32.dll', 'BOOL', 'TrackMouseEvent', 'STRUCT*', $tTME) + EndIf +EndFunc ;==>_cHvr_cMove + +Func _cHvr_cUp(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + Local $lRet = _WinAPI_DefSubclassProc($hWnd, $uMsg, $wParam, $lParam) + If (_WinAPI_GetCapture() = $hWnd) Then + _WinAPI_ReleaseCapture() + If _cHvr_IsInClient($hWnd, $lParam) Then + _cHvr_CallFunc($aCtrlData, 9) + EndIf + EndIf + Return $lRet +EndFunc ;==>_cHvr_cUp + +Func _cHvr_cDblClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 11) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cRightClk(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + _cHvr_CallFunc($aCtrlData, 7) +EndFunc ;==>_cHvr_cDblClk + +Func _cHvr_cLeave(ByRef $aCtrlData, $hWnd, $uMsg, ByRef $wParam, ByRef $lParam) + $aCtrlData[2] = 0 + _cHvr_CallFunc($aCtrlData, 3) +EndFunc ;==>_cHvr_cLeave + +Func _cHvr_CallFunc(ByRef $aCtrlData, $iCallType) + Call($aCtrlData[$iCallType], $aCtrlData[1], $aCtrlData[$iCallType + 1]) +EndFunc ;==>_cHvr_CallFunc + +Func _cHvr_ArrayPush(ByRef $aStackArr, Const $vSrc1 = Default, Const $vSrc2 = Default, Const $vSrc3 = Default, Const $vSrc4 = Default, Const $vSrc5 = Default) + While (UBound($aStackArr) < ($aStackArr[0] + @NumParams)) + ReDim $aStackArr[UBound($aStackArr) * 2] + WEnd + + If Not ($vSrc1 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc1 + EndIf + If Not ($vSrc2 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc2 + EndIf + If Not ($vSrc3 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc3 + EndIf + If Not ($vSrc4 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc4 + EndIf + If Not ($vSrc5 = Default) Then + $aStackArr[0] += 1 + $aStackArr[$aStackArr[0]] = $vSrc5 + EndIf +EndFunc ;==>_cHvr_ArrayPush + +Func _cHvr_IsInClient($hWnd, $lParam) + Local $iX = BitShift(BitShift($lParam, -16), 16) + Local $iY = BitShift($lParam, 16) + Local $aSize = WinGetClientSize($hWnd) + Return Not ($iX < 0 Or $iY < 0 Or $iX > $aSize[0] Or $iY > $aSize[1]) +EndFunc ;==>_cHvr_IsInClient + +Func _cHvr_CSCP_X86() ;Create Subclass Process x86 + ; $hWnd HWND size: 4 ESP+4 EBP+8 + ; $uMsg UINT size: 4 ESP+8 EBP+12 + ; $wParam WPARAM size: 4 ESP+12 EBP+16 + ; $lParam LPARAM size: 4 ESP+16 EBP+20 + ; $uIdSubclass UINT_PTR size: 4 ESP+20 EBP+24 + ; $dwRefData DWORD_PTR size: 4 ESP+24 EBP+28 Total: 24 + + ; NERVER FORGET ADDING align 1 OR YOU WILL SPEND HOURS TO FIND WHAT CAUSE 0xC0000005 Access Violation + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; Func ; __stdcall + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x55) ;push ebp + _cHvr_ArrayPush($aOpCode, 0x8B, 0xEC) ;mov ebp, esp + + ; Save un-modified params to nv register + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+16] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x5D, 16) ;8b 5d 10 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov esi, DWORD PTR [ebp+12] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x75, 12) ;8b 75 0c + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ebx, DWORD PTR [ebp+20] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x7D, 20) ;8b 7d 14 + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x82) ;81 fe 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp esi, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFE, 0x2A3) ;81 fe a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;BYTE;' ;lea eax, DWORD PTR [esi-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x86, -0x200) ;8d 86 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + + ; :WndProcInternal (HWND, UINT, WPARAM, LPARAM, DWORD) + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov ecx, DWORD PTR [ebp+28] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x4D, 28) ;8b 4d 1c + $sExe &= 'BYTE;BYTE;BYTE;' ;mov edx, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x55, 8) ;8b 55 08 + $sExe &= 'BYTE;' ;push ecx + _cHvr_ArrayPush($aOpCode, 0x51) ;51 + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push edx + _cHvr_ArrayPush($aOpCode, 0x52) ;52 + + ; Call + $sExe &= 'BYTE;PTR;' ;mov eax, _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PINTERNALSUBCLASS) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;' ;test eax, eax + _cHvr_ArrayPush($aOpCode, 0x85, 0xC0) ;85 c0 + $sExe &= 'BYTE;BYTE;' ;jz short Return + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $aOpCode[$nElemOffset[2]] = $nAddrOffset[3] - $nAddrOffset[2] + + ; Prepare stack + $sExe &= 'BYTE;BYTE;BYTE;' ;mov eax, DWORD PTR [ebp+8] + _cHvr_ArrayPush($aOpCode, 0x8B, 0x45, 8) + $sExe &= 'BYTE;' ;push edi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + $sExe &= 'BYTE;' ;push ebx + _cHvr_ArrayPush($aOpCode, 0x53) ;53 + $sExe &= 'BYTE;' ;push esi + _cHvr_ArrayPush($aOpCode, 0x56) ;56 + $sExe &= 'BYTE;' ;push eax + _cHvr_ArrayPush($aOpCode, 0x50) ;50 + + ;Call + $sExe &= 'BYTE;PTR;' ;mov eax,COMCTL32.DefSubclassProc + _cHvr_ArrayPush($aOpCode, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' ;call near eax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff 75 8 + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + + ; :Return + $aOpCode[$nElemOffset[3]] = $nAddrOffset[4] - $nAddrOffset[3] + + ; Restore nv-register + $sExe &= 'BYTE;BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0x5F) ;pop edi + _cHvr_ArrayPush($aOpCode, 0x5E) ;pop esi + _cHvr_ArrayPush($aOpCode, 0x5B) ;pop ebx + + + ; EndFunc + $sExe &= 'BYTE;BYTE;BYTE;WORD' + _cHvr_ArrayPush($aOpCode, 0x5D) ;pop ebp + _cHvr_ArrayPush($aOpCode, 0xC2, 24) ;ret 24 + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X86 + +Func _cHvr_CSCP_X64() ;Create Subclass Process x64 + ; First four INT and UINT has size = 8 instead of 4 because they are stored in RCX, RDX, R8, R9 + ; $hWnd HWND size: 8 RCX RSP+8 + ; $uMsg UINT size: 8 EDX RSP+16 + ; $wParam WPARAM size: 8 R8 RSP+24 + ; $lParam LPARAM size: 8 R9 RSP+32 + ; $uIdSubclass UINT_PTR size: 8 RSP+40 + ; $dwRefData DWORD_PTR size: 8 RSP+48 Total: 48 + Local $sExe = 'align 1;' + Local $aOpCode[100] + $aOpCode[0] = 0 + Local $nAddrOffset[5] + Local $nElemOffset[5] + + ; If ($uMsg = 0x0082) Then Goto WndProcInternal ;WM_NCDESTROY + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x82 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x82) ;81 fa 82 00 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[0] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[0] = $aOpCode[0] + + ; ElseIf ($uMsg = 0x02A3) Then Goto WndProcInternal ;WM_MOUSELEAVE + $sExe &= 'BYTE;BYTE;DWORD;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x81, 0xFA, 0x2A3) ;81 fa a3 02 00 00 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) ;74 BYTE_OFFSET + $nAddrOffset[1] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[1] = $aOpCode[0] + + ; ElseIf ($uMsg < 0x200 Or $uMsg > 0x203) Then Goto DefaultWndProc + $sExe &= 'BYTE;BYTE;DWORD;' ;lea eax, DWORD PTR [rdx-0x200] + _cHvr_ArrayPush($aOpCode, 0x8D, 0x82, -0x200) ;8d 82 00 02 00 00 + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp eax, 3 + _cHvr_ArrayPush($aOpCode, 0x83, 0xF8, 3) ;83 f8 03 + $sExe &= 'BYTE;BYTE;' ;ja short DefaultWndProc + _cHvr_ArrayPush($aOpCode, 0x77, 0) ;77 BYTE_OFFSET + $nAddrOffset[2] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[2] = $aOpCode[0] + $aOpCode[$nElemOffset[0]] = $nAddrOffset[2] - $nAddrOffset[0] + $aOpCode[$nElemOffset[1]] = $nAddrOffset[2] - $nAddrOffset[1] + + + ; :WndProcInternal (HWND rsp+8, UINT +16, WPARAM +24, LPARAM +32, DWORD +40) + ; $dwRefData = [ESP+48+48(sub rsp, 48)+8(push rdi)] = [ESP+104] + ; Save base registers: + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+8], rbx + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x5C, 0x24, 8) ;48 89 5c 24 08 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+16], rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x6C, 0x24, 16) ;48 89 6c 24 10 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+24], rsi + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x74, 0x24, 24) ;48 89 74 24 18 + $sExe &= 'BYTE;' ;push rdi + _cHvr_ArrayPush($aOpCode, 0x57) ;57 + ; Max sub-routine params = 5 (size = 5*8 = 40), + 8 bytes for return value = 48. + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;sub rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xEC, 48) ;48 83 ec 30 + ; rbx, rbp, rsi now at [ESP+8+56], [ESP+16+56], [ESP+24+56] + + ; Save the parameters: + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rdi, r9 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF9) ;49 8b f9 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rsi, r8 + _cHvr_ArrayPush($aOpCode, 0x49, 0x8B, 0xF0) ;49 8b f0 + $sExe &= 'BYTE;BYTE;' ;mov ebx, edx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xDA) ;8b da + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rbp, rcx + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xE9) ;48 8b e9 + + ; Prepare additional parameter for internal WndProc + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rax, QWORD PTR [rsp+104] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x44, 0x24, 104) ;48 8b 44 24 68 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov QWORD PTR [rsp+32], Rax] + _cHvr_ArrayPush($aOpCode, 0x48, 0x89, 0x44, 0x24, 32) ;48 89 44 24 20 + + ; Call internal WndProc + $sExe &= 'BYTE;BYTE;PTR;' ;mov rax, QWORD PTR _cHvr_iProc + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PINTERNALSUBCLASS) + ;movabs rax, _cHvr_iProc ;48 b8 QWORD_PTR + $sExe &= 'BYTE;BYTE;' ;call rax + _cHvr_ArrayPush($aOpCode, 0xFF, 0xD0) ;ff d0 + + ; If (WndProcInternal() = 0) Then Return + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[3] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[3] = $aOpCode[0] + + ; Restore parameters for DefSubclassProc call + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r9, rdi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xCF) ;4c 8b cf + $sExe &= 'BYTE;BYTE;BYTE;' ;mov r8, rsi + _cHvr_ArrayPush($aOpCode, 0x4C, 0x8B, 0xC6) ;4c 8b c6 + $sExe &= 'BYTE;BYTE;' ;mov edx, ebx + _cHvr_ArrayPush($aOpCode, 0x8B, 0xD3) ;8b d3 + $sExe &= 'BYTE;BYTE;BYTE;' ;mov rcx, rbp + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0xCD) ;48 8b cd + + ; Restore registers value + $aOpCode[$nElemOffset[3]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[3] + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbx, QWORD PTR [rsp+64] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x5C, 0x24, 64) ;48 8b 5c 24 40 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rbp, QWORD PTR [rsp+72] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x6C, 0x24, 72) ;48 8b 6c 24 48 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;BYTE;' ;mov rsi, QWORD PTR [rsp+80] + _cHvr_ArrayPush($aOpCode, 0x48, 0x8B, 0x74, 0x24, 80) ;48 8b 74 24 50 + $sExe &= 'BYTE;BYTE;BYTE;BYTE;' ;add rsp, 48 + _cHvr_ArrayPush($aOpCode, 0x48, 0x83, 0xc4, 48) ;48 83 c4 30 + $sExe &= 'BYTE;' ;pop rdi + _cHvr_ArrayPush($aOpCode, 0x5F) ;5f + $sExe &= 'BYTE;BYTE;BYTE;' ;cmp edx, 0x2A3 + _cHvr_ArrayPush($aOpCode, 0x48, 0x85, 0xC0) ;48 85 c0 + $sExe &= 'BYTE;BYTE;' ;je short WndProcInternal + _cHvr_ArrayPush($aOpCode, 0x74, 0) + $nAddrOffset[4] = DllStructGetSize(DllStructCreate($sExe)) + $nElemOffset[4] = $aOpCode[0] + $aOpCode[$nElemOffset[2]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[2] + + ; :DefaultWndProc (HWND, UINT, WPARAM, LPARAM) + $sExe &= 'BYTE;BYTE;PTR;' + _cHvr_ArrayPush($aOpCode, 0x48, 0xB8, $_cHvr_PDEFSUBCLASSPROC) + $sExe &= 'BYTE;BYTE;' + _cHvr_ArrayPush($aOpCode, 0xFF, 0xE0) + + ; :Return + $aOpCode[$nElemOffset[4]] = DllStructGetSize(DllStructCreate($sExe)) - $nAddrOffset[4] + $sExe &= 'BYTE;' ;ret 0 + _cHvr_ArrayPush($aOpCode, 0xC3) + + Return _cHvr_PopulateOpcode($sExe, $aOpCode) +EndFunc ;==>_cHvr_CSCP_X64 + +Func _cHvr_PopulateOpcode(ByRef $sExe, ByRef $aOpCode) + Local $tExe = DllStructCreate($sExe) + Assert(@error = 0, 'DllStrucCreate Failed With Error = ' & @error) + For $i = 1 To $aOpCode[0] + DllStructSetData($tExe, $i, $aOpCode[$i]) + Next + Return $tExe +EndFunc ;==>_cHvr_PopulateOpcode + +Func _cHvr_ExecutableFromStruct($tExe) + Local $pExe = DllCall('kernel32.dll', 'PTR', 'HeapAlloc', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 8, 'ULONG_PTR', DllStructGetSize($tExe))[0] + Assert($pExe <> 0, 'Allocate memory failed') + DllCall("kernel32.dll", "none", "RtlMoveMemory", "PTR", $pExe, "PTR", DllStructGetPtr($tExe), "ULONG_PTR", DllStructGetSize($tExe)) + Assert(@error = 0, 'Failed to copy memory') + Return $pExe +EndFunc ;==>_cHvr_ExecutableFromStruct + +Func _cHvr_UnRegisterInternal($cIndex, $hWnd) + _WinAPI_RemoveWindowSubclass($hWnd, $_cHvr_PSUBCLASSEXE, $hWnd) + Local $aData=$_cHvr_aData[$cIndex] + $_cHvr_aData[$cIndex] = 0 + Call( "_iControlDelete",$aData[1]) +EndFunc ;==>_cHvr_UnRegisterInternal + +Func _cHvr_Finalize() + DllCallbackFree($_cHvr_PINTERNALSUBCLASS_DLL) + _WinAPI_FreeLibrary($_cHvr_HDLLCOMCTL32) + If ($_cHvr_HEXECUTABLEHEAP <> 0) Then + If ($_cHvr_PSUBCLASSEXE <> 0) Then + DllCall('kernel32.dll', 'BOOL', 'HeapFree', 'HANDLE', $_cHvr_HEXECUTABLEHEAP, 'DWORD', 0, 'PTR', $_cHvr_PSUBCLASSEXE) + EndIf + DllCall('kernel32.dll', 'BOOL', 'HeapDestroy', 'HANDLE', $_cHvr_HEXECUTABLEHEAP) + EndIf +EndFunc ;==>_cHvr_Finalize + +Func Assert($bExpression, $sMsg = '', $sScript = @ScriptName, $sScriptPath = @ScriptFullPath, $iLine = @ScriptLineNumber, $iError = @error, $iExtend = @extended) + If (Not ($bExpression)) Then + MsgBox(BitOR(1, 0x10), 'Assertion Error!', _ + @CRLF & 'Script' & @TAB & ': ' & $sScript _ + & @CRLF & 'Path' & @TAB & ': ' & $sScriptPath _ + & @CRLF & 'Line' & @TAB & ': ' & $iLine _ + & @CRLF & 'Error' & @TAB & ': ' & ($iError > 0x7FFF ? Hex($iError) : $iError) _ + & ($iExtend <> 0 ? ' (Extended : ' & ($iExtend > 0x7FFF ? Hex($iExtend) : $iExtend) & ')' : '') _ + & @CRLF & 'Message' & @TAB & ': ' & $sMsg _ + & @CRLF & @CRLF & 'OK: Exit Script' & @TAB & 'Cancel: Continue') + Exit + EndIf +EndFunc ;==>Assert + +Func _cHvr_GetNewIndex($hWnd) + ;Try to assign index from previously deleted control + For $i = 0 To UBound($_cHvr_aData) - 1 Step +1 + If Not IsArray($_cHvr_aData[$i]) Then + Return $i + EndIf + Next + + ReDim $_cHvr_aData[UBound($_cHvr_aData) + 1] + Return UBound($_cHvr_aData) - 1 +EndFunc ;==>_cHvr_GetNewIndex + +Func _WinAPI_GetCapture() + Return DllCall("user32.dll", "HWND", "GetCapture")[0] +EndFunc ;==>_WinAPI_GetCapture diff --git a/source/Include/MetroUDF-Required/StringSize.au3 b/source/Include/MetroUDF-Required/StringSize.au3 new file mode 100644 index 0000000..93ec00b --- /dev/null +++ b/source/Include/MetroUDF-Required/StringSize.au3 @@ -0,0 +1,279 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: _StringSize +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Returns size of rectangle required to display string - maximum width can be chosen +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23 - thanks to trancexx for the default DC code +; ==================================================================================================================== + +;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 + +; #CURRENT# ========================================================================================================== +; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; _StringSize_Error_Close: Releases DC and deletes font object after error +; _StringSize_DefaultFontName: Determines Windows default font +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _StringSize +; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen +; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]]) +; Parameters ....: $sText - String to display +; $iSize - [optional] Font size in points - (default = 8.5) +; $iWeight - [optional] Font weight - (default = 400 = normal) +; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike) +; + 1 if tabs are to be expanded before sizing +; $sName - [optional] Font name - (default = Tahoma) +; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string) +; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required) +; Requirement(s) : v3.2.12.1 or higher +; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set) +; |$array[0] = String reformatted with additonal @CRLF // Original string +; |$array[1] = Height of single line in selected font // idem +; |$array[2] = Width of rectangle required for reformatted // original string +; |$array[3] = Height of rectangle required for reformatted // original string +; Failure - Returns 0 and sets @error: +; |1 - Incorrect parameter type (@extended = parameter index) +; |2 - DLL call error - extended set as follows: +; |1 - GetDC failure +; |2 - SendMessage failure +; |3 - GetDeviceCaps failure +; |4 - CreateFont failure +; |5 - SelectObject failure +; |6 - GetTextExtentPoint32 failure +; |3 - Font too large for chosen max width - a word will not fit +; Author ........: Melba23 - thanks to trancexx for the default DC code +; Modified ......: +; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not +; return correct dimensions without it. +; Related .......: +; Link ..........: +; Example .......: Yes +;===================================================================================================================== +Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0) + + ; Set parameters passed as Default + If $iSize = Default Then $iSize = 8.5 + If $iWeight = Default Then $iWeight = 400 + If $iAttrib = Default Then $iAttrib = 0 + If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName() + + ; Check parameters are correct type + If Not IsString($sText) Then Return SetError(1, 1, 0) + If Not IsNumber($iSize) Then Return SetError(1, 2, 0) + If Not IsInt($iWeight) Then Return SetError(1, 3, 0) + If Not IsInt($iAttrib) Then Return SetError(1, 4, 0) + If Not IsString($sName) Then Return SetError(1, 5, 0) + If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0) + If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0) + + Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle + + ; Check for tab expansion flag + Local $iExpTab = BitAnd($iAttrib, 1) + ; Remove possible tab expansion flag from font attribute value + $iAttrib = BitAnd($iAttrib, BitNot(1)) + + ; If GUI handle was passed + If IsHWnd($hWnd) Then + ; Create label outside GUI borders + $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10) + $hLabel_Handle = GUICtrlGetHandle(-1) + GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName) + ; Create DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle) + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, 1, 0) + EndIf + $hDC = $aRet[0] + $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont + If @error Or $aRet[0] = 0 Then + GUICtrlDelete($hLabel) + Return SetError(2, _StringSize_Error_Close(2, $hDC), 0) + EndIf + $hFont = $aRet[0] + Else + ; Get default DC + $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0) + $hDC = $aRet[0] + ; Create required font + $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0) + Local $iInfo = $aRet[0] + $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _ + "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _ + "dword", 0, "dword", 5, "dword", 0, "wstr", $sName) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0) + $hFont = $aRet[0] + EndIf + + ; Select font and store previous font + $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont) + If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0) + Local $hPrevFont = $aRet[0] + + ; Declare variables + Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line + ; Declare and fill Size structure + Local $tSize = DllStructCreate("int X;int Y") + DllStructSetData($tSize, "X", 0) + DllStructSetData($tSize, "Y", 0) + + ; Ensure EoL is @CRLF and break text into lines + $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X") + If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y") + Next + + ; Check if $iMaxWidth has been both set and exceeded + If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required + ; For each Line + For $j = 1 To $asLines[0] + ; Size line unwrapped + $iLine_Length = StringLen($asLines[$j]) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + ; Check wrap status + If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then + ; No wrap needed so count line and store + $iLine_Count += 1 + $avSize_Info[0] &= $asLines[$j] & @CRLF + Else + ; Wrap needed so zero counter for wrapped lines + $iWrap_Count = 0 + ; Build line to max width + While 1 + ; Zero line width + $iLine_Width = 0 + ; Initialise pointer for end of word + $iLast_Word = 0 + ; Add characters until EOL or maximum width reached + For $i = 1 To StringLen($asLines[$j]) + ; Is this just past a word ending? + If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1 + ; Increase line by one character + $sTest_Line = StringMid($asLines[$j], 1, $i) + ; Get line length + $iLine_Length = StringLen($sTest_Line) + DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize)) + If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0) + $iLine_Width = DllStructGetData($tSize, "X") + ; If too long exit the loop + If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop + Next + ; End of the line of text? + If $i > StringLen($asLines[$j]) Then + ; Yes, so add final line to count + $iWrap_Count += 1 + ; Store line + $avSize_Info[0] &= $sTest_Line & @CRLF + ExitLoop + Else + ; No, but add line just completed to count + $iWrap_Count += 1 + ; Check at least 1 word completed or return error + If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0) + ; Store line up to end of last word + $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF + ; Strip string to point reached + $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word) + ; Trim leading whitespace + $asLines[$j] = StringStripWS($asLines[$j], 1) + ; Repeat with remaining characters in line + EndIf + WEnd + ; Add the number of wrapped lines to the count + $iLine_Count += $iWrap_Count + EndIf + Next + ; Reset any tab expansions + If $iExpTab Then + $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB) + EndIf + ; Complete return array + $avSize_Info[1] = $iLine_Height + $avSize_Info[2] = $iMaxWidth + ; Convert lines to pixels and add drop margin + $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4 + Else ; No wrapping required + ; Create return array (add drop margin to height) + Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4] + EndIf + + ; Clear up + DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont) + DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $avSize_Info + +EndFunc ;==>_StringSize + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_Error_Close +; Description ...: Releases DC and deleted font object if required after error +; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI) +; Parameters ....: $iExtCode - code to return +; $hDC, $hGUI - handles as set in _StringSize function +; Return value ..: $iExtCode as passed +; Author ........: Melba23 +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0) + + If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont) + If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC) + If $hLabel Then GUICtrlDelete($hLabel) + + Return $iExtCode + +EndFunc ;=>_StringSize_Error_Close + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _StringSize_DefaultFontName +; Description ...: Determines Windows default font +; Syntax ........: _StringSize_DefaultFontName() +; Parameters ....: None +; Return values .: Success - Returns name of system default font +; Failure - Returns "Tahoma" +; Author ........: Melba23, based on some original code by Larrydalooza +; Modified.......: +; Remarks .......: This function is used internally by _StringSize +; =============================================================================================================================== +Func _StringSize_DefaultFontName() + + ; Get default system font data + Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") + DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) + DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) + Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13)) + If IsString(DllStructGetData($tLOGFONT, 14)) Then + Return DllStructGetData($tLOGFONT, 14) + Else + Return "Tahoma" + EndIf + +EndFunc ;=>_StringSize_DefaultFontName diff --git a/source/Include/ResizeStuff.au3 b/source/Include/ResizeStuff.au3 new file mode 100644 index 0000000..33f0e5a --- /dev/null +++ b/source/Include/ResizeStuff.au3 @@ -0,0 +1,98 @@ +#include-once +#include +;Check if Monitor supports Resolution +;Basic Idea by PACaleala from https://www.autoitscript.com/forum/topic/185017/?do=findComment&comment=1328940 +Func _ScreenCompatibility($rw = 800, $rh = 600) + Local $strComputer = "." + Local $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") + Local $colItems = $objWMIService.ExecQuery("Select * from CIM_VideoControllerResolution") + Local $compatible[] = ["0", "0", "0"] + For $objItem In $colItems + If $objItem.HorizontalResolution = $rw And $objItem.VerticalResolution = $rh Then + If $objItem.RefreshRate > $compatible[2] Then + $compatible[0] = $objItem.HorizontalResolution + $compatible[1] = $objItem.VerticalResolution + $compatible[2] = $objItem.RefreshRate + EndIf + EndIf + Next + If $compatible[2] > 0 Then + Return $compatible + Else + Return -1 + EndIf + +EndFunc ;==>_ScreenCompatibility + + +;=============================================================================== +; +; Function Name: _ChangeScreenRes() +; Description: Changes the current screen geometry, colour and refresh rate. +; Version: 1.0.0.1 +; Parameter(s): $i_Width - Width of the desktop screen in pixels. (horizontal resolution) +; $i_Height - Height of the desktop screen in pixels. (vertical resolution) +; $i_BitsPP - Depth of the desktop screen in bits per pixel. +; $i_RefreshRate - Refresh rate of the desktop screen in hertz. +; Requirement(s): AutoIt Beta > 3.1 +; Return Value(s): On Success - Screen is adjusted, @ERROR = 0 +; On Failure - sets @ERROR = 1 +; Forum(s): http://www.autoitscript.com/forum/index.php?showtopic=20121 +; Author(s): Original code - psandu.ro +; Modifications - PartyPooper +; +;=============================================================================== + +Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh) + Local Const $DM_PELSWIDTH = 0x00080000 + Local Const $DM_PELSHEIGHT = 0x00100000 + Local Const $DM_BITSPERPEL = 0x00040000 + Local Const $DM_DISPLAYFREQUENCY = 0x00400000 + Local Const $CDS_TEST = 0x00000002 + Local Const $CDS_UPDATEREGISTRY = 0x00000001 + Local Const $DISP_CHANGE_RESTART = 1 + Local Const $DISP_CHANGE_SUCCESSFUL = 0 + Local Const $HWND_BROADCAST = 0xffff + Local Const $WM_DISPLAYCHANGE = 0x007E + If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting + If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting + If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting + If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting + Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]") + Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE)) + If @error Then + $B = 0 + SetError(1) + Return $B + Else + $B = $B[0] + EndIf + If $B <> 0 Then + DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5) + DllStructSetData($DEVMODE, 4, $i_Width, 2) + DllStructSetData($DEVMODE, 4, $i_Height, 3) + DllStructSetData($DEVMODE, 4, $i_BitsPP, 1) + DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5) + $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) + If @error Then + $B = -1 + Else + $B = $B[0] + EndIf + Select + Case $B = $DISP_CHANGE_RESTART + $DEVMODE = "" + Return 2 + Case $B = $DISP_CHANGE_SUCCESSFUL + DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) + DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ + "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) + $DEVMODE = "" + Return 1 + Case Else + $DEVMODE = "" + SetError(1) + Return $B + EndSelect + EndIf +EndFunc ;==>_ChangeScreenRes diff --git a/source/Include/SimpleR_Constants.au3 b/source/Include/SimpleR_Constants.au3 new file mode 100644 index 0000000..b4b8fdc --- /dev/null +++ b/source/Include/SimpleR_Constants.au3 @@ -0,0 +1,79 @@ +;Constants to be used with Scripts related to SimpleR +#include-once + + +Global Const $user32 = "user32.dll", $HEIGHT = 658, $WIDTH = 816 ;user32.ddl used to change mouse cursor, height + width for resize to default game window size + +;Paths +$pathGeneral = @ScriptDir & "\data\General.csv" +$pathPaths = @ScriptDir & "\data\Paths.csv" +$pathMacros = @ScriptDir & "\data\Macros.csv" +$pathIngame = @ScriptDir & "\data\Ingame.csv" +$pathHotkeys = @ScriptDir & "\data\Hotkeys.csv" +$pathSettings = @ScriptDir & "\Settings.exe" + +;Array indexes +Global const $cAIdescription = 0 +Global const $cAIactive = 1 +Global const $cAIcontent = 1 +Global const $cAIKey = 2 +Global const $cAImacrotext = 3 + +;Settings +;GENERAL +Global const $bTesting = 0 +Global const $bAGCLoader = 1 +Global const $bMacros = 2 +Global const $bHotkeys = 3 +Global const $bCustomCursor = 4 +Global const $bKongregate = 5 +Global const $bScreenshots = 6 +Global const $bCursorOnScreenshot = 7 +Global const $bKeepWindowFocused = 8 +Global const $bLaunchAdditionalProgram = 9 +Global const $bAnchor = 10 +;~ ;Reserved 11-24 +Global const $sWindowName = 25 +Global const $sDefaultAnchor = 26 +Global const $sKongregateParameters = 27 +Global const $sAdditionalProgramPath = 28 +;~ Global const $sLastKnownVersion = 29 +;~ Reserved 30 - 44 + + + +;MACROS +Global const $cmacro1 = 0 +Global const $cmacro2 = 1 +Global const $cmacro3 = 2 +Global const $cmacro4 = 3 +;~ Reserved 5 - 16 + +;PATHS +Global const $sFlashFile = 0 +Global const $sCustomCursorPath = 1 +;~ Reserved 3 - 10 + +;INGAME KEYS +Global const $igChat = 0 +Global const $igAbility = 1 +Global const $igCommand = 2 +Global const $igTell = 3 +;~ Reserved 5-12 + +;HOTKEYS +Global const $hkResetSize = 0 +Global const $hk43Maximize = 1 +Global const $hkScreenshot = 2 +Global const $hkSetAnchor = 3 +Global const $hkTPAnchor = 4 +Global const $hkIgnorePM = 5 +Global const $hkToggleFocus = 6 +Global const $hkActualFullscreen = 7 +;~ Reserved 9-17 + +;SWF +Global const $cSWFtesting = 1 +Global const $cSWFproduction = 0 +Global const $cSWFloader = 0 +Global const $cSWFclient = 1 diff --git a/source/Include/_GUIDisable.au3 b/source/Include/_GUIDisable.au3 new file mode 100644 index 0000000..df5b192 --- /dev/null +++ b/source/Include/_GUIDisable.au3 @@ -0,0 +1,80 @@ +#include-once + +; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 +; #INDEX# ======================================================================================================================= +; Title .........: _GUIDisable +; AutoIt Version : v3.2.2.0 or higher +; Language ......: English +; Description ...: Creates a dimming effect on the current/selected GUI. +; Note ..........: +; Author(s) .....: guinness +; Remarks .......: Thanks to supersonic for the idea of adjusting the UDF when using Classic themes in Windows Vista+. +; =============================================================================================================================== + +; #INCLUDES# ==================================================================================================================== +#include +#include +#include + +; #GLOBAL VARIABLES# ============================================================================================================ +Global Enum $__hGUIDisableHWnd, $__hGUIDisableHWndPrevious, $__iGUIDisableMax +Global $__aGUIDisable[$__iGUIDisableMax] + +Func _GUIDisable($hWnd, $iAnimate = Default, $iBrightness = Default, $bColor = 0x000000) + Local Const $AW_SLIDE_IN_TOP = 0x00040004, $AW_SLIDE_OUT_TOP = 0x00050008 + + If $iAnimate = Default Then + $iAnimate = 1 + EndIf + If $iBrightness = Default Then + $iBrightness = 5 + EndIf + + If $hWnd = -1 And $__aGUIDisable[$__hGUIDisableHWnd] = 0 Then + Local $iLabel = GUICtrlCreateLabel('', -99, -99, 1, 1) + $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iLabel)) + If @error Then + Return SetError(1, 0 * GUICtrlDelete($iLabel), 0) + EndIf + GUICtrlDelete($iLabel) + EndIf + + If IsHWnd($__aGUIDisable[$__hGUIDisableHWnd]) Then + GUIDelete($__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = 0 + $__aGUIDisable[$__hGUIDisableHWndPrevious] = 0 + Else + $__aGUIDisable[$__hGUIDisableHWndPrevious] = $hWnd + + Local $iLeft = 0, $iTop = 0 + Local $iStyle = GUIGetStyle($__aGUIDisable[$__hGUIDisableHWndPrevious]) + Local $sCurrentTheme = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes', 'CurrentTheme') + Local $iIsClassicTheme = Number(StringInStr($sCurrentTheme, 'Basic.theme', 2) = 0 And StringInStr($sCurrentTheme, 'Ease of Access Themes', 2) > 0) + + Local $aWinGetPos = WinGetClientSize($__aGUIDisable[$__hGUIDisableHWndPrevious]) + $__aGUIDisable[$__hGUIDisableHWnd] = GUICreate('', $aWinGetPos[0], $aWinGetPos[1], $iLeft + 3, $iTop + 3, $WS_POPUP, $WS_EX_MDICHILD, $__aGUIDisable[$__hGUIDisableHWndPrevious]) + GUISetBkColor($bColor, $__aGUIDisable[$__hGUIDisableHWnd]) + WinSetTrans($__aGUIDisable[$__hGUIDisableHWnd], '', Round($iBrightness * (255 / 100))) + If not $iAnimate Then + GUISetState(@SW_SHOW, $__aGUIDisable[$__hGUIDisableHWnd]) + EndIf + GUISetState(@SW_DISABLE, $__aGUIDisable[$__hGUIDisableHWnd]) + GUISwitch($__aGUIDisable[$__hGUIDisableHWndPrevious]) + EndIf + Return $__aGUIDisable[$__hGUIDisableHWnd] +EndFunc ;==>_GUIDisable + +; #INTERNAL_USE_ONLY#============================================================================================================ +Func __GUIDisable_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) + #forceref $hWnd, $iMsg, $iwParam + Local $iHeight = _WinAPI_HiWord($ilParam) + Local $iWidth = _WinAPI_LoWord($ilParam) + If $hWnd = $__aGUIDisable[$__hGUIDisableHWndPrevious] Then + Local $iWinGetPos = WinGetPos($__aGUIDisable[$__hGUIDisableHWnd]) + If @error = 0 Then + WinMove($__aGUIDisable[$__hGUIDisableHWnd], '', $iWinGetPos[0], $iWinGetPos[1], $iWidth, $iHeight) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc ;==>__GUIDisable_WM_SIZE diff --git a/source/Settings.au3 b/source/Settings.au3 new file mode 100644 index 0000000..575f140 --- /dev/null +++ b/source/Settings.au3 @@ -0,0 +1,1766 @@ +#NoTrayIcon +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=..\data\Icons\Settings.ico +#AutoIt3Wrapper_Res_Description=Settings GUI for SimpleR +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p +#AutoIt3Wrapper_Res_HiDpi=y +#AutoIt3Wrapper_Run_Au3Stripper=y +#Au3Stripper_Parameters=/so /rm /pe +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** + +#include ".\include\MetroGUI_UDF.au3" +#include ".\include\_GUIDisable.au3" ; For dim effects when msgbox is displayed +#include ".\Include\LoadSettings.au3" ;for hotkeys / macros +#include "./Include/IsPressed_UDF.au3" +#include +#include +#include +; =============================================================================================================================== +; Name ..........: Settings GUI for SimpleR +; =============================================================================================================================== +#Region MetroGUI settings + +#Au3Stripper_Ignore_Funcs=_iHoverOn,_iHoverOff,_iFullscreenToggleBtn,_cHvr_CSCP_X64,_cHvr_CSCP_X86,_iControlDelete +_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. +_SetTheme("DarkBlue") + +#EndRegion MetroGUI settings + + +AutoItSetOption("GUICloseOnESC", 0) + +;Create resizable Metro GUI +$Form1 = _Metro_CreateGUI("SimpleR Settings", 800, 700, -1, -1, True) + +;Add/create control buttons to the GUI +$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True + +;Set variables for the handles of the GUI-Control buttons. (Above function always returns an array this size and in this order, no matter which buttons are selected.) +$GUI_CLOSE_BUTTON = $Control_Buttons[0] +$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1] +$GUI_RESTORE_BUTTON = $Control_Buttons[2] +$GUI_MINIMIZE_BUTTON = $Control_Buttons[3] +$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4] +$GUI_FSRestore_BUTTON = $Control_Buttons[5] +$GUI_MENU_BUTTON = $Control_Buttons[6] +;====================================================================================================================================================================== + + +#Region VARIABLES +Global $savedGeneral +Global $savedPaths +Global $savedMacros +Global $savedIngame +Global $savedHotkeys + +Global $newGeneral +Global $newPaths +Global $newMacros +Global $newIngame +Global $newHotkeys + +#EndRegion VARIABLES + + + +#Region GENERAL +$lblMenu = GUICtrlCreateLabel("â–² Open Menu", 20, 30, 120, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblMenu, 768 + 8) +GUICtrlSetColor($lblMenu, $COLOR_WHITE) +GUICtrlSetFont($lblMenu, 9, "", "", "Segoe UI") + +$tgUseMacros = _Metro_CreateToggle("Use macros", 40, 70, 250, 30) +GUICtrlSetResizing($tgUseMacros, 768 + 8) + +$tgUseHotkeys = _Metro_CreateToggle("Use hotkeys", 40, 130, 250, 30) +GUICtrlSetResizing($tgUseHotkeys, 768 + 8) + +$tgUseCustomCursor = _Metro_CreateToggle("Use Custom cursor", 40, 190, 250, 30) +GUICtrlSetResizing($tgUseCustomCursor, 768 + 8) + +$lblCustomCursorPath = GUICtrlCreateLabel("C...", 120, 250, 600, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblCustomCursorPath, 768 + 8) +GUICtrlSetColor($lblCustomCursorPath, $COLOR_GRAY) +GUICtrlSetFont($lblCustomCursorPath, 11.5, "", "", "Segoe UI") + +$browseCustomCursorPath = _Metro_CreateButton("Browse...", 40, 245, 70, 30) +GUICtrlSetResizing($browseCustomCursorPath, 768 + 8) + +$tgForceFocus = _Metro_CreateToggle("Force focus on game window (avoid clicking out of the window)", 40, 310, 600, 30) +GUICtrlSetResizing($tgForceFocus, 768 + 8) + +$lblGameName = GUICtrlCreateLabel("Window name:", 40, 370, 120, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblGameName, 768 + 8) +GUICtrlSetColor($lblGameName, $COLOR_WHITE) +GUICtrlSetFont($lblGameName, 11.5, "", "", "Segoe UI") + +$inputGameName = GUICtrlCreateInput("RotMG", 170, 370, 550, 30) +GUICtrlSetResizing($inputGameName, 768 + 8) +GUICtrlSetColor($inputGameName, $COLOR_WHITE) +GUICtrlSetBkColor($inputGameName, $COLOR_BLACK) +GUICtrlSetFont($inputGameName, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputGameName, 5) + +#EndRegion GENERAL + +#Region MACROS +;M1 +$tgMacro1 = _Metro_CreateToggle("", 40, 70, 60, 30) +GUICtrlSetResizing($tgMacro1, 768 + 8) + +$btnMacro1 = GUICtrlCreateLabel("", 120, 70, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnMacro1, 768 + 8) +GUICtrlSetColor($btnMacro1, $COLOR_WHITE) +GUICtrlSetFont($btnMacro1, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnMacro1, "0x1E648C") +GUICtrlSetCursor($btnMacro1, 0) + +$inputMacro1 = GUICtrlCreateInput("Macro Text 1", 230, 70, 490, 30) +GUICtrlSetResizing($inputMacro1, 768 + 8) +GUICtrlSetColor($inputMacro1, $COLOR_WHITE) +GUICtrlSetBkColor($inputMacro1, $COLOR_BLACK) +GUICtrlSetFont($inputMacro1, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputMacro1, 5) + +;M2 +$tgMacro2 = _Metro_CreateToggle("", 40, 130, 60, 30) +GUICtrlSetResizing($tgMacro2, 768 + 8) + +$btnMacro2 = GUICtrlCreateLabel("", 120, 130, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnMacro2, 768 + 8) +GUICtrlSetColor($btnMacro2, $COLOR_WHITE) +GUICtrlSetFont($btnMacro2, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnMacro2, "0x1E648C") +GUICtrlSetCursor($btnMacro2, 0) + +$inputMacro2 = GUICtrlCreateInput("Macro Text 2", 230, 130, 490, 30) +GUICtrlSetResizing($inputMacro2, 768 + 8) +GUICtrlSetColor($inputMacro2, $COLOR_WHITE) +GUICtrlSetBkColor($inputMacro2, $COLOR_BLACK) +GUICtrlSetFont($inputMacro2, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputMacro2, 5) + +;M3 +$tgMacro3 = _Metro_CreateToggle("", 40, 190, 60, 30) +GUICtrlSetResizing($tgMacro3, 768 + 8) + +$btnMacro3 = GUICtrlCreateLabel("", 120, 190, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnMacro3, 768 + 8) +GUICtrlSetColor($btnMacro3, $COLOR_WHITE) +GUICtrlSetFont($btnMacro3, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnMacro3, "0x1E648C") +GUICtrlSetCursor($btnMacro3, 0) + +$inputMacro3 = GUICtrlCreateInput("Macro Text 3", 230, 190, 490, 30) +GUICtrlSetResizing($inputMacro3, 768 + 8) +GUICtrlSetColor($inputMacro3, $COLOR_WHITE) +GUICtrlSetBkColor($inputMacro3, $COLOR_BLACK) +GUICtrlSetFont($inputMacro3, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputMacro3, 5) + +;M4 +$tgMacro4 = _Metro_CreateToggle("", 40, 250, 60, 30) +GUICtrlSetResizing($tgMacro4, 768 + 8) + +$btnMacro4 = GUICtrlCreateLabel("", 120, 250, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnMacro4, 768 + 8) +GUICtrlSetColor($btnMacro4, $COLOR_WHITE) +GUICtrlSetFont($btnMacro4, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnMacro4, "0x1E648C") +GUICtrlSetCursor($btnMacro4, 0) + +$inputMacro4 = GUICtrlCreateInput("Macro Text 4", 230, 250, 490, 30) +GUICtrlSetResizing($inputMacro4, 768 + 8) +GUICtrlSetColor($inputMacro4, $COLOR_WHITE) +GUICtrlSetBkColor($inputMacro4, $COLOR_BLACK) +GUICtrlSetFont($inputMacro4, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputMacro4, 5) + +#EndRegion MACROS + + +#Region Hotkeys +;H1 +$tgHotkey1 = _Metro_CreateToggle("", 40, 70, 60, 30) +GUICtrlSetResizing($tgHotkey1, 768 + 8) + +$btnHotkey1 = GUICtrlCreateLabel("", 120, 70, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey1, 768 + 8) +GUICtrlSetColor($btnHotkey1, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey1, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey1, "0x1E648C") +GUICtrlSetCursor($btnHotkey1, 0) + +$lblHotkey1 = GUICtrlCreateLabel("Reset Game to default window size", 230, 75, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey1, 768 + 8) +GUICtrlSetColor($lblHotkey1, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey1, 11.5, "", "", "Segoe UI") + +;H2 +$tgHotkey2 = _Metro_CreateToggle("", 40, 130, 60, 30) +GUICtrlSetResizing($tgHotkey2, 768 + 8) + +$btnHotkey2 = GUICtrlCreateLabel("", 120, 130, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey2, 768 + 8) +GUICtrlSetColor($btnHotkey2, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey2, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey2, "0x1E648C") +GUICtrlSetCursor($btnHotkey2, 0) + +$lblHotkey2 = GUICtrlCreateLabel("Maximize game window with 4:3 aspect ratio", 230, 135, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey2, 768 + 8) +GUICtrlSetColor($lblHotkey2, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey2, 11.5, "", "", "Segoe UI") + +;H8 +$tgHotkey8 = _Metro_CreateToggle("", 40, 190, 60, 30) +GUICtrlSetResizing($tgHotkey8, 768 + 8) + +$btnHotkey8 = GUICtrlCreateLabel("", 120, 190, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey8, 768 + 8) +GUICtrlSetColor($btnHotkey8, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey8, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey8, "0x1E648C") +GUICtrlSetCursor($btnHotkey8, 0) + +$lblHotkey8 = GUICtrlCreateLabel("Toggle actual 4:3 Fullscreen (temp. changes screen resolution)", 230, 195, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey8, 768 + 8) +GUICtrlSetColor($lblHotkey8, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey8, 11.5, "", "", "Segoe UI") + +;H3 +$tgHotkey3 = _Metro_CreateToggle("", 40, 250, 60, 30) +GUICtrlSetResizing($tgHotkey3, 768 + 8) + +$btnHotkey3 = GUICtrlCreateLabel("", 120, 250, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey3, 768 + 8) +GUICtrlSetColor($btnHotkey3, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey3, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey3, "0x1E648C") +GUICtrlSetCursor($btnHotkey3, 0) + +$lblHotkey3 = GUICtrlCreateLabel("Save a Screenshot of the game client", 230, 255, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey3, 768 + 8) +GUICtrlSetColor($lblHotkey3, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey3, 11.5, "", "", "Segoe UI") + +;H3+ +$tgIncludeCursor = _Metro_CreateToggle("Show cursor on screenshot", 120, 290, 250, 30) +GUICtrlSetResizing($tgIncludeCursor, 768 + 8) + +;H4,5 ALL +$tgEnableAnchor = _Metro_CreateToggle("Enable save anchor feature", 40, 350, 350, 30) +GUICtrlSetResizing($tgEnableAnchor, 768 + 8) + +$btnHotkey4 = GUICtrlCreateLabel("", 120, 390, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey4, 768 + 8) +GUICtrlSetColor($btnHotkey4, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey4, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey4, "0x1E648C") +GUICtrlSetCursor($btnHotkey4, 0) + +$lblHotkey4 = GUICtrlCreateLabel("Set your anchor", 240, 395, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey4, 768 + 8) +GUICtrlSetColor($lblHotkey4, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey4, 11.5, "", "", "Segoe UI") + +$btnHotkey5 = GUICtrlCreateLabel("", 120, 430, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey5, 768 + 8) +GUICtrlSetColor($btnHotkey5, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey5, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey5, "0x1E648C") +GUICtrlSetCursor($btnHotkey5, 0) + +$lblHotkey5 = GUICtrlCreateLabel("Teleport to your anchor", 240, 435, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey5, 768 + 8) +GUICtrlSetColor($lblHotkey5, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey5, 11.5, "", "", "Segoe UI") + +$inputDefaultAnchor = GUICtrlCreateInput("", 240, 470, 200, 30) +GUICtrlSetResizing($inputDefaultAnchor, 768 + 8) +GUICtrlSetColor($inputDefaultAnchor, $COLOR_WHITE) +GUICtrlSetBkColor($inputDefaultAnchor, $COLOR_BLACK) +GUICtrlSetFont($inputDefaultAnchor, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputDefaultAnchor, 5) + +$lblDefaultAnchor = GUICtrlCreateLabel("Default anchor:", 120, 475, 120, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblDefaultAnchor, 768 + 8) +GUICtrlSetColor($lblDefaultAnchor, $COLOR_WHITE) +GUICtrlSetFont($lblDefaultAnchor, 11.5, "", "", "Segoe UI") + +;H6 +$tgHotkey6 = _Metro_CreateToggle("", 40, 530, 60, 30) +GUICtrlSetResizing($tgHotkey6, 768 + 8) + +$btnHotkey6 = GUICtrlCreateLabel("", 120, 530, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey6, 768 + 8) +GUICtrlSetColor($btnHotkey6, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey6, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey6, "0x1E648C") +GUICtrlSetCursor($btnHotkey6, 0) + +$lblHotkey6 = GUICtrlCreateLabel("Ignore the last person that sent you a message", 230, 535, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey6, 768 + 8) +GUICtrlSetColor($lblHotkey6, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey6, 11.5, "", "", "Segoe UI") + +;H7 +$tgHotkey7 = _Metro_CreateToggle("", 40, 590, 60, 30) +GUICtrlSetResizing($tgHotkey7, 768 + 8) + +$btnHotkey7 = GUICtrlCreateLabel("", 120, 590, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnHotkey7, 768 + 8) +GUICtrlSetColor($btnHotkey7, $COLOR_WHITE) +GUICtrlSetFont($btnHotkey7, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnHotkey7, "0x1E648C") +GUICtrlSetCursor($btnHotkey7, 0) + +$lblHotkey7 = GUICtrlCreateLabel("Toggle 'force focus on game'", 230, 595, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblHotkey7, 768 + 8) +GUICtrlSetColor($lblHotkey7, $COLOR_WHITE) +GUICtrlSetFont($lblHotkey7, 11.5, "", "", "Segoe UI") + +#EndRegion Hotkeys + + +#Region IngameKeys +;CHAT +$btnIngame1 = GUICtrlCreateLabel("", 40, 70, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnIngame1, 768 + 8) +GUICtrlSetColor($btnIngame1, $COLOR_WHITE) +GUICtrlSetFont($btnIngame1, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnIngame1, "0x1E648C") +GUICtrlSetCursor($btnIngame1, 0) + +$lblIngame1 = GUICtrlCreateLabel("Ingame Chat key (Default: ENTER)", 150, 75, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblIngame1, 768 + 8) +GUICtrlSetColor($lblIngame1, $COLOR_WHITE) +GUICtrlSetFont($lblIngame1, 11.5, "", "", "Segoe UI") + +;Ability +$btnIngame2 = GUICtrlCreateLabel("", 40, 130, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnIngame2, 768 + 8) +GUICtrlSetColor($btnIngame2, $COLOR_WHITE) +GUICtrlSetFont($btnIngame2, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnIngame2, "0x1E648C") +GUICtrlSetCursor($btnIngame2, 0) + +$lblIngame2 = GUICtrlCreateLabel("Ingame Ability key (Default: SPACEBAR)", 150, 135, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblIngame2, 768 + 8) +GUICtrlSetColor($lblIngame2, $COLOR_WHITE) +GUICtrlSetFont($lblIngame2, 11.5, "", "", "Segoe UI") + +;TELL +$btnIngame3 = GUICtrlCreateLabel("", 40, 190, 100, 30, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($btnIngame3, 768 + 8) +GUICtrlSetColor($btnIngame3, $COLOR_WHITE) +GUICtrlSetFont($btnIngame3, 11.5, "", "", "Segoe UI Bold") +GUICtrlSetBkColor($btnIngame3, "0x1E648C") +GUICtrlSetCursor($btnIngame3, 0) + +$lblIngame3 = GUICtrlCreateLabel("Ingame Tell key (Default: TAB)", 150, 195, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblIngame3, 768 + 8) +GUICtrlSetColor($lblIngame3, $COLOR_WHITE) +GUICtrlSetFont($lblIngame3, 11.5, "", "", "Segoe UI") + +;COMMAND SYMBOL +$inputCommandSymbol = GUICtrlCreateInput("", 40, 250, 100, 30) +GUICtrlSetResizing($inputCommandSymbol, 768 + 8) +GUICtrlSetColor($inputCommandSymbol, $COLOR_WHITE) +GUICtrlSetBkColor($inputCommandSymbol, $COLOR_BLACK) +GUICtrlSetFont($inputCommandSymbol, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputCommandSymbol, 5) + +$lblIngame4 = GUICtrlCreateLabel("Command Symbol (Default: '/')", 150, 255, 490, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblIngame4, 768 + 8) +GUICtrlSetColor($lblIngame4, $COLOR_WHITE) +GUICtrlSetFont($lblIngame4, 11.5, "", "", "Segoe UI") + +#EndRegion IngameKeys + + +#Region Others +;Play with Kongregate Toggle +$tgbKongregate = _Metro_CreateToggle("Play with Kongregate", 40, 70, 250, 30) +GUICtrlSetResizing($tgbKongregate, 768 + 8) + +;Kongregate Parameters Input +$lblsKongregateParameters = GUICtrlCreateLabel("Kongregate Parameters:", 40, 110, 160, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblsKongregateParameters, 768 + 8) +GUICtrlSetColor($lblsKongregateParameters, $COLOR_WHITE) +GUICtrlSetFont($lblsKongregateParameters, 11.5, "", "", "Segoe UI") + +$inputsKongregateParameters = GUICtrlCreateInput("?params", 210, 105, 465, 30) +GUICtrlSetResizing($inputsKongregateParameters, 768 + 8) +GUICtrlSetColor($inputsKongregateParameters, $COLOR_WHITE) +GUICtrlSetBkColor($inputsKongregateParameters, $COLOR_BLACK) +GUICtrlSetFont($inputsKongregateParameters, 11.5, "", "", "Segoe UI") +GUICtrlSetCursor($inputsKongregateParameters, 5) + +;Kongregate help +$btnKongregateHelp = _Metro_CreateButton("?", 680, 105, 40, 30) +GUICtrlSetResizing($btnKongregateHelp, 768 + 8) + +;Launch additional Program Toggle +$tgbAdditionalProgram = _Metro_CreateToggle("Launch an additional program when starting the game (Discord, Spotify, ...)", 40, 160, 600, 30) +GUICtrlSetResizing($tgbAdditionalProgram, 768 + 8) + +$lblsAdditionalProgramPath = GUICtrlCreateLabel("C...", 120, 205, 600, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblsAdditionalProgramPath, 768 + 8) +GUICtrlSetColor($lblsAdditionalProgramPath, $COLOR_GRAY) +GUICtrlSetFont($lblsAdditionalProgramPath, 11.5, "", "", "Segoe UI") + +$browsesAdditionalProgramPath = _Metro_CreateButton("Browse...", 40, 200, 70, 30) +GUICtrlSetResizing($browsesAdditionalProgramPath, 768 + 8) + + +;Flash directory +$lblAdvancedWarning = GUICtrlCreateLabel("Do NOT modify the settings below unless you know what you're doing.", 40, 280, 600, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblAdvancedWarning, 768 + 8) +GUICtrlSetColor($lblAdvancedWarning, $COLOR_WHITE) +GUICtrlSetFont($lblAdvancedWarning, 11.5, "", "", "Segoe UI") + +$lblFlashProjectorInfo = GUICtrlCreateLabel("Path for flash projector file:", 40, 325, 600, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblFlashProjectorInfo, 768 + 8) +GUICtrlSetColor($lblFlashProjectorInfo, $COLOR_WHITE) +GUICtrlSetFont($lblFlashProjectorInfo, 11.5, "", "", "Segoe UI") + +$browsesFlashFile = _Metro_CreateButton("Browse...", 40, 350, 70, 30) +GUICtrlSetResizing($browsesFlashFile, 768 + 8) + +$lblsFlashFile = GUICtrlCreateLabel("C...", 120, 355, 600, 30, $SS_LEFTNOWORDWRAP) +GUICtrlSetResizing($lblsFlashFile, 768 + 8) +GUICtrlSetColor($lblsFlashFile, $COLOR_GRAY) +GUICtrlSetFont($lblsFlashFile, 11.5, "", "", "Segoe UI") + +;(Testing / AGC) +$tgbTesting = _Metro_CreateToggle("Connect to testing", 40, 400, 600, 30) +GUICtrlSetResizing($tgbTesting, 768 + 8) + +$tgbAGCLoader = _Metro_CreateToggle("Use AGCLoader instead of AssembleeGameClient", 40, 440, 600, 30) +GUICtrlSetResizing($tgbAGCLoader, 768 + 8) + +#EndRegion Others + +$ESCinfo = GUICtrlCreateLabel("Press ESC to cancel.", 40, 650, 690, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) +GUICtrlSetResizing($ESCinfo, 768 + 8) +GUICtrlSetColor($ESCinfo, $COLOR_WHITE) +GUICtrlSetFont($ESCinfo, 20, "", "", "Segoe UI Bold") +GUICtrlSetCursor($ESCinfo, -1) + +Local $r = "" +Local $tmp = "" +Local $noexit +_InitializeSettings() + +;remove fullscreen button function and stuff +$ControlBtnsAutoMode = False +GUISetState(@SW_SHOW) + +While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON + $noexit = _PrepareExit() + Case $GUI_MAXIMIZE_BUTTON + Case $GUI_MINIMIZE_BUTTON + GUISetState(@SW_MINIMIZE, $Form1) + Case $GUI_RESTORE_BUTTON + GUISetState(@SW_RESTORE, $Form1) + Case $GUI_MENU_BUTTON + GUICtrlSetState($lblMenu, 32) + + ;Create an Array containing menu button names + Local $MenuButtonsArray[12] = ["General", "Macros", "Hotkeys", "Ingame Keys", "Others", "", "Save & Exit", "Exit", "", "", "", "Reset settings"] + ; Open the metro Menu. See decleration of $MenuButtonsArray above. + Local $MenuSelect = _Metro_MenuStart($Form1, 150, $MenuButtonsArray) + Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. + Case "0" + _HideAll() + _ShowGeneral() + Case "1" + _HideAll() + _ShowMacros() + Case "2" + _HideAll() + _ShowHotkeys() + Case "3" + _HideAll() + _ShowIngame() + Case "4" + _HideAll() + _ShowOthers() + Case "6" + _SaveExit() + Case "7" + $noexit = _PrepareExit() + Case "11" + Local $doreset = MsgBox(52, "Reset settings", "Are you sure you want to reset all settings? This action can't be undone.") + If $doreset = 6 Then + _ResetSettings() + _InitializeSettings() + EndIf + EndSwitch + + #Region GENERALactions + Case $tgUseMacros + If _Metro_ToggleIsChecked($tgUseMacros) Then + _Metro_ToggleUnCheck($tgUseMacros) + Else + _Metro_ToggleCheck($tgUseMacros) + EndIf + + Case $tgUseHotkeys + If _Metro_ToggleIsChecked($tgUseHotkeys) Then + _Metro_ToggleUnCheck($tgUseHotkeys) + Else + _Metro_ToggleCheck($tgUseHotkeys) + EndIf + + Case $tgUseCustomCursor + If _Metro_ToggleIsChecked($tgUseCustomCursor) Then + _Metro_ToggleUnCheck($tgUseCustomCursor) + _Metro_DisableButton($browseCustomCursorPath) + Else + _Metro_ToggleCheck($tgUseCustomCursor) + _Metro_EnableButton($browseCustomCursorPath) + EndIf + Case $browseCustomCursorPath + _GUIDisable($Form1, 0, 30) + $r = FileOpenDialog("Choose cursor file", @ScriptDir & "\data\cursors", "Cursors (*.cur;*.ani) | All FIles (*.*)", 0, "", $Form1) + If $r <> "" Then + GUICtrlSetData($lblCustomCursorPath, $r) + EndIf + _GUIDisable($Form1, 0, 30) + + + Case $tgForceFocus + If _Metro_ToggleIsChecked($tgForceFocus) Then + _Metro_ToggleUnCheck($tgForceFocus) + Else + _Metro_ToggleCheck($tgForceFocus) + EndIf + ;MACROS + ;MACRO 1 + Case $tgMacro1 + If _Metro_ToggleIsChecked($tgMacro1) Then + _Metro_ToggleUnCheck($tgMacro1) + GUICtrlSetState($btnMacro1, 128) + GUICtrlSetBkColor($btnMacro1, "0x123c54") + GUICtrlSetState($inputMacro1, 128) + Else + _Metro_ToggleCheck($tgMacro1) + GUICtrlSetState($btnMacro1, 64) + GUICtrlSetBkColor($btnMacro1, "0x1E648C") + GUICtrlSetState($inputMacro1, 64) + EndIf + Case $btnMacro1 + $tmp = GUICtrlRead($btnMacro1) + GUICtrlSetData($btnMacro1, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnMacro1, $result[2]) + Else + GUICtrlSetData($btnMacro1, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + + + + + + ;MACRO 2 + Case $tgMacro2 + If _Metro_ToggleIsChecked($tgMacro2) Then + _Metro_ToggleUnCheck($tgMacro2) + GUICtrlSetState($btnMacro2, 128) + GUICtrlSetBkColor($btnMacro2, "0x123c54") + GUICtrlSetState($inputMacro2, 128) + Else + _Metro_ToggleCheck($tgMacro2) + GUICtrlSetState($btnMacro2, 64) + GUICtrlSetBkColor($btnMacro2, "0x1E648C") + GUICtrlSetState($inputMacro2, 64) + EndIf + Case $btnMacro2 + $tmp = GUICtrlRead($btnMacro2) + GUICtrlSetData($btnMacro2, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnMacro2, $result[2]) + Else + GUICtrlSetData($btnMacro2, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + ;MACRO 3 + Case $tgMacro3 + If _Metro_ToggleIsChecked($tgMacro3) Then + _Metro_ToggleUnCheck($tgMacro3) + GUICtrlSetState($btnMacro3, 128) + GUICtrlSetBkColor($btnMacro3, "0x123c54") + GUICtrlSetState($inputMacro3, 128) + Else + _Metro_ToggleCheck($tgMacro3) + GUICtrlSetState($btnMacro3, 64) + GUICtrlSetBkColor($btnMacro3, "0x1E648C") + GUICtrlSetState($inputMacro3, 64) + EndIf + Case $btnMacro3 + $tmp = GUICtrlRead($btnMacro3) + GUICtrlSetData($btnMacro3, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnMacro3, $result[2]) + Else + GUICtrlSetData($btnMacro3, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + ;MACRO 4 + Case $tgMacro4 + If _Metro_ToggleIsChecked($tgMacro4) Then + _Metro_ToggleUnCheck($tgMacro4) + GUICtrlSetState($btnMacro4, 128) + GUICtrlSetBkColor($btnMacro4, "0x123c54") + GUICtrlSetState($inputMacro4, 128) + Else + _Metro_ToggleCheck($tgMacro4) + GUICtrlSetState($btnMacro4, 64) + GUICtrlSetBkColor($btnMacro4, "0x1E648C") + GUICtrlSetState($inputMacro4, 64) + EndIf + Case $btnMacro4 + $tmp = GUICtrlRead($btnMacro4) + GUICtrlSetData($btnMacro4, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnMacro4, $result[2]) + Else + GUICtrlSetData($btnMacro4, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + ;HOTKEYS + + ;Hotkey 1 + Case $tgHotkey1 + If _Metro_ToggleIsChecked($tgHotkey1) Then + _Metro_ToggleUnCheck($tgHotkey1) + GUICtrlSetState($btnHotkey1, 128) + GUICtrlSetBkColor($btnHotkey1, "0x123c54") + Else + _Metro_ToggleCheck($tgHotkey1) + GUICtrlSetState($btnHotkey1, 64) + GUICtrlSetBkColor($btnHotkey1, "0x1E648C") + EndIf + Case $btnHotkey1 + $tmp = GUICtrlRead($btnHotkey1) + GUICtrlSetData($btnHotkey1, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey1, $result[2]) + Else + GUICtrlSetData($btnHotkey1, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + ;Hotkey 2 + Case $tgHotkey2 + If _Metro_ToggleIsChecked($tgHotkey2) Then + _Metro_ToggleUnCheck($tgHotkey2) + ConsoleWrite("Toggle $tgHotkey2 unchecked!" & @CRLF) + GUICtrlSetState($btnHotkey2, 128) + GUICtrlSetBkColor($btnHotkey2, "0x123c54") + Else + _Metro_ToggleCheck($tgHotkey2) + ConsoleWrite("Toggle $tgHotkey2 checked!" & @CRLF) + GUICtrlSetState($btnHotkey2, 64) + GUICtrlSetBkColor($btnHotkey2, "0x1E648C") + EndIf + Case $btnHotkey2 + $tmp = GUICtrlRead($btnHotkey2) + GUICtrlSetData($btnHotkey2, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey2, $result[2]) + Else + GUICtrlSetData($btnHotkey2, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + + ;Hotkey 3 + Case $tgHotkey3 + If _Metro_ToggleIsChecked($tgHotkey3) Then + _Metro_ToggleUnCheck($tgHotkey3) + ConsoleWrite("Toggle $tgHotkey3 unchecked!" & @CRLF) + GUICtrlSetState($btnHotkey3, 128) + GUICtrlSetBkColor($btnHotkey3, "0x123c54") + GUICtrlSetState($tgIncludeCursor, 128) + Else + _Metro_ToggleCheck($tgHotkey3) + ConsoleWrite("Toggle $tgHotkey3 checked!" & @CRLF) + GUICtrlSetState($btnHotkey3, 64) + GUICtrlSetBkColor($btnHotkey3, "0x1E648C") + GUICtrlSetState($tgIncludeCursor, 64) + EndIf + Case $btnHotkey3 + $tmp = GUICtrlRead($btnHotkey3) + GUICtrlSetData($btnHotkey3, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey3, $result[2]) + Else + GUICtrlSetData($btnHotkey3, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + ;Hotkey3+ + Case $tgIncludeCursor + If _Metro_ToggleIsChecked($tgIncludeCursor) Then + _Metro_ToggleUnCheck($tgIncludeCursor) + ConsoleWrite("Toggle $tgIncludeCursor unchecked!" & @CRLF) + Else + _Metro_ToggleCheck($tgIncludeCursor) + ConsoleWrite("Toggle $tgIncludeCursor checked!" & @CRLF) + EndIf + + ;Hotkey4,5 + Case $tgEnableAnchor + If _Metro_ToggleIsChecked($tgEnableAnchor) Then + _Metro_ToggleUnCheck($tgEnableAnchor) + ConsoleWrite("Toggle $tgEnableAnchor unchecked!" & @CRLF) + GUICtrlSetState($btnHotkey4, 128) + GUICtrlSetBkColor($btnHotkey4, "0x123c54") + GUICtrlSetState($btnHotkey5, 128) + GUICtrlSetBkColor($btnHotkey5, "0x123c54") + GUICtrlSetState($inputDefaultAnchor, 128) + Else + _Metro_ToggleCheck($tgEnableAnchor) + ConsoleWrite("Toggle $tgEnableAnchor checked!" & @CRLF) + GUICtrlSetState($btnHotkey4, 64) + GUICtrlSetBkColor($btnHotkey4, "0x1E648C") + GUICtrlSetState($btnHotkey5, 64) + GUICtrlSetBkColor($btnHotkey5, "0x1E648C") + GUICtrlSetState($inputDefaultAnchor, 64) + EndIf + Case $btnHotkey4 + $tmp = GUICtrlRead($btnHotkey4) + GUICtrlSetData($btnHotkey4, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey4, $result[2]) + Else + GUICtrlSetData($btnHotkey4, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + Case $btnHotkey5 + $tmp = GUICtrlRead($btnHotkey5) + GUICtrlSetData($btnHotkey5, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey5, $result[2]) + Else + GUICtrlSetData($btnHotkey5, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + + ;Hotkey 6 + Case $tgHotkey6 + If _Metro_ToggleIsChecked($tgHotkey6) Then + _Metro_ToggleUnCheck($tgHotkey6) + ConsoleWrite("Toggle $tgHotkey6 unchecked!" & @CRLF) + GUICtrlSetState($btnHotkey6, 128) + GUICtrlSetBkColor($btnHotkey6, "0x123c54") + Else + _Metro_ToggleCheck($tgHotkey6) + ConsoleWrite("Toggle $tgHotkey6 checked!" & @CRLF) + GUICtrlSetState($btnHotkey6, 64) + GUICtrlSetBkColor($btnHotkey6, "0x1E648C") + EndIf + Case $btnHotkey6 + $tmp = GUICtrlRead($btnHotkey6) + GUICtrlSetData($btnHotkey6, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey6, $result[2]) + Else + GUICtrlSetData($btnHotkey6, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + ;Hotkey 7 + Case $tgHotkey7 + If _Metro_ToggleIsChecked($tgHotkey7) Then + _Metro_ToggleUnCheck($tgHotkey7) + ConsoleWrite("Toggle $tgHotkey7 unchecked!" & @CRLF) + GUICtrlSetState($btnHotkey7, 128) + GUICtrlSetBkColor($btnHotkey7, "0x123c54") + Else + _Metro_ToggleCheck($tgHotkey7) + ConsoleWrite("Toggle $tgHotkey6 checked!" & @CRLF) + GUICtrlSetState($btnHotkey7, 64) + GUICtrlSetBkColor($btnHotkey7, "0x1E648C") + EndIf + Case $btnHotkey7 + $tmp = GUICtrlRead($btnHotkey7) + GUICtrlSetData($btnHotkey7, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey7, $result[2]) + Else + GUICtrlSetData($btnHotkey7, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + ;Hotkey 8 + Case $tgHotkey8 + If _Metro_ToggleIsChecked($tgHotkey8) Then + _Metro_ToggleUnCheck($tgHotkey8) + ConsoleWrite("Toggle $tgHotkey8 unchecked!" & @CRLF) + GUICtrlSetState($btnHotkey8, 128) + GUICtrlSetBkColor($btnHotkey8, "0x123c54") + Else + _Metro_ToggleCheck($tgHotkey8) + ConsoleWrite("Toggle $tgHotkey8 checked!" & @CRLF) + GUICtrlSetState($btnHotkey8, 64) + GUICtrlSetBkColor($btnHotkey8, "0x1E648C") + EndIf + Case $btnHotkey8 + $tmp = GUICtrlRead($btnHotkey8) + GUICtrlSetData($btnHotkey8, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnHotkey8, $result[2]) + Else + GUICtrlSetData($btnHotkey8, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + + #EndRegion GENERALactions + + #Region Ingame + ;CHAT + Case $btnIngame1 + $tmp = GUICtrlRead($btnIngame1) + GUICtrlSetData($btnIngame1, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnIngame1, $result[2]) + Else + GUICtrlSetData($btnIngame1, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + ;ABILITY + Case $btnIngame2 + $tmp = GUICtrlRead($btnIngame2) + GUICtrlSetData($btnIngame2, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnIngame2, $result[2]) + Else + GUICtrlSetData($btnIngame2, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + ;TELL + Case $btnIngame3 + $tmp = GUICtrlRead($btnIngame3) + GUICtrlSetData($btnIngame3, "PRESS KEY") + _GUIDisable($Form1, 0, 30) + $result = GetKeyInput() + If Not @error Then + GUICtrlSetData($btnIngame3, $result[2]) + Else + GUICtrlSetData($btnIngame3, $tmp) + EndIf + _GUIDisable($Form1, 0, 30) + #EndRegion Ingame + + #Region Others + Case $tgbKongregate + If _Metro_ToggleIsChecked($tgbKongregate) Then + _Metro_ToggleUnCheck($tgbKongregate) + ConsoleWrite("Toggle $tgbKongregate unchecked!" & @CRLF) + GUICtrlSetState($inputsKongregateParameters, 128) + Else + _Metro_ToggleCheck($tgbKongregate) + ConsoleWrite("Toggle $tgbKongregate checked!" & @CRLF) + GUICtrlSetState($inputsKongregateParameters, 64) + EndIf + + Case $btnKongregateHelp + ShellExecute("https://www.realmeye.com/wiki/using-the-adobe-flash-projector#kongregate") + + Case $tgbAdditionalProgram + If _Metro_ToggleIsChecked($tgbAdditionalProgram) Then + _Metro_ToggleUnCheck($tgbAdditionalProgram) + ConsoleWrite("Toggle $tgbAdditionalProgram unchecked!" & @CRLF) + _Metro_DisableButton($browsesAdditionalProgramPath) + Else + _Metro_ToggleCheck($tgbAdditionalProgram) + ConsoleWrite("Toggle $tgbAdditionalProgram checked!" & @CRLF) + _Metro_EnableButton($browsesAdditionalProgramPath) + EndIf + Case $browsesAdditionalProgramPath + _GUIDisable($Form1, 0, 30) + $r = FileOpenDialog("Choose Program", @ScriptDir, "All FIles (*.*)", 0, "", $Form1) + If $r <> "" Then + GUICtrlSetData($lblsAdditionalProgramPath, $r) + EndIf + _GUIDisable($Form1, 0, 30) + + + Case $browsesFlashFile + _GUIDisable($Form1, 0, 30) + $r = FileOpenDialog("Choose Flash Projector file", @ScriptDir & "\data\", "Executables (*.exe) | All FIles (*.*)", 0, "", $Form1) + If $r <> "" Then + GUICtrlSetData($lblsFlashFile, $r) + EndIf + _GUIDisable($Form1, 0, 30) + + + Case $tgbTesting + If _Metro_ToggleIsChecked($tgbTesting) Then + _Metro_ToggleUnCheck($tgbTesting) + Else + _Metro_ToggleCheck($tgbTesting) + EndIf + + + Case $tgbAGCLoader + If _Metro_ToggleIsChecked($tgbAGCLoader) Then + _Metro_ToggleUnCheck($tgbAGCLoader) + Else + _Metro_ToggleCheck($tgbAGCLoader) + EndIf + #EndRegion Others + + + EndSwitch +WEnd + + +Func _InitializeSettings() + $savedGeneral = GetGeneral() + $savedPaths = GetPaths() + $savedMacros = GetMacros() + $savedIngame = GetIngame() + $savedHotkeys = GetHotkeys() + + $newGeneral = $savedGeneral + $newPaths = $savedPaths + $newMacros = $savedMacros + $newIngame = $savedIngame + $newHotkeys = $savedHotkeys + + _SetGeneral() + _SetOthers() + _SetMacros() + _SetIngame() + _SetHotkeys() + + _HideAll() + _ShowGeneral() +EndFunc ;==>_InitializeSettings + + +Func _SetGeneral() + + ;Use Macros + If $savedGeneral[$bMacros][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgUseMacros) + Else + _Metro_ToggleUnCheck($tgUseMacros) + EndIf + + ;Use Hotkeys + If $savedGeneral[$bHotkeys][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgUseHotkeys) + Else + _Metro_ToggleUnCheck($tgUseHotkeys) + EndIf + + ;Use Custom cursor + If $savedGeneral[$bCustomCursor][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgUseCustomCursor) + _Metro_EnableButton($browseCustomCursorPath) + Else + _Metro_ToggleUnCheck($tgUseCustomCursor) + _Metro_DisableButton($browseCustomCursorPath) + EndIf + + ;Browse Cursor Path + GUICtrlSetData($lblCustomCursorPath, $savedPaths[$sCustomCursorPath][$cAIcontent]) + + ;Force game focus + If $savedGeneral[$bKeepWindowFocused][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgForceFocus) + Else + _Metro_ToggleUnCheck($tgForceFocus) + EndIf + + ;Game Window name + GUICtrlSetData($inputGameName, $savedGeneral[$sWindowName][$cAIcontent]) + +EndFunc ;==>_SetGeneral + +Func _SetOthers() + + ;Use Kongregate + If $savedGeneral[$bKongregate][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgbKongregate) + GUICtrlSetState($inputsKongregateParameters, 64) + Else + _Metro_ToggleUnCheck($tgbKongregate) + GUICtrlSetState($inputsKongregateParameters, 128) + EndIf + GUICtrlSetData($inputsKongregateParameters, $savedGeneral[$sKongregateParameters][$cAIcontent]) + + ;Launch additional program + If $savedGeneral[$bLaunchAdditionalProgram][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgbAdditionalProgram) + GUICtrlSetState($browsesAdditionalProgramPath, 64) + Else + _Metro_ToggleUnCheck($tgbAdditionalProgram) + GUICtrlSetState($browsesAdditionalProgramPath, 128) + EndIf + GUICtrlSetData($lblsAdditionalProgramPath, $savedGeneral[$sAdditionalProgramPath][$cAIcontent]) + GUICtrlSetData($lblsFlashFile, $savedPaths[$sFlashFile][$cAIcontent]) + + ;Testing, AGC + If $savedGeneral[$bTesting][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgbTesting) + Else + _Metro_ToggleUnCheck($tgbTesting) + EndIf + + If $savedGeneral[$bAGCLoader][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgbAGCLoader) + Else + _Metro_ToggleUnCheck($tgbAGCLoader) + EndIf + +EndFunc ;==>_SetOthers + + + + +Func _SetMacros() + + ;Macro 1 + If $savedMacros[$cmacro1][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgMacro1) + GUICtrlSetState($btnMacro1, 64) + GUICtrlSetBkColor($btnMacro1, "0x1E648C") + GUICtrlSetState($inputMacro1, 64) + Else + _Metro_ToggleUnCheck($tgMacro1) + GUICtrlSetState($btnMacro1, 128) + GUICtrlSetBkColor($btnMacro1, "0x123c54") + GUICtrlSetState($inputMacro1, 128) + EndIf + GUICtrlSetData($btnMacro1, $savedMacros[$cmacro1][$cAIKey]) + GUICtrlSetData($inputMacro1, $savedMacros[$cmacro1][$cAImacrotext]) + + ;Macro 2 + If $savedMacros[$cmacro2][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgMacro2) + GUICtrlSetState($btnMacro2, 64) + GUICtrlSetBkColor($btnMacro2, "0x1E648C") + GUICtrlSetState($inputMacro2, 64) + Else + _Metro_ToggleUnCheck($tgMacro2) + GUICtrlSetState($btnMacro2, 128) + GUICtrlSetBkColor($btnMacro2, "0x123c54") + GUICtrlSetState($inputMacro2, 128) + EndIf + GUICtrlSetData($btnMacro2, $savedMacros[$cmacro2][$cAIKey]) + GUICtrlSetData($inputMacro2, $savedMacros[$cmacro2][$cAImacrotext]) + + ;Macro 3 + If $savedMacros[$cmacro3][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgMacro3) + GUICtrlSetState($btnMacro3, 64) + GUICtrlSetBkColor($btnMacro3, "0x1E648C") + GUICtrlSetState($inputMacro3, 64) + Else + _Metro_ToggleUnCheck($tgMacro3) + GUICtrlSetState($btnMacro3, 128) + GUICtrlSetBkColor($btnMacro3, "0x123c54") + GUICtrlSetState($inputMacro3, 128) + EndIf + GUICtrlSetData($btnMacro3, $savedMacros[$cmacro3][$cAIKey]) + GUICtrlSetData($inputMacro3, $savedMacros[$cmacro3][$cAImacrotext]) + + ;Macro 4 + If $savedMacros[$cmacro4][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgMacro4) + GUICtrlSetState($btnMacro4, 64) + GUICtrlSetBkColor($btnMacro4, "0x1E648C") + GUICtrlSetState($inputMacro4, 64) + Else + _Metro_ToggleUnCheck($tgMacro4) + GUICtrlSetState($btnMacro4, 128) + GUICtrlSetBkColor($btnMacro4, "0x123c54") + GUICtrlSetState($inputMacro4, 128) + EndIf + GUICtrlSetData($btnMacro4, $savedMacros[$cmacro4][$cAIKey]) + GUICtrlSetData($inputMacro4, $savedMacros[$cmacro4][$cAImacrotext]) + +EndFunc ;==>_SetMacros + +Func _SetIngame() + + GUICtrlSetData($btnIngame1, $savedIngame[$igChat][$cAIKey]) + GUICtrlSetData($btnIngame2, $savedIngame[$igAbility][$cAIKey]) + GUICtrlSetData($btnIngame3, $savedIngame[$igTell][$cAIKey]) + GUICtrlSetData($inputCommandSymbol, $savedIngame[$igCommand][$cAIKey]) + +EndFunc ;==>_SetIngame + +Func _SetHotkeys() + ;Hotkeys 1 + If $savedHotkeys[$hkResetSize][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgHotkey1) + GUICtrlSetState($btnHotkey1, 64) + GUICtrlSetBkColor($btnHotkey1, "0x1E648C") + Else + _Metro_ToggleUnCheck($tgHotkey1) + GUICtrlSetState($btnHotkey1, 128) + GUICtrlSetBkColor($btnHotkey1, "0x123c54") + EndIf + GUICtrlSetData($btnHotkey1, $savedHotkeys[$hkResetSize][$cAIKey]) + + ;Hotkeys 2 + If $savedHotkeys[$hk43Maximize][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgHotkey2) + GUICtrlSetState($btnHotkey2, 64) + GUICtrlSetBkColor($btnHotkey2, "0x1E648C") + Else + _Metro_ToggleUnCheck($tgHotkey2) + GUICtrlSetState($btnHotkey2, 128) + GUICtrlSetBkColor($btnHotkey2, "0x123c54") + EndIf + GUICtrlSetData($btnHotkey2, $savedHotkeys[$hk43Maximize][$cAIKey]) + + ;Hotkeys 3 + If $savedHotkeys[$hkScreenshot][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgHotkey3) + GUICtrlSetState($btnHotkey3, 64) + GUICtrlSetBkColor($btnHotkey3, "0x1E648C") + GUICtrlSetState($tgIncludeCursor, 64) + Else + _Metro_ToggleUnCheck($tgHotkey3) + GUICtrlSetState($btnHotkey3, 128) + GUICtrlSetBkColor($btnHotkey3, "0x123c54") + GUICtrlSetState($tgIncludeCursor, 128) + EndIf + GUICtrlSetData($btnHotkey3, $savedHotkeys[$hkScreenshot][$cAIKey]) + + ;Hotkeys 3+ + If $savedGeneral[$bCursorOnScreenshot][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgIncludeCursor) + Else + _Metro_ToggleUnCheck($tgIncludeCursor) + EndIf + + ;Hotkeys 4,5 + If $savedGeneral[$bAnchor][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgEnableAnchor) + GUICtrlSetState($btnHotkey4, 64) + GUICtrlSetState($btnHotkey5, 64) + GUICtrlSetState($inputDefaultAnchor, 64) + GUICtrlSetBkColor($btnHotkey4, "0x1E648C") + GUICtrlSetBkColor($btnHotkey5, "0x1E648C") + Else + _Metro_ToggleUnCheck($tgEnableAnchor) + GUICtrlSetState($btnHotkey4, 128) + GUICtrlSetState($btnHotkey5, 128) + GUICtrlSetState($inputDefaultAnchor, 128) + GUICtrlSetBkColor($btnHotkey4, "0x123c54") + GUICtrlSetBkColor($btnHotkey5, "0x123c54") + EndIf + GUICtrlSetData($btnHotkey4, $savedHotkeys[$hkSetAnchor][$cAIKey]) + GUICtrlSetData($btnHotkey5, $savedHotkeys[$hkTPAnchor][$cAIKey]) + GUICtrlSetData($inputDefaultAnchor, $savedGeneral[$sDefaultAnchor][$cAIcontent]) + + + ;Hotkeys 6 + If $savedHotkeys[$hkIgnorePM][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgHotkey6) + GUICtrlSetState($btnHotkey6, 64) + GUICtrlSetBkColor($btnHotkey6, "0x1E648C") + Else + _Metro_ToggleUnCheck($tgHotkey6) + GUICtrlSetState($btnHotkey6, 128) + GUICtrlSetBkColor($btnHotkey6, "0x123c54") + EndIf + GUICtrlSetData($btnHotkey6, $savedHotkeys[$hkIgnorePM][$cAIKey]) + + ;Hotkeys 7 + If $savedHotkeys[$hkToggleFocus][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgHotkey7) + GUICtrlSetState($btnHotkey7, 64) + GUICtrlSetBkColor($btnHotkey7, "0x1E648C") + Else + _Metro_ToggleUnCheck($tgHotkey7) + GUICtrlSetState($btnHotkey7, 128) + GUICtrlSetBkColor($btnHotkey7, "0x123c54") + EndIf + GUICtrlSetData($btnHotkey7, $savedHotkeys[$hkToggleFocus][$cAIKey]) + + ;Hotkeys 8 + If $savedHotkeys[$hkActualFullscreen][$cAIactive] = 1 Then + _Metro_ToggleCheck($tgHotkey8) + GUICtrlSetState($btnHotkey8, 64) + GUICtrlSetBkColor($btnHotkey8, "0x1E648C") + Else + _Metro_ToggleUnCheck($tgHotkey8) + GUICtrlSetState($btnHotkey8, 128) + GUICtrlSetBkColor($btnHotkey8, "0x123c54") + EndIf + GUICtrlSetData($btnHotkey8, $savedHotkeys[$hkActualFullscreen][$cAIKey]) + +EndFunc ;==>_SetHotkeys + + + +Func _HideAll() + GUICtrlSetState($tgUseMacros, 32) + GUICtrlSetState($tgUseHotkeys, 32) + GUICtrlSetState($tgUseCustomCursor, 32) + GUICtrlSetState($lblCustomCursorPath, 32) + GUICtrlSetState($browseCustomCursorPath, 32) + GUICtrlSetState($tgForceFocus, 32) + GUICtrlSetState($lblGameName, 32) + GUICtrlSetState($inputGameName, 32) + + GUICtrlSetState($tgMacro1, 32) + GUICtrlSetState($btnMacro1, 32) + GUICtrlSetState($inputMacro1, 32) + + GUICtrlSetState($tgMacro2, 32) + GUICtrlSetState($btnMacro2, 32) + GUICtrlSetState($inputMacro2, 32) + + GUICtrlSetState($tgMacro3, 32) + GUICtrlSetState($btnMacro3, 32) + GUICtrlSetState($inputMacro3, 32) + + GUICtrlSetState($tgMacro4, 32) + GUICtrlSetState($btnMacro4, 32) + GUICtrlSetState($inputMacro4, 32) + + GUICtrlSetState($tgHotkey1, 32) + GUICtrlSetState($btnHotkey1, 32) + GUICtrlSetState($lblHotkey1, 32) + + GUICtrlSetState($tgHotkey2, 32) + GUICtrlSetState($btnHotkey2, 32) + GUICtrlSetState($lblHotkey2, 32) + + GUICtrlSetState($tgHotkey3, 32) + GUICtrlSetState($btnHotkey3, 32) + GUICtrlSetState($lblHotkey3, 32) + + GUICtrlSetState($tgIncludeCursor, 32) + + GUICtrlSetState($tgEnableAnchor, 32) + GUICtrlSetState($btnHotkey4, 32) + GUICtrlSetState($btnHotkey5, 32) + GUICtrlSetState($inputDefaultAnchor, 32) + GUICtrlSetState($lblDefaultAnchor, 32) + GUICtrlSetState($lblHotkey4, 32) + GUICtrlSetState($lblHotkey5, 32) + + GUICtrlSetState($tgHotkey6, 32) + GUICtrlSetState($btnHotkey6, 32) + GUICtrlSetState($lblHotkey6, 32) + + GUICtrlSetState($tgHotkey7, 32) + GUICtrlSetState($btnHotkey7, 32) + GUICtrlSetState($lblHotkey7, 32) + + GUICtrlSetState($tgHotkey8, 32) + GUICtrlSetState($btnHotkey8, 32) + GUICtrlSetState($lblHotkey8, 32) + + GUICtrlSetState($btnIngame1, 32) + GUICtrlSetState($btnIngame2, 32) + GUICtrlSetState($btnIngame3, 32) + GUICtrlSetState($inputCommandSymbol, 32) + GUICtrlSetState($lblIngame1, 32) + GUICtrlSetState($lblIngame2, 32) + GUICtrlSetState($lblIngame3, 32) + GUICtrlSetState($lblIngame4, 32) + + GUICtrlSetState($tgbKongregate, 32) + GUICtrlSetState($lblsKongregateParameters, 32) + GUICtrlSetState($inputsKongregateParameters, 32) + GUICtrlSetState($btnKongregateHelp, 32) + GUICtrlSetState($tgbAdditionalProgram, 32) + GUICtrlSetState($lblsAdditionalProgramPath, 32) + GUICtrlSetState($browsesAdditionalProgramPath, 32) + GUICtrlSetState($lblAdvancedWarning, 32) + GUICtrlSetState($lblFlashProjectorInfo, 32) + GUICtrlSetState($browsesFlashFile, 32) + GUICtrlSetState($lblsFlashFile, 32) + GUICtrlSetState($tgbTesting, 32) + GUICtrlSetState($tgbAGCLoader, 32) + + + GUICtrlSetState($ESCinfo, 32) +EndFunc ;==>_HideAll + +Func _ShowGeneral() + GUICtrlSetState($tgUseMacros, 16) + GUICtrlSetState($tgUseHotkeys, 16) + GUICtrlSetState($tgUseCustomCursor, 16) + GUICtrlSetState($lblCustomCursorPath, 16) + GUICtrlSetState($browseCustomCursorPath, 16) + GUICtrlSetState($tgForceFocus, 16) + GUICtrlSetState($lblGameName, 16) + GUICtrlSetState($inputGameName, 16) +EndFunc ;==>_ShowGeneral + +Func _ShowMacros() + GUICtrlSetState($tgMacro1, 16) + GUICtrlSetState($btnMacro1, 16) + GUICtrlSetState($inputMacro1, 16) + + GUICtrlSetState($tgMacro2, 16) + GUICtrlSetState($btnMacro2, 16) + GUICtrlSetState($inputMacro2, 16) + + GUICtrlSetState($tgMacro3, 16) + GUICtrlSetState($btnMacro3, 16) + GUICtrlSetState($inputMacro3, 16) + + GUICtrlSetState($tgMacro4, 16) + GUICtrlSetState($btnMacro4, 16) + GUICtrlSetState($inputMacro4, 16) + +EndFunc ;==>_ShowMacros + +Func _ShowHotkeys() + GUICtrlSetState($tgHotkey1, 16) + GUICtrlSetState($btnHotkey1, 16) + GUICtrlSetState($lblHotkey1, 16) + + GUICtrlSetState($tgHotkey2, 16) + GUICtrlSetState($btnHotkey2, 16) + GUICtrlSetState($lblHotkey2, 16) + + GUICtrlSetState($tgHotkey3, 16) + GUICtrlSetState($btnHotkey3, 16) + GUICtrlSetState($lblHotkey3, 16) + + GUICtrlSetState($tgIncludeCursor, 16) + + GUICtrlSetState($tgEnableAnchor, 16) + GUICtrlSetState($btnHotkey4, 16) + GUICtrlSetState($btnHotkey5, 16) + GUICtrlSetState($inputDefaultAnchor, 16) + GUICtrlSetState($lblDefaultAnchor, 16) + GUICtrlSetState($lblHotkey4, 16) + GUICtrlSetState($lblHotkey5, 16) + + GUICtrlSetState($tgHotkey6, 16) + GUICtrlSetState($btnHotkey6, 16) + GUICtrlSetState($lblHotkey6, 16) + + GUICtrlSetState($tgHotkey7, 16) + GUICtrlSetState($btnHotkey7, 16) + GUICtrlSetState($lblHotkey7, 16) + + GUICtrlSetState($tgHotkey8, 16) + GUICtrlSetState($btnHotkey8, 16) + GUICtrlSetState($lblHotkey8, 16) +EndFunc ;==>_ShowHotkeys + +Func _ShowIngame() + + GUICtrlSetState($btnIngame1, 16) + GUICtrlSetState($btnIngame2, 16) + GUICtrlSetState($btnIngame3, 16) + GUICtrlSetState($inputCommandSymbol, 16) + GUICtrlSetState($lblIngame1, 16) + GUICtrlSetState($lblIngame2, 16) + GUICtrlSetState($lblIngame3, 16) + GUICtrlSetState($lblIngame4, 16) +EndFunc ;==>_ShowIngame + + +Func _ShowOthers() + GUICtrlSetState($tgbKongregate, 16) + GUICtrlSetState($lblsKongregateParameters, 16) + GUICtrlSetState($inputsKongregateParameters, 16) + GUICtrlSetState($btnKongregateHelp, 16) + GUICtrlSetState($tgbAdditionalProgram, 16) + GUICtrlSetState($lblsAdditionalProgramPath, 16) + GUICtrlSetState($browsesAdditionalProgramPath, 16) + GUICtrlSetState($lblAdvancedWarning, 16) + GUICtrlSetState($lblFlashProjectorInfo, 16) + GUICtrlSetState($browsesFlashFile, 16) + GUICtrlSetState($lblsFlashFile, 16) + GUICtrlSetState($tgbTesting, 16) + GUICtrlSetState($tgbAGCLoader, 16) +EndFunc ;==>_ShowOthers + + + + +Func _ReadGUI() + #Region General + If _Metro_ToggleIsChecked($tgUseMacros) Then + $newGeneral[$bMacros][$cAIactive] = 1 + Else + $newGeneral[$bMacros][$cAIactive] = 0 + EndIf + + If _Metro_ToggleIsChecked($tgUseHotkeys) Then + $newGeneral[$bHotkeys][$cAIactive] = 1 + Else + $newGeneral[$bHotkeys][$cAIactive] = 0 + EndIf + + If _Metro_ToggleIsChecked($tgUseCustomCursor) Then + $newGeneral[$bCustomCursor][$cAIactive] = 1 + Else + $newGeneral[$bCustomCursor][$cAIactive] = 0 + EndIf + + $newPaths[$sCustomCursorPath][$cAIcontent] = GUICtrlRead($lblCustomCursorPath) + + If _Metro_ToggleIsChecked($tgForceFocus) Then + $newGeneral[$bKeepWindowFocused][$cAIactive] = 1 + Else + $newGeneral[$bKeepWindowFocused][$cAIactive] = 0 + EndIf + + $newGeneral[$sWindowName][$cAIcontent] = GUICtrlRead($inputGameName) + #EndRegion General + + #Region Macros + ;Macro 1 + If _Metro_ToggleIsChecked($tgMacro1) Then + $newMacros[$cmacro1][$cAIactive] = 1 + Else + $newMacros[$cmacro1][$cAIactive] = 0 + EndIf + $newMacros[$cmacro1][$cAIKey] = GUICtrlRead($btnMacro1) + $newMacros[$cmacro1][$cAImacrotext] = GUICtrlRead($inputMacro1) + + ;Macro 2 + If _Metro_ToggleIsChecked($tgMacro2) Then + $newMacros[$cmacro2][$cAIactive] = 1 + Else + $newMacros[$cmacro2][$cAIactive] = 0 + EndIf + $newMacros[$cmacro2][$cAIKey] = GUICtrlRead($btnMacro2) + $newMacros[$cmacro2][$cAImacrotext] = GUICtrlRead($inputMacro2) + + ;Macro 3 + If _Metro_ToggleIsChecked($tgMacro3) Then + $newMacros[$cmacro3][$cAIactive] = 1 + Else + $newMacros[$cmacro3][$cAIactive] = 0 + EndIf + $newMacros[$cmacro3][$cAIKey] = GUICtrlRead($btnMacro3) + $newMacros[$cmacro3][$cAImacrotext] = GUICtrlRead($inputMacro3) + + ;Macro 4 + If _Metro_ToggleIsChecked($tgMacro4) Then + $newMacros[$cmacro4][$cAIactive] = 1 + Else + $newMacros[$cmacro4][$cAIactive] = 0 + EndIf + $newMacros[$cmacro4][$cAIKey] = GUICtrlRead($btnMacro4) + $newMacros[$cmacro4][$cAImacrotext] = GUICtrlRead($inputMacro4) + #EndRegion Macros + + #Region Hotkeys + ;Hotkey 1 + If _Metro_ToggleIsChecked($tgHotkey1) Then + $newHotkeys[$hkResetSize][$cAIactive] = 1 + Else + $newHotkeys[$hkResetSize][$cAIactive] = 0 + EndIf + $newHotkeys[$hkResetSize][$cAIKey] = GUICtrlRead($btnHotkey1) + + ;Hotkey 2 + If _Metro_ToggleIsChecked($tgHotkey2) Then + $newHotkeys[$hk43Maximize][$cAIactive] = 1 + Else + $newHotkeys[$hk43Maximize][$cAIactive] = 0 + EndIf + $newHotkeys[$hk43Maximize][$cAIKey] = GUICtrlRead($btnHotkey2) + + ;Hotkey 3 + If _Metro_ToggleIsChecked($tgHotkey3) Then + $newHotkeys[$hkScreenshot][$cAIactive] = 1 + Else + $newHotkeys[$hkScreenshot][$cAIactive] = 0 + EndIf + $newHotkeys[$hkScreenshot][$cAIKey] = GUICtrlRead($btnHotkey3) + + ;Hotkey 3+ + If _Metro_ToggleIsChecked($tgIncludeCursor) Then + $newGeneral[$bCursorOnScreenshot][$cAIactive] = 1 + Else + $newGeneral[$bCursorOnScreenshot][$cAIactive] = 0 + EndIf + + ;Hotkey 4,5 + If _Metro_ToggleIsChecked($tgEnableAnchor) Then + $newGeneral[$bAnchor][$cAIactive] = 1 + Else + $newGeneral[$bAnchor][$cAIactive] = 0 + EndIf + $newHotkeys[$hkSetAnchor][$cAIKey] = GUICtrlRead($btnHotkey4) + $newHotkeys[$hkTPAnchor][$cAIKey] = GUICtrlRead($btnHotkey5) + $newGeneral[$sDefaultAnchor][$cAIcontent] = GUICtrlRead($inputDefaultAnchor) + + ;Hotkey 6 + If _Metro_ToggleIsChecked($tgHotkey6) Then + $newHotkeys[$hkIgnorePM][$cAIactive] = 1 + Else + $newHotkeys[$hkIgnorePM][$cAIactive] = 0 + EndIf + $newHotkeys[$hkIgnorePM][$cAIKey] = GUICtrlRead($btnHotkey6) + + ;Hotkey 7 + If _Metro_ToggleIsChecked($tgHotkey7) Then + $newHotkeys[$hkToggleFocus][$cAIactive] = 1 + Else + $newHotkeys[$hkToggleFocus][$cAIactive] = 0 + EndIf + $newHotkeys[$hkToggleFocus][$cAIKey] = GUICtrlRead($btnHotkey7) + + ;Hotkey 8 + If _Metro_ToggleIsChecked($tgHotkey8) Then + $newHotkeys[$hkActualFullscreen][$cAIactive] = 1 + Else + $newHotkeys[$hkActualFullscreen][$cAIactive] = 0 + EndIf + $newHotkeys[$hkActualFullscreen][$cAIKey] = GUICtrlRead($btnHotkey8) + + #EndRegion Hotkeys + + #Region Ingame + $newIngame[$igChat][$cAIKey] = GUICtrlRead($btnIngame1) + $newIngame[$igAbility][$cAIKey] = GUICtrlRead($btnIngame2) + $newIngame[$igTell][$cAIKey] = GUICtrlRead($btnIngame3) + $newIngame[$igCommand][$cAIKey] = GUICtrlRead($inputCommandSymbol) + + #EndRegion Ingame + + + + #Region Others + If _Metro_ToggleIsChecked($tgbKongregate) Then + $newGeneral[$bKongregate][$cAIactive] = 1 + Else + $newGeneral[$bKongregate][$cAIactive] = 0 + EndIf + + $newGeneral[$sKongregateParameters][$cAIcontent] = GUICtrlRead($inputsKongregateParameters) + + If _Metro_ToggleIsChecked($tgbAdditionalProgram) Then + $newGeneral[$bLaunchAdditionalProgram][$cAIactive] = 1 + Else + $newGeneral[$bLaunchAdditionalProgram][$cAIactive] = 0 + EndIf + + + $newGeneral[$sAdditionalProgramPath][$cAIcontent] = GUICtrlRead($lblsAdditionalProgramPath) + $newPaths[$sFlashFile][$cAIcontent] = GUICtrlRead($lblsFlashFile) + + If _Metro_ToggleIsChecked($tgbTesting) Then + $newGeneral[$bTesting][$cAIactive] = 1 + Else + $newGeneral[$bTesting][$cAIactive] = 0 + EndIf + + + If _Metro_ToggleIsChecked($tgbAGCLoader) Then + $newGeneral[$bAGCLoader][$cAIactive] = 1 + Else + $newGeneral[$bAGCLoader][$cAIactive] = 0 + EndIf + + #EndRegion Others + + Local $differ = 0 + $differ += _Compare2DArrays($savedGeneral, $newGeneral) + $differ += _Compare2DArrays($savedPaths, $newPaths) + $differ += _Compare2DArrays($savedMacros, $newMacros) + $differ += _Compare2DArrays($savedIngame, $newIngame) + $differ += _Compare2DArrays($savedHotkeys, $newHotkeys) + Return $differ +EndFunc ;==>_ReadGUI + +Func _CheckDuplicateKeys($macros, $hotkeys) + Local $AllDuplicates = "Unable to save settings. One ore more Hotkeys/Macros use the SAME KEY. Please choose a different key or disable one of the features. " & @CRLF & @CRLF & "The following duplicates were found: " & @CRLF + Local $iErrors = 0 + For $i = 0 To UBound($macros) - 1 + If $macros[$i][$cAIactive] = 1 Then + For $j = 0 To UBound($hotkeys) - 1 + If $hotkeys[$j][$cAIactive] = 1 Then + If $macros[$i][$cAIKey] = $hotkeys[$j][$cAIKey] Then + $AllDuplicates = $AllDuplicates & "Macro " & $i & " and Hotkey '" & $hotkeys[$j][$cAIdescription] & "' both use '" & $macros[$i][$cAIKey] & "'" & @CRLF + $iErrors += 1 + Else + EndIf + + EndIf + Next + EndIf + + Next + + For $i = 0 To UBound($macros) - 1 + If $macros[$i][$cAIactive] = 1 Then + For $j = 0 To UBound($macros) - 1 + If $macros[$j][$cAIactive] = 1 And $i <> $j Then + If $macros[$i][$cAIKey] = $macros[$j][$cAIKey] Then + $AllDuplicates = $AllDuplicates & "Macro '" & $i & "' and Macro '" & $j & "' both use '" & $macros[$i][$cAIKey] & "'" & @CRLF + $iErrors += 1 + EndIf + EndIf + Next + EndIf + Next + + For $i = 0 To UBound($hotkeys) - 1 + If $hotkeys[$i][$cAIactive] = 1 Then + For $j = 0 To UBound($hotkeys) - 1 + If $hotkeys[$j][$cAIactive] = 1 And $i <> $j Then + If $hotkeys[$i][$cAIKey] = $hotkeys[$j][$cAIKey] Then + $AllDuplicates = $AllDuplicates & "Hotkey '" & $hotkeys[$i][$cAIdescription] & "' and Hotkey '" & $hotkeys[$j][$cAIdescription] & "' both use '" & $hotkeys[$i][$cAIKey] & "'" & @CRLF + $iErrors += 1 + EndIf + EndIf + Next + EndIf + Next + $AllDuplicates = $iErrors & $AllDuplicates + Return $AllDuplicates +EndFunc ;==>_CheckDuplicateKeys + + +Func _PrepareExit() + Local $changesMade = _ReadGUI() + If $changesMade > 0 Then + Local $descision = MsgBox(35, "Save configuration?", "Do you want to save your changes?") + + If $descision = 6 Then + ; Save to csv + _SaveExit(1) + ElseIf $descision = 2 Then + Return 0 + Else + _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! + Exit + EndIf + Else + _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! + Exit + EndIf +EndFunc ;==>_PrepareExit + + + +Func _SaveExit($skipCheck = 0) + + If Not $skipCheck = 1 Then + Local $changesMade = _ReadGUI() + EndIf + + Local $compared = _CheckDuplicateKeys($newMacros, $newHotkeys) + + $res = StringLeft($compared, 1) + $compared = StringTrimLeft($compared, 1) + + If $res > 0 Then + MsgBox(4096 + 16, "Unable to save settings", $compared) + Return -1 + EndIf + + For $i = 0 To UBound($newPaths) - 1 + $newPaths[$i][$cAIcontent] = _ConvertPath($newPaths[$i][$cAIcontent]) + Next + _SaveToCSV($pathGeneral, $newGeneral) + _SaveToCSV($pathPaths, $newPaths) + _SaveToCSV($pathMacros, $newMacros) + _SaveToCSV($pathIngame, $newIngame) + _SaveToCSV($pathHotkeys, $newHotkeys) + _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! + Exit + +EndFunc ;==>_SaveExit + + +; Autor: Faweyr +; Function: GetKeyInput($sTime,$sBack) +; Parameter: $sTime = Time to wait and check for pressed Keys +; $sBack = the kind of Result +; 0 = Array[3] = ["_ispressed"-Code , "Send"-Code , Name of Key] +; 1 = "_ispressed"-Code +; 2 = "Send"-Code +; 3 = Name of Key +; Includes: +Func GetKeyInput($sTime = 5000, $sBack = 0) + $sTimer = TimerInit() + $sDll = DllOpen("user32.dll") + Local $sList[][3] = [[05, "none", "1Mouse"], [06, "none", "2Mouse"], [04, "none", "MiddleMouse"], [08, "{BACKSPACE}", "Backspace"], [09, "{TAB}", "Tab"], [0 & "D", "{ENTER}", "Enter"], _ + ["A" & 0, "{LSHIFT}", "Left Shift"], ["A" & 1, "{RSHIFT}", "Right Shift"], _ + [13, "{Pause}", "Pause"], [14, "{CAPSLOCK}", "Caps Lock"], [20, "{SPACE}", "Spacebar"], [21, "{PGUP}", "Page Up"], [22, "{PGDN}", "Page Down"], [23, "{End}", "End"], _ + [24, "{Home}", "Home"], [25, "{Left}", "Left Arrow"], [26, "{UP}", "Up Arrow"], [27, "{Right}", "Right Arrow"], [28, "{Down}", "Down Arrow"], [12, "{ALT}", "Alt"], [5 & "C", "{RWIN}", "Right Windows"], _ + [2 & "C", "{PRINTSCREEN}", "Print Screen"], [2 & "D", "{INS}", "Ins"], [2 & "E", "{DELETE}", "Del"], [30, 0, "0"], [31, 1, "1"], [32, 2, "2"], _ + [33, 3, "3"], [34, 4, "4"], [35, 5, "5"], [36, 6, "6"], [37, 7, "7"], [38, 8, "8"], [39, 9, "9"], _ + [41, "a", "A"], [42, "b", "B"], [43, "c", "C"], [44, "d", "D"], [45, "e", "E"], [46, "f", "F"], [47, "g", "G"], _ + [48, "h", "H"], [49, "i", "I"], [4 & "A", "j", "J"], [4 & "B", "k", "K"], [4 & "C", "l", "L"], [4 & "D", "m", "M"], [4 & "E", "n", "N"], _ + [4 & "F", "o", "O"], [50, "p", "P"], [51, "q", "Q"], [52, "r", "R"], [53, "s", "S"], [54, "t", "T"], [55, "u", "U"], _ + [56, "v", "V"], [57, "w", "W"], [58, "x", "X"], [59, "y", "Y"], [5 & "A", "z", "Z"], [60, "{NUMPAD0}", "Num 0"], [61, "{NUMPAD1}", "Num 1"], _ + [62, "{NUMPAD2}", "Num 2"], [63, "{NUMPAD3}", "Num 3"], [64, "{NUMPAD4}", "Num 4"], [65, "{NUMPAD5}", "Num 5"], [66, "{NUMPAD6}", "Num 6"], [67, "{NUMPAD7}", "Num 7"], [68, "{NUMPAD8}", "Num 8"], _ + [69, "{NUMPAD9}", "Num 9"], [6 & "A", "{NUMPADMULT}", "Multiply"], [6 & "B", "{NUMPADADD}", "Add"], [6 & "C", "{NUMPADENTER}", "Separator"], [6 & "D", "{NUMPADSUB}", "Subtract"], [6 & "E", "{NUMPADDOT}", "Decimal"], [6 & "F", "{NUMPADDIV}", "Divide"], _ + [70, "{F1}", "F1"], [71, "{F2}", "F2"], [72, "{F3}", "F3"], [73, "{F4}", "F4"], [74, "{F5}", "F5"], [75, "{F6}", "F6"], [76, "{F8}", "F7"], _ + [77, "{F8}", "F8"], [78, "{F9}", "F9"], [79, "{F10}", "F10"], [7 & "A", "{F11}", "F11"], [7 & "B", "{F12}", "F12"], [90, "{NUMLOCK}", "Num Lock"], [91, "{SCROLLLOCK}", "Scroll Lock"], _ + ["A" & 2, "{LCTRL}", "Left CTRL"], ["A" & 3, "{RCTRL}", "Right CTRL"], ["A" & 4, "{LALT}", "Left Menu"], ["A" & 5, "{RALT}", "Right Menu"], [5 & "B", "{LWIN}", "Left Windows"]] + GUICtrlSetState($ESCinfo, 16) + Do + For $i = 0 To UBound($sList) - 1 Step 1 + If _IsPressed($sList[$i][0], $sDll) Then + DllClose($sDll) + If $sBack <> 0 Then + Return $sList[$i][$sBack - 1] + Else + Local $sResult[3] = [$sList[$i][0], $sList[$i][1], $sList[$i][2]] + GUICtrlSetState($ESCinfo, 32) + Return $sResult + EndIf + EndIf + Next + Until _IsPressed("1B") = 1 Or $sTime <= TimerDiff($sTimer) + GUICtrlSetState($ESCinfo, 32) + DllClose($sDll) + SetError(1) +EndFunc ;==>GetKeyInput diff --git a/source/SimpleR.au3 b/source/SimpleR.au3 new file mode 100644 index 0000000..ca188db --- /dev/null +++ b/source/SimpleR.au3 @@ -0,0 +1,646 @@ +#Region ;**** Directives created by AutoIt3Wrapper_GUI **** +#AutoIt3Wrapper_Icon=..\data\Icons\SimpleR.ico +#AutoIt3Wrapper_Compression=0 +#AutoIt3Wrapper_Res_Description=Simple launcher to play RotMG +#AutoIt3Wrapper_Res_Fileversion=1.0.0.0 +#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p +#AutoIt3Wrapper_Res_LegalCopyright=GerRudi +#AutoIt3Wrapper_Res_Language=1033 +#AutoIt3Wrapper_Res_HiDpi=y +#AutoIt3Wrapper_Run_Au3Stripper=y +#Au3Stripper_Parameters=/so /rm /pe +#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** +#Region +#EndRegion + +#include ;_IsPressed +#include "./Include/LoadSettings.au3" ;for hotkeys / macros +#include +#include +#include ;for screenshot +#include ; for file-name for screenshot +#include "./Include/IsPressed_UDF.au3" +#include +#include +#include "./Include/InitialSetup.au3" +#include "./Include/ResizeStuff.au3" + +#Region MetroGUI +;YOU NEED TO EXCLUDE FOLLOWING FUNCTIONS FROM AU3STRIPPER, OTHERWISE IT WON'T WORK: +#Au3Stripper_Ignore_Funcs=_iHoverOn,_iHoverOff,_iFullscreenToggleBtn,_cHvr_CSCP_X64,_cHvr_CSCP_X86,_iControlDelete +;Please not that Au3Stripper will show errors. You can ignore them as long as you use the above Au3Stripper_Ignore_Funcs parameters. +#EndRegion MetroGUI + + + +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("TrayAutoPause", 0) ; no auto pause for tray +TraySetIcon(@ScriptFullPath, 0) + + +; ########################################## VARIABLES ################################################ +Global $hWnd_FP ;path to the config file +Local $t = _ScreenCompatibility() +Global $AF_compatible +Global $AF_active = 0 +Global $Dkstp_w = @DesktopWidth +Global $Dkstp_h = @DesktopHeight +If IsArray($t) Then + $AF_compatible = 1 +Else + $AF_compatible = 0 +EndIf + +; ########################################## FUNCTION CALLS ########################################### +main() ;main call +end() ;end call + + + +;############TODO: compare hotkeys in Settings.au3 + +AutoItSetOption("SendKeyDelay", 1) +AutoItSetOption("SendKeyDownDelay", 1) + +Func main() + + $savedGeneral = GetGeneral() + $savedPaths = GetPaths() + + If Not (FileExists($savedPaths[$sFlashFile][$cAIcontent])) Then + _Welcome() + + EndIf + + $savedMacros = GetMacros() + $savedIngame = GetIngame() + $savedHotkeys = GetHotkeys() + $savedMacros = _ClearKeys($savedMacros) + $savedHotkeys = _ClearKeys($savedHotkeys) + $savedIngame = _ClearKeys($savedIngame, 1) + + $chat = "{" & $savedIngame[$igChat][$cAIKey] & "}" + $ability = "{" & $savedIngame[$igAbility][$cAIKey] & "}" + $tell = "{" & $savedIngame[$igTell][$cAIKey] & "}" + + $SWF = _GetSWF() + + _TrayItems() + + ;Run Additional Program on Startup + If $savedGeneral[$bLaunchAdditionalProgram][$cAIactive] = 1 Then + Run($savedGeneral[$sAdditionalProgramPath][$cAIcontent]) + EndIf + + #Region StartGame + Local $bProjectorExists = FileExists($savedPaths[$sFlashFile][$cAIcontent]) + If $bProjectorExists Then + If $savedGeneral[$bTesting][$cAIactive] = 0 Then ; bTesting = 0? (false) + If $savedGeneral[$bKongregate][$cAIactive] = 1 Then ; bKongregate = 1? (true) + Run($savedPaths[$sFlashFile][$cAIcontent] & ' ' & $SWF[$cSWFproduction][$cSWFloader] & $savedGeneral[$sKongregateParameters][$cAIcontent]) + Else + If $savedGeneral[$bAGCLoader][$cAIactive] = 0 Then ;bAGCLoader 0 0? (false) + ;run AGCLIENT + Run($savedPaths[$sFlashFile][$cAIcontent] & ' ' & $SWF[$cSWFproduction][$cSWFclient]) + Else + ;run AGCLOADER + Run($savedPaths[$sFlashFile][$cAIcontent] & ' ' & $SWF[$cSWFproduction][$cSWFloader]) + EndIf + + EndIf + + Else + ;Run Testing##### + If $savedGeneral[$bAGCLoader][$cAIactive] = 0 Then ;bAGCLoader 0 0? (false) + ;run AGCLIENT + Run($savedPaths[$sFlashFile][$cAIcontent] & ' ' & $SWF[$cSWFtesting][$cSWFclient]) + Else + ;run AGCLOADER + Run($savedPaths[$sFlashFile][$cAIcontent] & ' ' & $SWF[$cSWFtesting][$cSWFloader]) + EndIf + EndIf + + Else + MsgBox(16, "Error", "Could not find Flash Projector at '" & $savedPaths[$sFlashFile][$cAIcontent] & "'") + Exit + EndIf + #EndRegion StartGame + + + Global $WindowClass = "[CLASS:ShockwaveFlash]" ; HANDLE for window rename + If $savedGeneral[$sWindowName][$cAIcontent] <> "" Then ;sWindowName + WinWait($WindowClass, "", 2) + WinSetTitle($WindowClass, '', $savedGeneral[$sWindowName][$cAIcontent]) + EndIf + Global $hWnd = WinGetHandle($WindowClass) + + _solutionchange() + Local $pid = WinGetProcess($WindowClass) + ProcessSetPriority($pid, 4) + + If $savedGeneral[$bKeepWindowFocused][$cAIactive] = 1 Then + TrayTip("Warning", "Force Focus is activated! Use the hotkey or rightclick the Icon to disable! " & "You can deactivate it permanently in the Settings. ", 5, 2) + EndIf + + If $savedGeneral[$bCustomCursor][$cAIactive] = 1 And FileExists($savedPaths[$sCustomCursorPath][$cAIcontent]) Then + _SetCursor($savedPaths[$sCustomCursorPath][$cAIcontent], $OCR_NORMAL) + EndIf + + While WinExists($hWnd) + + + If $savedGeneral[$bKeepWindowFocused][$cAIactive] = 1 Then ;bKeepWindowFocused - Warning: aggressive! + If Not WinActive($hWnd) Then + WinActivate($hWnd) + EndIf + EndIf + + ;MACROS + If $savedGeneral[$bMacros][$cAIactive] = 1 Then + For $i = UBound($savedMacros, 1) - 1 To 0 Step -1 + If _IsPressed($savedMacros[$i][$cAIKey]) Then + _SendMacro($savedMacros[$i][$cAImacrotext], $chat) + Do + Sleep(100) + Until Not _IsPressed($savedMacros[$i][$cAIKey]) + EndIf + + Next + EndIf + + If $savedGeneral[$bHotkeys][$cAIactive] = 1 Then + For $i = UBound($savedHotkeys, 1) - 1 To 0 Step -1 + If _IsPressed($savedHotkeys[$i][$cAIKey]) Then + Switch $savedHotkeys[$i][$cAIdescription] + + Case "ResetSize" + _solutionchange() + Case "43Maximize" + _43Maximize() + Case "Screenshot" + _captureShot($savedGeneral[$bCursorOnScreenshot][$cAIactive]) + Case "SetAnchor" + $newanchor = _Metro_InputBox("Please enter the name of your anchor", 11, $savedGeneral[$sDefaultAnchor][$cAIcontent], False, True, $hWnd) + If Not @error Then + $savedGeneral[$sDefaultAnchor][$cAIcontent] = $newanchor + EndIf + Case "TPAnchor" + _TPAnchor($savedGeneral[$sDefaultAnchor][$cAIcontent], $chat, $savedIngame[$igCommand][$cAIKey]) + Case "IgnorePM" + _IgnorePM($tell, $savedIngame[$igCommand][$cAIKey]) + Case "ToggleFocus" + $savedGeneral[$bKeepWindowFocused][$cAIactive] = _ToggleForceFocus($savedGeneral[$bKeepWindowFocused][$cAIactive]) + Case "ActualFullscreen" + If $AF_active = 0 Then + _ChangeScreenRes(800, 600, @DesktopDepth, @DesktopRefresh) + $AF_active = 1 + WinActivate($hWnd) + Send('^f') ;hotkey to activate flash projector fullscreen + Else + $s = _ChangeScreenRes($Dkstp_w, $Dkstp_h, @DesktopDepth, @DesktopRefresh) + $AF_active = 0 + WinActivate($hWnd) + Send('{ESC}') ;exit flash projector fullscreen + Sleep(100) + _solutionchange() + EndIf + Case Else + EndSwitch + Do + Sleep(200) + Until Not _IsPressed($savedHotkeys[$i][$cAIKey]) + EndIf + Next + + EndIf + + Switch TrayGetMsg() + Case $trayForceFocus + $savedGeneral[$bKeepWindowFocused][$cAIactive] = _ToggleForceFocus($savedGeneral[$bKeepWindowFocused][$cAIactive]) + Case $traySettings ; Open Settings + ShellExecute($pathSettings) + + Case $trayReloadSettings ; Reload Settings + $savedGeneral = GetGeneral() + $savedPaths = GetPaths() + $savedMacros = GetMacros() + $savedIngame = GetIngame() + $savedHotkeys = GetHotkeys() + $savedMacros = _ClearKeys($savedMacros) + $savedHotkeys = _ClearKeys($savedHotkeys) + $savedIngame = _ClearKeys($savedIngame, 1) + $chat = "{" & $savedIngame[$igChat][$cAIKey] & "}" + $ability = "{" & $savedIngame[$igAbility][$cAIKey] & "}" + $tell = "{" & $savedIngame[$igTell][$cAIKey] & "}" + If $savedGeneral[$bCustomCursor][$cAIactive] = 1 And FileExists($savedPaths[$sCustomCursorPath][$cAIcontent]) Then + _SetCursor($savedPaths[$sCustomCursorPath][$cAIcontent], $OCR_NORMAL) + EndIf + TrayTip("Reload successful", "The settings were reloaded succuessfully", 2, 16) +;~ COMMANDS +;~ MASTER RAT + Case $traySewerTime + WinActivate($hWnd) + _SendMacro("Its pizza time!", $chat) + Case $traySewerPlace + WinActivate($hWnd) + _SendMacro("Inside my shell.", $chat) + Case $traySewerNight + WinActivate($hWnd) + _SendMacro("A ninja of course!", $chat) + Case $traySewerLike + WinActivate($hWnd) + _SendMacro("Extra cheese, hold the anchovies.", $chat) + Case $traySewerWho + WinActivate($hWnd) + _SendMacro("Dr. Terrible, the mad scientist.", $chat) + + +;~ MR EYEBALL + ; TEMPLATES + + Case $trayMETtagcheater + WinActivate($hWnd) + _PrepareSend($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball tag cheater ", $chat) + Case $trayMETtagscammer + WinActivate($hWnd) + _PrepareSend($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball tag scammer ", $chat) + Case $trayMETUNtagcheater + WinActivate($hWnd) + _PrepareSend($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball untag cheater ", $chat) + Case $trayMETUNtagscammer + WinActivate($hWnd) + _PrepareSend($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball untag scammer ", $chat) + Case $trayMETcheckscammer + WinActivate($hWnd) + _PrepareSend($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball scammer ", $chat) + + + Case $trayMEpassword + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball password", $chat) + Case $trayMEstats + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball stats", $chat) + Case $trayMElefttomax + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball lefttomax", $chat) + Case $trayMEhideme + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball hide me", $chat) + Case $trayMEfriends + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball friends", $chat) + Case $trayMEserver + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball server", $chat) + Case $trayMEmates + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball mates", $chat) + Case $trayMEguild + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "tell MrEyeball hide my guild", $chat) + +;~ GENERAL + Case $trayCommandEvent + WinActivate($hWnd) +;~ MsgBox(0,"","Done") + _SendMacro($savedIngame[$igCommand][$cAIKey] & "event", $chat) + Case $trayCommandClasses + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "c", $chat) + Case $trayCommandWho + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "who", $chat) + Case $trayCommandNexustutorial + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "nexustutorial", $chat) + Case $trayCommandServer + WinActivate($hWnd) + _SendMacro($savedIngame[$igCommand][$cAIKey] & "server", $chat) +;~ END OF COMMANDS + + Case $traySiteRealmeye ; WEBSITE ENTRY - + ShellExecute("https://realmeye.com/") + Case $traySiteReddit ; WEBSITE ENTRY - + ShellExecute("https://reddit.com/r/RotMG") + Case $traySitePfiffel ; WEBSITE ENTRY - + ShellExecute("http://pfiffel.com/") + Case $traySiteProject ; WEBSITE ENTRY - + ShellExecute("https://github.com/GerRudi/SimpleR-RotMG") + Case $trayExit ; EXIT ENTRY - closes game, client & restores cursor + Local $pid = WinGetProcess($WindowClass) + ProcessClose($pid) + end() + EndSwitch + + WEnd + +EndFunc ;==>main + + +Func _SendMacro($text, $ChatKey) + ClipPut($text) + If @error Then + ;SLOW + Send($ChatKey) + Sleep(10) + Send($text) + Sleep(10) + Send("{Enter}") + Else + Send($ChatKey) + While Not StringInStr(ClipGet(), $text) ;wait till "Macro " is found in clipboard + Sleep(1) + WEnd + Send("^{v}") + Sleep(1) + Send("{Enter}") + Sleep(100) + EndIf +EndFunc ;==>_SendMacro + + + +Func _PrepareSend($text, $ChatKey) + ClipPut($text) + If @error Then + ;SLOW + Send($ChatKey) + Sleep(10) + Send($text) + + Else + Send($ChatKey) + While Not StringInStr(ClipGet(), $text) ;wait till "Macro " is found in clipboard + Sleep(1) + WEnd + Send("^{v}") + Sleep(100) + EndIf +EndFunc ;==>_PrepareSend + + +Func _ToggleForceFocus($currentState) + If $currentState = 1 Then + $currentState = 0 + ;TT + TrayTip("Force Focus", "Force Focus was disabled.", 2, 16) + Else + $currentState = 1 + ;TT + TrayTip("Force Focus", "Force Focus is now enabled!", 2, 16) + EndIf + Return $currentState +EndFunc ;==>_ToggleForceFocus + + +Func _TPAnchor($name, $ChatKey, $cmdChar) + Local $text = $cmdChar & "teleport " & $name + + ClipPut($text) + If @error Then + ;SLOW + Send($ChatKey) + Sleep(10) + Send($text) + Sleep(10) + Send("{Enter}") + + Else + Send($ChatKey) + While Not StringInStr(ClipGet(), $text) ;wait till "command " is found in clipboard + Sleep(1) + WEnd + Send("^{v}") + Sleep(1) + Send("{Enter}") + EndIf + + +EndFunc ;==>_TPAnchor + +Func _IgnorePM($TellKey, $cmdChar) + + Local $text = $cmdChar & "ignore" + + ClipPut($text) + If @error Then + ;SLOW + Send($TellKey) + Sleep(10) + Send("{HOME}{DEL 5}") + Sleep(10) + Send($text) + Sleep(10) + Send("{Enter}") + + Else + While Not StringInStr(ClipGet(), $text) ;wait till "command " is found in clipboard + Sleep(1) + WEnd + Send($TellKey) + Sleep(10) + Send("{HOME}{DEL 5}") + Sleep(10) + Send("^{v}") + Sleep(1) + Send("{Enter}") + EndIf +EndFunc ;==>_IgnorePM + + + + + +Func _solutionchange($a = 150, $b = 150) ; resize window to default + Local $size[4] + $size = WinGetPos($hWnd) + $a = (@DesktopWidth - $WIDTH) / 2 + $b = (@DesktopHeight - $HEIGHT) / 2 + If $size[0] <> $HEIGHT Or $size[1] <> $WIDTH Then + WinMove($hWnd, "", $a, $b, $WIDTH, $HEIGHT, 1) + EndIf +EndFunc ;==>_solutionchange + + +Func _43Maximize() + $po = WinGetPos("[CLASS:Shell_TrayWnd]") + Local $windowheight = @DesktopHeight + Local $top = 0 + Local $left = @DesktopWidth / 8 + If $po[1] > 0 Then ;Taskbar BOTTOM + $windowheight = $windowheight - $po[3] + ElseIf $po[0] = 0 And $po[1] = 0 And $po[2] = @DesktopWidth Then ;Taskbar TOP + $windowheight = $windowheight - $po[3] + $top = $po[3] + Else + EndIf + Local $windowwidth = $windowheight * 1.33 + WinMove($hWnd, "", $left, $top, $windowwidth, $windowheight, 1) +EndFunc ;==>_43Maximize + + +Func _captureShot($showCursor = 1) + If Not WinActive($hWnd) Then + Return -1 + EndIf + Local $cDate = _NowCalc() + Local $newTimeOnly, $newDateOnly + If Not FileExists(@ScriptDir & "\Screenshots\") Then + DirCreate(@ScriptDir & "\Screenshots\") + EndIf + + + _DateTimeSplit($cDate, $newDateOnly, $newTimeOnly) + Local $filename = @ScriptDir & "\Screenshots\RotMG " & $newDateOnly[3] & "-" & $newDateOnly[2] & "-" & $newDateOnly[1] & " " & $newTimeOnly[1] & "-" & $newTimeOnly[2] & "-" & $newTimeOnly[3] & ".jpg" + If $showCursor = 1 Then + _ScreenCapture_CaptureWnd($filename, $hWnd) + Sleep(50) + Else + _ScreenCapture_CaptureWnd($filename, $hWnd, 0, 0, -1, -1, False) + Sleep(50) + EndIf + + TrayTip("Screenshot saved", "Screenshot saved to: " & $filename, 2, 16) + + Return 0 +EndFunc ;==>_captureShot + + + +Func end($a = 0) ;cursor reset + _SetCursor($a, $OCR_NORMAL, 1) + If @DesktopWidth <> $Dkstp_w Then + _ChangeScreenRes($Dkstp_w, $Dkstp_h, @DesktopDepth, @DesktopRefresh) + EndIf + Exit +EndFunc ;==>end + + + + + +; change the system cursor +; WARNING: very CPU intensive +; used to run in a While (Winactive()) loop, but was removed which recuced CPU useage around -1000% +; therefore, it's now only set once when running the game and once closing the game +Func _SetCursor($CursorFile, $RepCursor, $flag = 0) ;changes cursor + Local Const $SPI_SETCURSORS = 0x0057 ;Used in $flag 1 to restore Cursor + Local $temp + If $flag = 0 Then + $temp = DllCall($user32, 'int', 'LoadCursorFromFile', 'str', $CursorFile) + If Not @error Then + DllCall($user32, 'int', 'SetSystemCursor', 'int', $temp[0], 'int', $RepCursor) + If Not @error Then + DllCall($user32, 'int', 'DestroyCursor', 'int', $temp[0]) + Else + Return -2 + EndIf + Else + Return -1 + EndIf + ElseIf $flag = 1 Then + DllCall($user32, 'int', 'SystemParametersInfo', 'int', $SPI_SETCURSORS, 'int', 0, 'int', 0, 'int', 0) + If @error Then + Return -3 + EndIf + EndIf +EndFunc ;==>_SetCursor + + +; creates tray menu entries +Func _TrayItems() + + Global $trayForceFocus = TrayCreateItem("Toggle Force Focus") + + TrayCreateItem("") + ;Options + Global $traySettings = TrayCreateItem("Open Settings") + Global $trayReloadSettings = TrayCreateItem("Reload Settings") + TrayCreateItem("") + Global $trayCommands = TrayCreateMenu("Commands") + + Global $trayMrEyeball = TrayCreateMenu("Mr. Eyeball", $trayCommands) + + Global $trayMETtagcheater = TrayCreateItem("cheater ", $trayMrEyeball) + Global $trayMETtagscammer = TrayCreateItem("scammer ", $trayMrEyeball) + Global $trayMETUNtagcheater = TrayCreateItem("NO cheater ", $trayMrEyeball) + Global $trayMETUNtagscammer = TrayCreateItem("NO scammer ", $trayMrEyeball) + Global $trayMETcheckscammer = TrayCreateItem("CHECK if scammer ", $trayMrEyeball) + TrayCreateItem("", $trayMrEyeball) + + Global $trayMEpassword = TrayCreateItem("Password", $trayMrEyeball) + Global $trayMEstats = TrayCreateItem("Stats", $trayMrEyeball) + Global $trayMElefttomax = TrayCreateItem("LeftToMax", $trayMrEyeball) + Global $trayMEhideme = TrayCreateItem("Hide Me", $trayMrEyeball) + + Global $trayMEfriends = TrayCreateItem("Friends", $trayMrEyeball) + Global $trayMEserver = TrayCreateItem("Server", $trayMrEyeball) + TrayCreateItem("", $trayMrEyeball) + Global $trayMEmates = TrayCreateItem("Mates", $trayMrEyeball) + Global $trayMEguild = TrayCreateItem("Hide My Guild", $trayMrEyeball) + + TrayCreateItem("", $trayCommands) + Global $trayCommandEvent = TrayCreateItem("/event", $trayCommands) + Global $trayCommandClasses = TrayCreateItem("/classes", $trayCommands) + Global $trayCommandWho = TrayCreateItem("/who", $trayCommands) + Global $trayCommandNexustutorial = TrayCreateItem("/nexustutorial", $trayCommands) + Global $trayCommandServer = TrayCreateItem("/server", $trayCommands) + + TrayCreateItem("", $trayCommands) + Global $traySewer = TrayCreateMenu("Master Rat Answers", $trayCommands) + Global $traySewerTime = TrayCreateItem("What time is it? ", $traySewer) + Global $traySewerPlace = TrayCreateItem("Where is the safest place in the world? ", $traySewer) + Global $traySewerNight = TrayCreateItem("What is fast, quiet and hidden by the night? ", $traySewer) + Global $traySewerLike = TrayCreateItem("How do you like your pizza? ", $traySewer) + Global $traySewerWho = TrayCreateItem("Who did this to me? ", $traySewer) + + TrayCreateItem("") + ;Misc + Global $traySiteRealmeye = TrayCreateItem("Visit RealmEye.com") + Global $traySiteReddit = TrayCreateItem("Visit /r/RotMG") + Global $traySitePfiffel = TrayCreateItem("Visit Pfiffel.com") + Global $traySiteProject = TrayCreateItem("Visit the SimpleR website") + TrayCreateItem("") + ;Exit + Global $trayExit = TrayCreateItem("Exit") + + TraySetState(1) ; Show the tray menu. +EndFunc ;==>_TrayItems + + +Func _GetSWF() + ;First try grabbing directly from source, then from version.txt as it is sometimes incorrect + Local $SWF[][] = [ _ + ["productionLoader", "productionClient"], _ + ["TestingLoader", "TestingClient"]] + Local $temp[] = ["prodID", "testID"] + Local $bnrysrc[] = ["prodID", "testID"] + Local $v1, $v2 + + $bnrysrc[0] = InetRead('http://www.realmofthemadgod.com/index.html', 1) + $bnrysrc[1] = InetRead('http://testing.realmofthemadgod.com/index.html', 1) + + $v1 = StringRegExp(BinaryToString($bnrysrc[0]), '(?:_GetSWF