Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/16/2018 in all areas

  1. ; NetFirewallPolicy2 COM UDF Library for AutoIt3 ; AutoIt Version : 3.3.14.5 ; Description ...: Windows Firewall Policy2 Interface, Provides access to the firewall policy for Windows Vista+ Including Test Script _NetFw_Get_CurrentProfileTypes Retrieves the currently active firewall profile(s) _NetFw_Get_FirewallEnabled Indicates whether a firewall is enabled locally _NetFw_Put_FirewallEnabled Specifies whether a firewall is enabled locally _NetFw_Get_ExcludedInterfaces Indicates a list of interfaces on which firewall settings are excluded _NetFw_Put_ExcludedInterfaces Specifies a list of interfaces on which firewall settings are excluded _NetFw_Get_BlockAllInboundTraffic Indicates whether the firewall should not allow inbound traffic _NetFw_Put_BlockAllInboundTraffic Specifies whether the firewall should not allow inbound traffic _NetFw_Get_NotificationsDisabled Indicates whether interactive firewall notifications are disabled _NetFw_Put_NotificationsDisabled Specifies whether interactive firewall notifications are disabled _NetFw_Get_UnicastResponsesToMulticastBroadcastDisabled Indicates whether the firewall should not allow unicast responses to multicast and broadcast traffic _NetFw_Put_UnicastResponsesToMulticastBroadcastDisabled Specifies whether the firewall should not allow unicast responses to multicast and broadcast traffic _NetFw_Get_Rules Retrieves the interface to collection of firewall rules _NetFw_Get_ServiceRestriction Retrieves the interface used to access the Windows Service Hardening store _NetFw_EnableRuleGroup Enables or disables a specified group of firewall rules _NetFw_IsRuleGroupEnabled Determines whether a specified group of firewall rules are enabled or disabled for the current profile _NetFw_RestoreLocalFirewallDefaults Restores the local firewall configuration to its default state _NetFw_Get_DefaultInboundAction Indicates the default action for inbound traffic _NetFw_Put_DefaultInboundAction Specifies the default action for inbound traffic _NetFw_Get_DefaultOutboundAction Indicates the default action for outbound traffic _NetFw_Put_DefaultOutboundAction Specifies the default action for outbound traffic _NetFw_Get_IsRuleGroupCurrentlyEnabled Determines whether a specified group of firewall rules are enabled or disabled for the current profile _NetFw_Get_LocalPolicyModifyState Determines if adding or setting a rule or group of rules will take effect in the current firewall profile UDF: Test Script:
    1 point
  2. IGroupPolicyObject interface ;;IGroupPolicyObject #RequireAdmin #include-once #include <WinAPIConstants.au3> ; $S_OK #include <WinAPIReg.au3> ;_WinAPI_GetRegKeyNameByHandle Global Enum $GPO_SECTION_ROOT = 0x0, $GPO_SECTION_USER, $GPO_SECTION_MACHINE Global Enum $GPO_OPEN_LOAD_REGISTRY = 0x1, $GPO_OPEN_READ_ONLY Global Enum $GPO_OPTION_DISABLE_USER = 0x1, $GPO_OPTION_DISABLE_MACHINE Global Enum $GPOTypeLocal = 0x0, $GPOTypeRemote, $GPOTypeDS, $GPOTypeLocalUser, $GPOTypeLocalGroup Global Const $sCLSID_GroupPolicyObject = "{EA502722-A23D-11D1-A7D3-0000F87571E3}" Global Const $sIID_IGroupPolicyObject = "{EA502723-A23D-11D1-A7D3-0000F87571E3}" Global Const $dtag_IGroupPolicyObject = _ "New hresult(wstr;wstr;dword);" & _ ; Creates a new GPO in the Active Directory with the specified display name. "OpenDSGPO hresult(wstr;dword);" & _ ; Opens the specified GPO and optionally loads the registry information. "OpenLocalMachineGPO hresult(dword);" & _ ; Opens the default GPO for the computer and optionally loads the registry information. "OpenRemoteMachineGPO hresult(wstr;dword);" & _ ; Opens the default GPO for the specified remote computer and optionally loads the registry information. "Save hResult(bool;bool;ptr;ptr);" & _ ; Saves the specified registry policy settings to disk and updates the revision number of the GPO. "Delete hresult();" & _ ; Deletes the GPO. "GetName hResult(wstr;int);" & _ ; Retrieves the unique name for the GPO. "GetDisplayName hResult(wstr;int);" & _ ; Retrieves the display name for the GPO. "SetDisplayName hresult(wstr);" & _ ; Sets the display name for the GPO. "GetPath hResult(wstr;int);" & _ ; Retrieves the path to the GPO. "GetDSPath hresult(dword;wstr;int);" & _ ; Retrieves the Active Directory path to the root of the specified GPO section. "GetFileSysPath hresult(dword;wstr;int);" & _ ; Retrieves the file system path (UNC format) to the root of the specified GPO section. "GetRegistryKey hresult(dword;handle);" & _ ; Retrieves a handle to the root of the registry key for the specified GPO section. "GetOptions hResult(dword*);" & _ ; Retrieves the options for the GPO. "SetOptions hresult(dword;dword);" & _ ; Sets the options for the GPO. "GetType hResult(dword*);" & _ ; Retrieves type information for the GPO being edited. "GetMachineName hResult(wstr;int);" & _ ; Retrieves the computer name of the remote GPO. "GetPropertySheetPages hresult(ptr;uint*);" ; Retrieves the property sheet pages associated with the GPO. Test() Func Test() Local $iResult Local $oIGroupPolicy Local $aGpoType[5] = ["Local", "Remote", "Active Directory", "LocalUser", "LocalGroup"] $oIGroupPolicy = ObjCreateInterface($sCLSID_GroupPolicyObject, $sIID_IGroupPolicyObject, $dtag_IGroupPolicyObject) While True If Not IsObj($oIGroupPolicy) Then ConsoleWrite("Failed To Retrieve Interface") $iResult = $E_NOINTERFACE ExitLoop Else ConsoleWrite("Success: " & ObjName($oIGroupPolicy, 1) & @CRLF) EndIf Local $sLoc, $sPath, $sName, $iType $tKey = DllStructCreate("handle hKey") $iResult = $oIGroupPolicy.OpenLocalMachineGPO(BitOR($GPO_OPEN_LOAD_REGISTRY, $GPO_OPEN_READ_ONLY)) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetDisplayName($sLoc, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetName($sName, 65535) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sLoc & " : " & $sName & @CRLF) $iResult = $oIGroupPolicy.GetPath($sPath, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sPath & @CRLF) $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite("Type: " & $aGpoType[$iType] & @CRLF) $iResult = $oIGroupPolicy.GetRegistryKey($GPO_SECTION_USER, DllStructGetPtr($tKey)) If $iResult <> $S_OK Then ExitLoop ConsoleWrite(_WinAPI_GetRegKeyNameByHandle(DllStructGetData($tKey, "hKey")) & @CRLF) ExitLoop WEnd Return SetError($iResult, 0, ($iResult = $S_OK)) EndFunc ;==>Test Note: Not well tested..
    1 point
  3. Um, scroll up four comments?
    1 point
  4. aiter, I would use a child GUI like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> $hGUI = GUICreate("", 1000, 800) $cPic = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif", 0, 0, 1000, 800) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW, $hGUI) ; Create child GUI $hChild = GUICreate("", 200, 600, 176, 32, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $cEdit = GUICtrlCreateEdit("First line" & @CRLF, 0, 0, 200, 600) GUICtrlSetBkColor(-1, $COLOR_YELLOW) ; Set child transparency WinSetTrans($hChild, "", 199) GUISetState(@SW_SHOW, $hChild) While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit M23
    1 point
  5. Today I have similar problem, and here is my solution: #include <FileConstants.au3> _Example() Func _Example() Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", False) $oHTTP.Send() ; $dReceived = $oHTTP.ResponseText Local $dReceived = $oHTTP.ResponseBody Local $sStatusCode = $oHTTP.Status ConsoleWrite("! " & $sStatusCode & @CRLF) Local $hFile = FileOpen('autoit-v3-setup.exe', $FO_OVERWRITE + $FO_UTF8_NOBOM + $FO_BINARY) FileWrite($hFile, $dReceived) FileClose($hFile) EndFunc ;==>_Example
    1 point
  6. Maybe if you upload the images we can help you. And what is _GDIPlus_MatrixTao?
    1 point
  7. Can you please provide me that portion of scripts or content where this issue solution i can get in FAQ 31, as there are many pages.
    1 point
  8. I don't know if you're still interested in this @KickStarter15, but I kept modifying my code and I eventually decided to add a userlist as well. Maybe you'll find something interesting. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=NetworkChat.ico #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Fileversion=1.0.0.21 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPISys.au3> #include <WinAPIsysinfoConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ListBoxConstants.au3> #include <TrayConstants.au3> #include <GUIEdit.au3> #include <GuiListView.au3> #include <IE.au3> #include <Date.au3> If $CmdLine[0] And StringInStr(FileGetAttrib($CmdLine[1]), 'D') Then FileChangeDir($CmdLine[1]) EndIf Global Const $SINGLETON_TITLE = String(StringToBinary('therks - Network Chat')), _ $APP_NAME = 'Network Chat', _ $USER_NAME = @ComputerName, _ $CHAT_FILE = @WorkingDir & '\NetworkChat.txt', _ $USER_FILE = @WorkingDir & '\NetworkChatUsers.ini', _ $CSS_FILE = @AppDataDir & '\NetworkChat.css', _ $INI_FILE = @AppDataDir & '\NetworkChat.ini', $INI_SECTION = 'CONFIG', $INI_HISTORY = 'History', _ $INI_ENTERSTYLE = 'EnterStyle', $INI_ONTOP = 'OnTop', $INI_STARTMIN = 'StartMin', $INI_MINTOTRAY = 'MinToTray', $INI_CLOSEMIN = 'CloseMin', $INI_SHOWUSERS = 'ShowUsers', _ $INI_ESCCLOSE = 'EscClose', $INI_SHOWTIMES = 'ShowTimes', $INI_CONFIRMLINK = 'ConfirmLink' Global Enum $GLOBAL_WIN, $GLOBAL_EMBED, $GLOBAL_TOGGLE, $GLOBAL_UB Global $GLOBAL_ARRAY[$GLOBAL_UB] Global $HISTORY_LIST[11] Main() Func Main() If 'Singleton window' Then If WinExists($SINGLETON_TITLE) Then ControlSetText('[last]', '', 'Edit1', 'Show') Exit EndIf GUICreate($SINGLETON_TITLE) Local $ed_Singleton = GUICtrlCreateEdit('', 0, 0) EndIf Opt('MustDeclareVars', 1) Opt('TrayMenuMode', 3) TraySetToolTip($APP_NAME) TraySetState() _CSSFile() Local $iCfgEnterStyle = Int(IniRead($INI_FILE, $INI_SECTION, $INI_ENTERSTYLE, 0)) Local $iCfgShowTimes = Int(IniRead($INI_FILE, $INI_SECTION, $INI_SHOWTIMES, 0)) Local $iCfgConfirmLink = Int(IniRead($INI_FILE, $INI_SECTION, $INI_CONFIRMLINK, 0)) Local $iCfgEscKeyClose = Int(IniRead($INI_FILE, $INI_SECTION, $INI_ESCCLOSE, 0)) Local $iCfgStartMin = Int(IniRead($INI_FILE, $INI_SECTION, $INI_STARTMIN, 0)) Local $iCfgMinToTray = Int(IniRead($INI_FILE, $INI_SECTION, $INI_MINTOTRAY, 0)) Local $iCfgCloseMin = Int(IniRead($INI_FILE, $INI_SECTION, $INI_CLOSEMIN, 0)) Local $iCfgOnTop = Int(IniRead($INI_FILE, $INI_SECTION, $INI_ONTOP, 0)) Local $iCfgShowUsers = Int(IniRead($INI_FILE, $INI_SECTION, $INI_SHOWUSERS, 1)) If 'Tray Menu Setup' Then ; ========================================================================================================= TraySetClick(16) Local $ti_Open, $ti_Exit $ti_Open = TrayCreateItem('&Open') TrayItemSetState(-1, $TRAY_DEFAULT) $ti_Exit = TrayCreateItem('E&xit') EndIf ; ========================================================================================================= Local $aTabStop = [ 4 * 4 ] If 'Main window' Then ; ============================================================================================================ Local Enum $ACC_CTRL_TAB, $ACC_CTRL_A, $ACC_ENTER, $ACC_SHIFT_ENTER, $ACC_PGUP, $ACC_PGDN, $ACC_CTRL_UP, $ACC_CTRL_DN, $ACC_ESC, $ACC_UB Local $hGUIMain, $oEmbeddedIE, $ob_EmbedIE, $li_Users, $dm_Accel[$ACC_UB], $bt_Options, $ed_Chat, $bt_Send, $lb_Status $hGUIMain = GUICreate($APP_NAME, 500, 415, Default, Default, $WS_OVERLAPPEDWINDOW) $oEmbeddedIE = _IECreateEmbedded() $ob_EmbedIE = GUICtrlCreateObj($oEmbeddedIE, 0, 0, 400, 310) $li_Users = GUICtrlCreateList('', 405, 0, 95, 310, BitOR($LBS_NOINTEGRALHEIGHT, $LBS_SORT, $LBS_NOSEL)) GUICtrlSetResizing(-1, BitOR(BitXOR($GUI_DOCKBORDERS, $GUI_DOCKLEFT), $GUI_DOCKWIDTH)) If Not $iCfgShowUsers Then GUICtrlSetState(-1, $GUI_HIDE) EndIf _IENavigate($oEmbeddedIE, 'about:blank') $dm_Accel[$ACC_CTRL_TAB] = GUICtrlCreateDummy() $dm_Accel[$ACC_CTRL_A] = GUICtrlCreateDummy() $dm_Accel[$ACC_ENTER] = GUICtrlCreateDummy() $dm_Accel[$ACC_SHIFT_ENTER] = GUICtrlCreateDummy() $dm_Accel[$ACC_PGUP] = GUICtrlCreateDummy() $dm_Accel[$ACC_PGDN] = GUICtrlCreateDummy() $dm_Accel[$ACC_CTRL_UP] = GUICtrlCreateDummy() $dm_Accel[$ACC_CTRL_DN] = GUICtrlCreateDummy() $dm_Accel[$ACC_ESC] = GUICtrlCreateDummy() $bt_Options = GUICtrlCreateButton('+', 480, 315, 20, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKRIGHT)) GUICtrlSetTip(-1, 'Options (Alt+O)') $ed_Chat = GUICtrlCreateEdit('', 0, 315, 480, 80, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKLEFT, $GUI_DOCKRIGHT)) _GUICtrlEdit_SetTabStops($ed_Chat, $aTabStop) $bt_Send = GUICtrlCreateButton('>', 480, 335, 20, 60) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_DEFBUTTON) $lb_Status = GUICtrlCreateLabel(' Chat file: ' & $CHAT_FILE, 0, 395, 500, 20, BitOR($SS_SUNKEN, $SS_CENTERIMAGE)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKLEFT, $GUI_DOCKRIGHT)) GUICtrlSetCursor(-1, 0) EndIf ; ============================================================================================================================= If 'Options Window' Then ; ========================================================================================================= Local $hGUIOptions, $ra_EnterStyleNoShift, $ra_EnterStyleShift, $ch_OnTop, $ch_StartMin, $ch_MinToTray, $ch_CloseMin, $ch_EscKeyClose, $ch_Timestamps, $ch_ShowUsers, $ch_ConfirmLink, $ch_RawHTML, $bt_CSS, $bt_CSSReset $hGUIOptions = GUICreate('Options', 240, 275, Default, Default, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_TOOLWINDOW, $hGUIMain) GUICtrlCreateGroup('&Enter key behaviour:', 5, 5, 230, 60) $ra_EnterStyleNoShift = GUICtrlCreateRadio('Enter to send (Shift+Enter for new line)', 10, 20, 215, 20) GUICtrlSetState(-1, $GUI_CHECKED) $ra_EnterStyleShift = GUICtrlCreateRadio('Shift+Enter to send (Enter for new line)', 10, 40, 215, 20) If $iCfgEnterStyle Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_OnTop = GUICtrlCreateCheckbox('Keep &window on top', 5, 70, 200, 20) If $iCfgOnTop Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_StartMin = GUICtrlCreateCheckbox('&Start minimized/hidden', 5, 90, 215, 20) If $iCfgStartMin Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_MinToTray = GUICtrlCreateCheckbox('&Minimize to tray (hide)', 5, 110, 200, 20) If $iCfgMinToTray Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_CloseMin = GUICtrlCreateCheckbox('&Close minimizes', 5, 130, 215, 20) If $iCfgCloseMin Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_EscKeyClose = GUICtrlCreateCheckbox('Escape &key closes', 5, 150, 215, 20) If $iCfgEscKeyClose Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_ShowUsers = GUICtrlCreateCheckbox('Show &users', 5, 170, 200, 20) If $iCfgShowUsers Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_Timestamps = GUICtrlCreateCheckbox('Show &timestamps', 5, 190, 200, 20) If $iCfgShowTimes Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_ConfirmLink = GUICtrlCreateCheckbox('Confirm &before opening links', 5, 210, 200, 20) If $iCfgConfirmLink Then GUICtrlSetState(-1, $GUI_CHECKED) $ch_RawHTML = GUICtrlCreateCheckbox('&View Chat HTML', 5, 230, 200, 20) $bt_CSS = GUICtrlCreateButton('Edit CSS &File', 5, 250, 115, 20) $bt_CSSReset = GUICtrlCreateButton('&Reset CSS File', 120, 250, 115, 20) EndIf ; ============================================================================================================================= Local $aAccel = [ _ [ '{enter}', $dm_Accel[$ACC_ENTER] ], _ [ '+{enter}', $dm_Accel[$ACC_SHIFT_ENTER] ], _ [ '^{tab}', $dm_Accel[$ACC_CTRL_TAB] ], _ [ '{pgup}', $dm_Accel[$ACC_PGUP] ], _ [ '{pgdn}', $dm_Accel[$ACC_PGDN] ], _ [ '^{up}', $dm_Accel[$ACC_CTRL_UP] ], _ [ '^{down}', $dm_Accel[$ACC_CTRL_DN] ], _ [ '{esc}', $dm_Accel[$ACC_ESC] ], _ [ '^a', $dm_Accel[$ACC_CTRL_A] ], _ [ '!o', $bt_Options ] _ ] GUISetAccelerators($aAccel, $hGUIMain) $GLOBAL_ARRAY[$GLOBAL_WIN] = $hGUIMain $GLOBAL_ARRAY[$GLOBAL_EMBED] = $ob_EmbedIE $GLOBAL_ARRAY[$GLOBAL_TOGGLE] = $iCfgShowUsers GUIRegisterMsg($WM_GETMINMAXINFO, WM_GETMINMAXINFO) GUIRegisterMsg($WM_PAINT, WM_PAINT) If $iCfgStartMin Then If Not $iCfgMinToTray Then GUISetState(@SW_SHOWMINIMIZED, $hGUIMain) EndIf Else GUISetState(@SW_SHOW, $hGUIMain) EndIf GUICtrlSetState($ed_Chat, $GUI_FOCUS) If $iCfgOnTop Then WinSetOnTop($hGUIMain, '', 1) _IEErrorNotify(False) Local $bReload = True, $sHTML, $aChatFileTime[2], $oDoc = _IEDocGetObj($oEmbeddedIE), $oAutoItMonitor, $sMonitorValue, $iTM, $aGM, $iUserPingTimer, $sUserList, $iPing, $aUserData While 1 If GUICtrlRead($ed_Singleton) Then GUICtrlSetData($ed_Singleton, '') GUISetState(@SW_SHOWNORMAL, $hGUIMain) WinActivate($hGUIMain) EndIf If TimerDiff($iUserPingTimer) > 2000 Then $iUserPingTimer = TimerInit() IniWrite($USER_FILE, 'Users', $USER_NAME, _NowCalc()) $sUserList = '' $aUserData = IniReadSection($USER_FILE, 'Users') For $i = 1 To $aUserData[0][0] $iPing = _DateDiff('s', $aUserData[$i][1], _NowCalc()) If $iPing > 30 Then IniDelete($USER_FILE, 'Users', $aUserData[$i][0]) EndIf If $aUserData[$i][0] = $USER_NAME Then $aUserData[$i][0] = '@' & $aUserData[$i][0] $sUserList &= '|' & $aUserData[$i][0] Assign('USERPING_' & StringToBinary($aUserData[$i][0]), $iPing, 2) Next GUICtrlSetData($li_Users, $sUserList) EndIf ; Check modified time on chat file, refresh if changes detected $aChatFileTime[0] = FileGetTime($CHAT_FILE, 0, 1) If $bReload Or $aChatFileTime[0] <> $aChatFileTime[1] Then $sHTML = _LoadChat(_IsChecked($ch_Timestamps)) If _IsChecked($ch_RawHTML) Then $sHTML = StringReplace($sHTML, '<', '<') $sHTML = StringReplace($sHTML, '>', '>') $sHTML = '<pre>' & $sHTML & '</pre>' EndIf _IEDocWriteHTML($oEmbeddedIE, $sHTML) _IEAction($oEmbeddedIE, 'refresh') $oDoc = _IEDocGetObj($oEmbeddedIE) $oDoc.parentwindow.scrollTo(0, $oDoc.body.scrollHeight) ; Scroll to bottom $aChatFileTime[1] = $aChatFileTime[0] Local $aFormatTime = _FormatTime($aChatFileTime[0]) GUICtrlSetData($lb_Status, ' Chat file: ' & $CHAT_FILE & ' | Last update: ' & $aFormatTime[1]) If Not $bReload And Not WinActive($hGUIMain) Then TrayTip($APP_NAME, '[' & $aFormatTime[1] & '] New message', 5) EndIf $bReload = False EndIf ; If the embedded browser somehow navigates away If IsObj($oDoc) Then If $oDoc.location.href <> 'about:blank' Then _IENavigate($oEmbeddedIE, 'about:blank') $bReload = True EndIf $oAutoItMonitor = _IEGetObjById($oEmbeddedIE, 'autoit_monitor') If IsObj($oAutoItMonitor) And $oAutoItMonitor.value Then $sMonitorValue = $oAutoItMonitor.value If StringLeft($sMonitorValue, 4) = 'URL:' Then $sMonitorValue = StringReplace(StringTrimLeft($sMonitorValue, 4), '&', '&') ; For some reason the JavaScript copying the URL always encodes ampersands to html entities If Not _IsChecked($ch_ConfirmLink) Or (MsgBox(0x124, 'URL', 'Open URL?' & @LF & $sMonitorValue, 0, $hGUIMain) = 6) Then ShellExecute($sMonitorValue) EndIf ElseIf StringLeft($sMonitorValue, 4) = 'KEY:' Then Switch StringTrimLeft($sMonitorValue, 4) Case 27 ; Escape ExitLoop Case 17, 35 To 40 ; Do nothing - allows Ctrl, Home/End, & arrow keys Case Else ; Any other key: focus edit control GUICtrlSetState($ed_Chat, $GUI_FOCUS) EndSwitch EndIf $oAutoItMonitor.value = '' ; Always clear monitor EndIf EndIf $iTM = TrayGetMsg() Switch $iTM Case $ti_Open GUISetState(@SW_SHOWNORMAL, $hGUIMain) WinActivate($hGUIMain) Case $ti_Exit _Exit() EndSwitch $aGM = GUIGetMsg(1) Switch $aGM[0] Case $li_Users If GUICtrlRead($li_Users) Then ToolTip(GUICtrlRead($li_Users) & ' - Ping: ' & Eval('USERPING_' & StringToBinary(GUICtrlRead($li_Users))) & 's') EndIf Case $ra_EnterStyleNoShift $iCfgEnterStyle = 0 IniWrite($INI_FILE, $INI_SECTION, $INI_ENTERSTYLE, $iCfgEnterStyle) Case $ra_EnterStyleShift $iCfgEnterStyle = 1 IniWrite($INI_FILE, $INI_SECTION, $INI_ENTERSTYLE, $iCfgEnterStyle) Case $ch_OnTop $iCfgOnTop = _SetSetting($aGM[0], $INI_ONTOP) WinSetOnTop($hGUIMain, '', $iCfgOnTop) Case $ch_StartMin $iCfgStartMin = _SetSetting($aGM[0], $INI_STARTMIN) Case $ch_MinToTray $iCfgMinToTray = _SetSetting($aGM[0], $INI_MINTOTRAY) Case $ch_CloseMin $iCfgCloseMin = _SetSetting($aGM[0], $INI_CLOSEMIN) Case $ch_EscKeyClose $iCfgEscKeyClose = _SetSetting($aGM[0], $INI_ESCCLOSE) Case $ch_ShowUsers $iCfgShowUsers = _SetSetting($aGM[0], $INI_SHOWUSERS) $GLOBAL_ARRAY[$GLOBAL_TOGGLE] = $iCfgShowUsers If $iCfgShowUsers Then GUICtrlSetState($li_Users, $GUI_SHOW) Else GUICtrlSetState($li_Users, $GUI_HIDE) EndIf Case $ch_Timestamps $bReload = True ; Causes chat refresh $iCfgShowTimes = _SetSetting($aGM[0], $INI_SHOWTIMES) Case $ch_ConfirmLink $iCfgConfirmLink = _SetSetting($aGM[0], $INI_CONFIRMLINK) Case $ch_RawHTML $bReload = True ; Causes chat refresh Case $bt_CSS ShellExecute($CSS_FILE) Case $bt_CSSReset If _CSSFile(1) Then MsgBox(0x40, 'CSS File', 'CSS file restored', 0, $hGUIOptions) Else MsgBox(0x30, 'CSS File', 'Unable to restore CSS file', 0, $hGUIOptions) EndIf Case $dm_Accel[$ACC_PGUP] $oDoc.parentwindow.scrollBy(0, -200) Case $dm_Accel[$ACC_PGDN] $oDoc.parentwindow.scrollBy(0, 200) Case $dm_Accel[$ACC_CTRL_UP] GUICtrlSetData($ed_Chat, _SendHistory(1)) Case $dm_Accel[$ACC_CTRL_DN] GUICtrlSetData($ed_Chat, _SendHistory(-1)) Case $dm_Accel[$ACC_CTRL_A] If _IsFocused($ed_Chat) Then _GUICtrlEdit_SetSel($ed_Chat, 0, -1) Case $dm_Accel[$ACC_ENTER] If _IsFocused($ed_Chat) Then If _IsChecked($ra_EnterStyleNoShift) Then _SendChat($ed_Chat) $bReload = True Else _GUICtrlEdit_ReplaceSel($ed_Chat, @CRLF) EndIf EndIf Case $dm_Accel[$ACC_SHIFT_ENTER] If _IsFocused($ed_Chat) Then If _IsChecked($ra_EnterStyleShift) Then _SendChat($ed_Chat) $bReload = True Else _GUICtrlEdit_ReplaceSel($ed_Chat, @CRLF) EndIf EndIf Case $dm_Accel[$ACC_CTRL_TAB] If _IsFocused($ed_Chat) Then _GUICtrlEdit_ReplaceSel($ed_Chat, @TAB) EndIf Case $bt_Send _SendChat($ed_Chat) $bReload = True Case $bt_Options Local $aMainPos = WinGetPos($hGUIMain) Local $aOptPos = WinGetPos($hGUIOptions) WinMove($hGUIOptions, '', _ $aMainPos[0]+($aMainPos[2]-$aOptPos[2])/2, _ $aMainPos[1]+($aMainPos[3]-$aOptPos[3])/2) GUISetState(@SW_SHOW, $hGUIOptions) WinActivate($hGUIOptions) Case $lb_Status ShellExecute($CHAT_FILE) ; Open raw chat file Case $dm_Accel[$ACC_ESC] If _IsChecked($ch_EscKeyClose) Then ContinueCase Case $GUI_EVENT_CLOSE If $aGM[1] = $hGUIMain Then If _IsChecked($ch_CloseMin) Then ContinueCase Else _Exit() EndIf ElseIf $aGM[1] = $hGUIOptions Then GUISetState(@SW_HIDE, $hGUIOptions) WinActivate($hGUIMain) EndIf Case $GUI_EVENT_MINIMIZE GUISetState(@SW_MINIMIZE, $hGUIMain) If _IsChecked($ch_MinToTray) Then GUISetState(@SW_HIDE, $hGUIMain) TraySetState($TRAY_ICONSTATE_SHOW) EndIf Case $GUI_EVENT_MOUSEMOVE ToolTip('') EndSwitch WEnd EndFunc Func _Exit() IniDelete($USER_FILE, 'Users', $USER_NAME) Exit EndFunc Func _EncodeMessage($sString) $sString = StringStripCR($sString) $sString = StringReplace($sString, '%', '%%') $sString = StringReplace($sString, '\', '\\') $sString = StringReplace($sString, @LF, '\n') $sString = StringReplace($sString, @TAB, '\t') Return $sString EndFunc Func _DecodeMessage($sString) $sString = StringFormat($sString) $sString = StringReplace($sString, '<', '<') $sString = StringReplace($sString, '>', '>') $sString = StringReplace($sString, @TAB, '    ') $sString = StringReplace($sString, @LF, '<br />' & @CRLF & ' ') ; Tabs for HTML indentation $sString = StringRegExpReplace($sString, '((?:file|https?)://\S+|\\\\\S+\\\S*)', _ '<span class="link" onclick="document.getElementById(''autoit_monitor'').value=''URL:''+this.innerHTML">\1</span>') Return $sString EndFunc Func _SendChat($iCtrl) Local $sMessage = StringStripWS(GUICtrlRead($iCtrl), 3) If $sMessage Then FileWrite($CHAT_FILE, @CRLF & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @TAB & $USER_NAME & @TAB & _EncodeMessage($sMessage)) _AddHistory($sMessage) GUICtrlSetData($iCtrl, '') EndIf EndFunc Func _LoadChat($iShowTimes) Local Enum $RE_DATETIME, $RE_USER, $RE_TEXT Local Enum $DT_DATE, $DT_TIME Local $sOutput, $sDateMem, $aLines, $iLineCount, $iLineTrack = 0, $aRegExLine, $aDateTime $sOutput = StringFormat('<html>\r\n<head>\r\n\t<link href="%s" rel="stylesheet">\r\n</head>\r\n', $CSS_FILE) $sOutput &= '<body onkeydown="document.getElementById(''autoit_monitor'').value=''KEY:''+event.keyCode">' & @CRLF $sOutput &= '<table>' & @CRLF $aLines = FileReadToArray($CHAT_FILE) $iLineCount = @extended For $L = 0 To $iLineCount-1 If Not StringStripWS($aLines[$L], 3) Then ContinueLoop $aRegExLine = StringRegExp($aLines[$L], '(\d{14})\t(.+)\t(.+)', 1) If Not @error Then $aDateTime = _FormatTime($aRegExLine[$RE_DATETIME]) If $aDateTime[$DT_DATE] <> $sDateMem Then $sOutput &= '<tr><td class="date" colspan="2">' & $aDateTime[$DT_DATE] & '</td></tr>' & @CRLF $sDateMem = $aDateTime[$DT_DATE] $iLineTrack = 0 EndIf $sOutput &= '<tr class="rowOffset' & Mod($iLineTrack, 2) & ' user' & $aRegExLine[$RE_USER] & '">' & @CRLF $sOutput &= ' <td class="name_column">' & @CRLF If $iShowTimes Then $sOutput &= ' <span class="timestamp">[' & $aDateTime[$DT_TIME] & '] </span>' & @CRLF $sOutput &= ' <span class="username"><' & $aRegExLine[$RE_USER] & '></span> ' & @CRLF $sOutput &= ' </td>' & @CRLF $sOutput &= ' <td class="text_column">' & @CRLF $sOutput &= ' ' & _DecodeMessage($aRegExLine[$RE_TEXT]) & @CRLF $sOutput &= ' </td>' & @CRLF $sOutput &= '</tr>' & @CRLF $iLineTrack += 1 EndIf Next $sOutput &= '</table>' & @CRLF $sOutput &= StringFormat('<input type="hidden" id="autoit_monitor" />\r\n</body>\r\n</html>') Return $sOutput EndFunc Func _FormatTime($sTime, $bToString = False) Local $aMonths = StringSplit('Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec', '|') Local $aRegEx = StringRegExp($sTime, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', 1) Local $aReturn[2] If Not @error Then $aReturn[0] = $aRegEx[0] &'-'& $aMonths[Int($aRegEx[1])] &'-'& $aRegEx[2] $aReturn[1] = $aRegEx[3] &':'& $aRegEx[4] &':'& $aRegEx[5] EndIf If $bToString Then Return $aReturn[0] &' '& $aReturn[1] Return $aReturn EndFunc Func _AddHistory($sMessage) Local Const $LIST = '0123456789' _SendHistory(0) $sMessage = _EncodeMessage($sMessage) Local $sKey, $sKeyList = $HISTORY_LIST[10] For $i = 0 To StringLen($sKeyList)-1 If $sMessage = $HISTORY_LIST[$i] Then $HISTORY_LIST[10] = $i & StringReplace($sKeyList, String($i), '') Return EndIf Next Local $sNext = StringLeft(StringRegExpReplace($LIST, '[' & $sKeyList & ']', ''), 1) If Not $sNext Then $sNext = StringRight($sKeyList, 1) $sKeyList = StringTrimRight($sKeyList, 1) EndIf $HISTORY_LIST[10] = $sNext & $sKeyList $HISTORY_LIST[Int($sNext)] = $sMessage EndFunc Func _SendHistory($iDir = 0) Static $iPosition = 0 Local $sKeyList = $HISTORY_LIST[10] Local $sKeyLen = StringLen($sKeyList) Local $sKey If $iDir < 0 Then $iPosition = $iPosition > 0 ? $iPosition - 1 : 0 ElseIf $iDir > 0 Then $iPosition = $iPosition < $sKeyLen ? $iPosition + 1 : $sKeyLen Else $iPosition = 0 EndIf $sKey = StringMid($sKeyList, $iPosition, 1) Return $sKey ? $HISTORY_LIST[Int($sKey)] : '' EndFunc Func _SetSetting($idCtrl, $sIniKey) Local $iSetting = 0 If _IsChecked($idCtrl) Then $iSetting = 1 IniWrite($INI_FILE, $INI_SECTION, $sIniKey, $iSetting) Return $iSetting EndFunc Func _IsChecked($idCtrl) Return BitAND(GUICtrlRead($idCtrl), $GUI_CHECKED) EndFunc Func _IsFocused($idCtrl) Return _WinAPI_GetFocus() = GUICtrlGetHandle($idCtrl) EndFunc Func _CSSFile($iForce = 0) Return FileInstall('NetworkChat.css', $CSS_FILE, $iForce) EndFunc Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) Local $tMinMaxInfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int', $lParam) If $hWnd = $GLOBAL_ARRAY[$GLOBAL_WIN] Then DllStructSetData($tMinMaxInfo, 7, 300); min width DllStructSetData($tMinMaxInfo, 8, 300); min height DllStructSetData($tMinMaxInfo, 9, @DesktopWidth); max width DllStructSetData($tMinMaxInfo, 10, @DesktopHeight); max height Return EndIf EndFunc Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam) If $hWnd = $GLOBAL_ARRAY[$GLOBAL_WIN] Then Local $aClient = WinGetClientSize($hWnd) If $GLOBAL_ARRAY[$GLOBAL_TOGGLE] Then GUICtrlSetPos($GLOBAL_ARRAY[$GLOBAL_EMBED], 0, 0, $aClient[0] - 100, $aClient[1] - 105) Else GUICtrlSetPos($GLOBAL_ARRAY[$GLOBAL_EMBED], 0, 0, $aClient[0], $aClient[1] - 105) EndIf EndIf EndFunc
    1 point
  9. Here are two functions to provide pixel-accurate height and width dimensions for a given string. The more commonly-used _GDIPlus_GraphicsMeasureString built-in UDF is problematic because it returns the width padded by roughly one en-space (for reasons related to the various ways Windows produces anti-aliased fonts). These are AutoIt translations of Pierre Arnaud's C# functions, described in his CodeProject article "Bypass Graphics.MeasureString limitations" The first is an all-purpose version that takes a window handle, string, font family, font size (in points), style, and (optionally) width of the layout column (in pixels) as parameters. The second, more efficient version is intended for applications where GDI+ fonts are already in use, and takes handles to the existing graphics context, string, font, layout and format as parameters. Both functions return a two-row array with the exact width [0] and height [1] of the string (in pixels). EDIT: (Note that some of the same anti-aliasing measurement issues still apply. I did my best to work around them, but the output of the function may still be off by a pixel or two. Buyer beware.) #include <GDIPlus.au3> #include <GUIConstantsEx.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringInPixels ; Description ...: Returns a pixel-accurate height and width for a given string using a given font, style and size. ; Syntax ........: _StringInPixels($hGUI, $sString, $sFontFamily, $fSize, $iStyle[, $iColWidth = 0]) ; Parameters ....: $hGUI - Handle to the window. ; $sString - The string to be measured. ; $sFontFamily - Full name of the font to use. ; $fSize - Font size in points (half-point increments). ; $iStyle - Combination of 0-normal, 1-bold, 2-italic, 4-underline, 8-strikethrough ; $iColWidth - [optional] If word-wrap is desired, column width in pixels ; Return values .: 2-row array. [0] is width in pixels; [1] is height in pixels. ; Author ........: Tim Curran; adapted from Pierre Arnaud's C# function ; Modified ......: ; Remarks .......: This version is longer and less efficient but works for all purposes. ; Related .......: <https://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations> ; Link ..........: ; Example .......: Example-StringInPixels.au3 ; =============================================================================================================================== #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Func _StringInPixels($hGUI, $sString, $sFontFamily, $fSize, $iStyle, $iColWidth = 0) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle Local $aRanges[2][2] = [[1]] $aRanges[1][0] = 0 ;Measure first char (0-based) $aRanges[1][1] = StringLen($sString) ;Region = String length Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFontFamily) Local $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges Local $aWinClient = WinGetClientSize($hGUI) If $iColWidth = 0 Then $iColWidth = $aWinClient[0] Local $tLayout = _GDIPlus_RectFCreate(10, 10, $iColWidth, $aWinClient[1]) Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions Local $aBounds = _GDIPlus_RegionGetBounds($aRegions[1], $hGraphic) Local $aWidthHeight[2] = [$aBounds[2], $aBounds[3]] ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_RegionDispose($aRegions[1]) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Return $aWidthHeight EndFunc ;==>_StringInPixels ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringInPixels_gdip ; Description ...: Returns a pixel-accurate height and width for a given string using a GDI+ font, layout and format ; Syntax ........: _StringInPixels_gdip($hGraphic, $sString, $hFont, $tLayout, $hFormat) ; Parameters ....: $hGraphic - Handle to a GDI+ graphics object. ; $sString - The string to be measured. ; $hFont - Handle to a GDI+ font. ; $tLayout - A $tagGDIPRECTF structure that bounds the string. ; $hFormat - Handle to a GDI+ string format. ; Return values .: 2-row array. [0] is width in pixels; [1] is height in pixels. ; Author ........: Tim Curran; adapted from Pierre Arnaud's C# function ; Modified ......: ; Remarks .......: This much more efficient version is for use with GDI+ fonts ; Related .......: ; Link ..........: <https://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations> ; Example .......: Example-StringInPixels.au3 ; =============================================================================================================================== #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Func _StringInPixels_gdip($hGraphic, $sString, $hFont, $tLayout, $hFormat) Local $aRanges[2][2] = [[1]] $aRanges[1][0] = 0 ;Measure first char (0-based) $aRanges[1][1] = StringLen($sString) ;Region = String length _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_CLEARTYPEGRIDFIT) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions Local $aBounds = _GDIPlus_RegionGetBounds($aRegions[1], $hGraphic) Local $aWidthHeight[2] = [$aBounds[2], $aBounds[3]] _GDIPlus_RegionDispose($aRegions[1]) Return $aWidthHeight EndFunc ;==>_StringInPixels_gdip _StringInPixels.au3 Example-StringInPixels.au3
    1 point
×
×
  • Create New...