Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/13/2024 in all areas

  1. Thank you @Andreik 👌 , for that function. I extented the $aData Array a litte bit by some 04, 004, etc. entries and I share the result (as screenshot), or better the comparison of _ArraySort and NaturalCompare for the community here. Just to give a better understanding what's the effect/difference 😇 . Local $aData = StringSplit('2|3|4|4 Part|7|8|9|12|13|004 Part|15|0004|04|4|004|21|28|31|35|OB1|NORTH|SOUTH|BORDER|3 Part|4 Past', '|', 2) Best regards Sven
    1 point
  2. Something like this? #include <Array.au3> Local $aData = StringSplit('2|3|4|4 Part|7|8|9|12|13|15|21|28|31|35|OB1|NORTH|SOUTH|BORDER|3 Part|4 Past', '|', 2) NaturalCompare($aData) _ArrayDisplay($aData) Func NaturalCompare(ByRef $aData) Local $vTemp, $i, $j Local $hDll = DllOpen('Shlwapi.dll') For $i = 1 To UBound($aData) - 1 $j = $i While $j > 0 And DllCall($hDll, "int", "StrCmpLogicalW", "wstr", $aData[$j-1], "wstr", $aData[$j])[0] <> -1 $vTemp = $aData[$j] $aData[$j] = $aData[$j-1] $aData[$j-1] = $vTemp $j -= 1 WEnd Next DllClose($hDll) EndFunc
    1 point
  3. @Melba23 & @Nine Deleting the menu control seems to do the job. It will position to the very left of the GUI all existing menuitem(s) control(s) . Does this work for you ? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $mDummymenu = GUICtrlCreateMenu("this menu control will be deleted") $menu1 = GUICtrlCreateMenuItem("click me", -1) $menu2 = GUICtrlCreateMenuItem("click me again", -1) GUICtrlDelete($mDummymenu) ; <====================== GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox($MB_TOPMOST ,'yes!', 'it works') Case $menu2 MsgBox($MB_TOPMOST,'yes!', 'it works again') EndSwitch WEnd
    1 point
  4. Here a GUI to enter the needed IP information. ;fast hack by UEZ 2013 #include <Array.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <StaticConstants.au3> Global Const $oMyError = ObjEvent("AutoIt.Error", "oMyError") ; Install a custom error handler $hGUI = GUICreate("IP Test", 423, 123) GUISetFont(9, 400, 0, "Arial") TrayTip("Information", "Reading network setting. Please wait...", 10, 1) $aNetworkAdapters = _WMI_GetNetworkAdapterNames() TrayTip("", "",0) $iComboBox = GUICtrlCreateCombo("", 220, 15, 180, 20, $CBS_DROPDOWN + $CBS_AUTOHSCROLL) Global $sNetworkAdapters, $z For $z = 0 To UBound($aNetworkAdapters) - 1 $sNetworkAdapters &= $aNetworkAdapters[$z][0] & "|" Next GUICtrlSetData($iComboBox, StringTrimRight($sNetworkAdapters, 1), $aNetworkAdapters[0][0]) $sCurrentIP = GUICtrlCreateLabel("Current IP:", 16, 18, 62, 19, $SS_RIGHT) $hCurrenIP = _GUICtrlIpAddress_Create($hGUI, 84, 16, 130, 21) _GUICtrlIpAddress_Set($hCurrenIP, $aNetworkAdapters[0][1]) $sNewIP = GUICtrlCreateLabel("New IP:", 16, 53, 62, 19, $SS_RIGHT) $hNewIP = _GUICtrlIpAddress_Create($hGUI, 84, 51, 130, 21) _GUICtrlIpAddress_Set($hNewIP, "0.0.0.0") $sDefaultGateway = GUICtrlCreateLabel("Gateway:", 16, 85, 62, 19, $SS_RIGHT) $hDefaultGateway = _GUICtrlIpAddress_Create($hGUI, 84, 83, 130, 21) _GUICtrlIpAddress_Set($hDefaultGateway, "0.0.0.254") $iBtnOK = GUICtrlCreateButton("OK", 232, 80, 75, 25) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_NOTIFY, "") GUIDelete() Exit Case $iBtnOK MsgBox(0, "Test", "Interface Name: " & $aNetworkAdapters[_ArraySearch($aNetworkAdapters, GUICtrlRead($iComboBox))][0] & @CRLF & _ "New IP: " & _GUICtrlIpAddress_Get($hNewIP) & @CRLF & _ "Default Gateway: " & _GUICtrlIpAddress_Get($hDefaultGateway)) Case $iComboBox _GUICtrlIpAddress_Set($hCurrenIP, $aNetworkAdapters[_ArraySearch($aNetworkAdapters, GUICtrlRead($iComboBox))][1]) EndSwitch WEnd Func _WMI_GetNetworkAdapterNames($sHost = ".") If $sHost = "." Then $sHost = @ComputerName Local $objWMI= ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2") Local $oItems1 = $objWMI.InstancesOf("Win32_NetworkAdapter WHERE NetEnabled=TRUE") Local $oItems2, $oTokens1, $oTokens2, $aIP, $sIPAddresses, $aResult[100][2], $i = 0 For $oTokens1 In $oItems1 $aResult[$i][0] = $oTokens1.NetConnectionID $oItems2 = $objWMI.InstancesOf('Win32_NetworkAdapterConfiguration WHERE Description="' & $oTokens1.Name & '"') For $oTokens2 In $oItems2 $aIP = $oTokens2.IPAddress For $j = 0 To UBound($aIP) - 1 If StringRegExp($aIP[$j], "(\d+\.\d+\.\d+\.\d+)", 0) Then $aResult[$i][1] = $aIP[$j] Next $i += 1 Next Next If $i > 0 Then ReDim $aResult[$i][2] Return $aResult EndIf Return SetError(1, 0, 0) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode, $tNMHDR Local $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hNewIP Switch $iCode Case $IPN_FIELDCHANGED Local $aIP = _GUICtrlIpAddress_GetArray($hNewIP) $aIP[3] = "254" _GUICtrlIpAddress_SetArray($hDefaultGateway, $aIP) EndSwitch Case $hDefaultGateway Switch $iCode Case $IPN_FIELDCHANGED Local $aIP = _GUICtrlIpAddress_GetArray($hDefaultGateway) $aIP[3] = "254" _GUICtrlIpAddress_SetArray($hDefaultGateway, $aIP) EndSwitch EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_NOTIFY Func oMyError() ConsoleWrite( @CRLF & @CRLF & _ "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.Description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.WinDescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.Number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.LastDllError & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.Scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.Source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.Helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.HelpContext & @CRLF & @CRLF) EndFunc To do: apply settings / save it to a ini file. Br, UEZ
    1 point
×
×
  • Create New...