ACalcutt Posted October 15, 2008 Posted October 15, 2008 (edited) Hey guys, I am trying to create a menu in my vistumbler program that lets the use choose the network adapter they want to use. I am using this code to create menu items and save the button ID into an array $Interfaces = GUICtrlCreateMenu("Interfaces") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colNIC = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2") Dim $NetworkAdapters[1] $menuid = GUICtrlCreateMenuItem("Default", $Interfaces) _ArrayAdd($NetworkAdapters, $menuid) GUICtrlSetOnEvent($menuid, '_InterfaceChanged') For $object In $colNIC $menuid = GUICtrlCreateMenuItem($object.NetConnectionID, $Interfaces) _ArrayAdd($NetworkAdapters, $menuid) GUICtrlSetOnEvent($menuid, '_InterfaceChanged') Next The problem I am having is I have no idea how to tell what button was pressed. I want to make it so when in interface is picked it will put a checkbox next to the interface and change a variable in my script. Does anyone know how i can tell what button was clicked or do this a different way? Edited October 15, 2008 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
Monamo Posted October 15, 2008 Posted October 15, 2008 Hey guys, I am trying to create a menu in my vistumbler program that lets the use choose the network adapter they want to use. I am using this code to create menu items and save the button ID into an array $Interfaces = GUICtrlCreateMenu("Interfaces") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colNIC = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2") Dim $NetworkAdapters[1] $menuid = GUICtrlCreateMenuItem("Default", $Interfaces) _ArrayAdd($NetworkAdapters, $menuid) GUICtrlSetOnEvent($menuid, '_InterfaceChanged') For $object In $colNIC $menuid = GUICtrlCreateMenuItem($object.NetConnectionID, $Interfaces) _ArrayAdd($NetworkAdapters, $menuid) GUICtrlSetOnEvent($menuid, '_InterfaceChanged') Next The problem I am having is I have no idea how to tell what button was pressed. I want to make it so when in interface is picked it will put a checkbox next to the interface and change a variable in my script. Does anyone know how i can tell what button was clicked or do this a different way?You could use the GUICtrlRead() function with the advanced parameter (without the advanced parameter, you'll just get the state of the menu item). An example function to show the return based upon your posted code would be (AutoIt v3.2.10.0): Func _InterfaceChanged() ConsoleWrite(GUICtrlRead(@GUI_CtrlId,1) &" was selected." &@CRLF) EndFunc - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
ACalcutt Posted October 15, 2008 Author Posted October 15, 2008 (edited) Thanks for your help. that should work Func _InterfaceChanged() $menuid = @GUI_CtrlId For $uc = 1 To $NetworkAdapters[0] If $NetworkAdapters[$uc] = $menuid Then GUICtrlSetState($NetworkAdapters[$uc], $GUI_CHECKED) Else GUICtrlSetState($NetworkAdapters[$uc], $GUI_UNCHECKED) EndIf Next $DefaultApapter = GUICtrlRead(@GUI_CtrlId, 1) ConsoleWrite(@GUI_CtrlId & '-' & GUICtrlRead(@GUI_CtrlId, 1) & " was selected." & @CRLF) EndFunc ;==>_InterfaceChanged -Andrew Edited October 15, 2008 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now