Sign in to follow this  
Followers 0
grimmlock

Need to send data from List

26 posts in this topic

Hello again

Here are my problems

1) When I click on the drop down box and select branch1 it shows the items in list 1, however I only want it to show the name of the pc (testpc.testnet.local) that way When I hit the ping button it only pings the name of the PC.

Because there are spaces in the list items (just like my text files) it is displaying all the information and not just the name, which when I run the Netsupport button (opening notepad) it does remove the last 12 characters but the rest of the information is still there which will not work when I ping it.

2) When I hit the Netsupport button I would like the item (in List1) that is selected to send its IP address instead of the name

Right now it is doing what the code is asking, however all I want it to do is send just the IP address of the List line, instead of the whole line.

3) The Wake on Lan button it requires the IP and the Mac address of the computer is sending the "magic packet", so what I am trying to do is take the ip address and the mac from the selected computer in $List1 and send it to the Wake On Lan code so that it will wake up the selected computers in the list.

4) When I stop the ping and move to a new branch, is there a way to get the pings to start back at the top of the list?

Right now it is starting where it left off, could be the top, bottom or somewhere in the middle

I hope that this helps explain what I am trying to do.

#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <GUIComboBox.au3>
#Include <String.au3>
#include <mysql.au3>


; Declare a flag
Global $fPing = False
Global $Input1 = False
Global $Input2 = False


GUICreate("Am I Asleep?", 315, 850)


GUISetState()

;~ IP Addresses
$List1 = ("Testingpc.testnet.local 192.168.2.1 00-00-00-00-00|Testing2pc.testnet.local 192.168.2.2 00-00-00-00-00-00") ; Branch1
$List2 = ("Testpc.testnet.local 192.168.1.1 00-00-00-00-00|Test2pc.testnet.local 192.168.1.2 00-00-00-00-00-00") ; Branch2
$List3 = ("") ; Branch3
$List4 = ("") ; Branch4
$List5 = ("") ; Branch5
$List6 = ("") ; Branch6
$List7 = ("") ; Branch7
$List8 = ("") ; Branch8
$List9 = ("") ; Branch9
$List10 = ("") ;Branch10
$List11 = ("") ; Branch11
$List12 = ("") ; Branch12
$List13 = ("") ; Branch13
$List14 = ("") ; Branch14
$List15 = ("") ; Branch15
$List16 = ("") ; Branch16
$List17 = ("") ; Branch17
$List18 = ("") ; Branch18
$List19 = ("") ; Branch Servers
$List20 = ("") ; Core Servers

Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 125, 10)
GUICtrlSetData(-1, "Branch1|Branch2|Branch3|Branch4|Branch5|Branch6|Branch7|Branch8|Branch9|Branch10|Branch11|Branch12|Branch13|Branch14|Branch15|Branch16|Branch17|Branch18|Branch Servers|Core Servers")

; Set Cuebanner rather than add an extra element to the combo <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Get handle of combo edit
$tInfo = $tagCOMBOBOXINFO
_GUICtrlComboBox_GetComboBoxInfo($Combo1, $tInfo)
$hComboEdit = DllStructGetData($tInfo, "hEdit")
; Write CueBanner
$tText = _WinAPI_MultiByteToWideChar("Select one")
_SendMessage($hComboEdit, $EM_SETCUEBANNER, False, $tText, 0, "wparam", "struct*")

Local $Input1 = GUICtrlCreateList("", 150, 20, 150, 815, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
Local $Input2 = GUICtrlCreateList("", 440, 20, 150, 815, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetState(-1, $GUI_HIDE)

;~ Controls
Local $Button_1 = GUICtrlCreateButton("Ping", 10, 340, 115)
Local $Button_2 = GUICtrlCreateButton("Wake On Lan", 10, 380, 115)
Local $Button_3 = GUICtrlCreateButton("Netsupport Manager", 10, 440, 115)
Local $Button_4 = GUICtrlCreateButton("Remote Desktop", 10, 475, 115)
Local $Button_5 = GUICtrlCreateButton("VNC", 10, 510, 115)
Local $Button_6 = GUICtrlCreateButton("Start WHD", 10, 750, 115)
Local $Button_7 = GUICtrlCreateButton("Stop WHD", 10, 780, 115)
Local $Display1 = GUICtrlCreateEdit("", 10, 70, 125, 30, BitOR($ES_READONLY, $ES_CENTER)) ;, 0)
Local $Display2 = GUICtrlCreateEdit("", 10, 110, 125, 30, BitOR($ES_READONLY, $ES_CENTER)) ;, 0)


$iIndex = 0
_GUICtrlListBox_ClickItem($Input1, $iIndex)
$iCount = _GUICtrlListBox_GetCount($Input1)

; _AddHorzSep(10, 40, 290)
_AddHorzSep(10, 325, 125)
_AddHorzSep(10, 420, 125)
;~ _AddHorzSep(10, 690, 125)

; Get a timestamp
$iBegin = TimerInit()

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit


Case $Button_1
Switch GUICtrlRead($Button_1)
; What does the button tell us we are going to do?
Case "Ping"
; We need to ping
$fPing = True
; And set the button text accordingly
GUICtrlSetData($Button_1, "Stop")
; Disable the combo <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetState($Combo1, $GUI_DISABLE)
Case Else
; Now we need to stop pinging
$fPing = False
; And again change the button text
GUICtrlSetData($Button_1, "Ping")
; Enable the combo <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetState($Combo1, $GUI_ENABLE)
EndSwitch


Case $Combo1
Switch GUICtrlRead($Combo1)
Case "Branch1"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch1
GUICtrlSetData($Input1, "|" & $List1)
;~ GUICtrlSetData($Input2, "|" & $List21)
Case "Branch2"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch2
GUICtrlSetData($Input1, "|" & $List2)
;~ GUICtrlSetData($Input2, "|" & $List22)
Case "Branch3"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch3
GUICtrlSetData($Input1, "|" & $List3)
;~ GUICtrlSetData($Input2, "|" & $List23)
Case "Branch4"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch4
GUICtrlSetData($Input1, "|" & $List4)
;~ GUICtrlSetData($Input2, "|" & $List24)
Case "Branch5"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch5
GUICtrlSetData($Input1, "|" & $List5)
;~ GUICtrlSetData($Input2, "|" & $List25)
Case "Branch6"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch6
GUICtrlSetData($Input1, "|" & $List6)
;~ GUICtrlSetData($Input2, "|" & $List26)
Case "Branch7"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch7
GUICtrlSetData($Input1, "|" & $List7)
;~ GUICtrlSetData($Input2, "|" & $List27)
Case "Branch8"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch8
GUICtrlSetData($Input1, "|" & $List8)
;~ GUICtrlSetData($Input2, "|" & $List28)
Case "Branch9"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch9
GUICtrlSetData($Input1, "|" & $List9)
;~ GUICtrlSetData($Input2, "|" & $List29)
Case "Branch10|"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch10
GUICtrlSetData($Input1, "|" & $List10)
;~ GUICtrlSetData($Input2, "|" & $List30)
Case "Branch11"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch11
GUICtrlSetData($Input1, "|" & $List11)
;~ GUICtrlSetData($Input2, "|" & $List31)
Case "Branch12"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch12
GUICtrlSetData($Input1, "|" & $List12)
;~ GUICtrlSetData($Input2, "|" & $List32)
Case "Branch13"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch13
GUICtrlSetData($Input1, "|" & $List13)
;~ GUICtrlSetData($Input2, "|" & $List33)
Case "Branch14"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch14
GUICtrlSetData($Input1, "|" & $List14)
;~ GUICtrlSetData($Input2, "|" & $List34)
Case "Branch15"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch15
GUICtrlSetData($Input1, "|" & $List15)
;~ GUICtrlSetData($Input2, "|" & $List35)
Case "Branch16"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch16
GUICtrlSetData($Input1, "|" & $List16)
;~ GUICtrlSetData($Input2, "|" & $List36)
Case "Branch17"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch17
GUICtrlSetData($Input1, "|" & $List17)
;~ GUICtrlSetData($Input2, "|" & $List37)
Case "Branch18"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch18
GUICtrlSetData($Input1, "|" & $List18)
;~ GUICtrlSetData($Input2, "|" & $List38)
Case "Branch Servers"
;~ ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch Servers
GUICtrlSetData($Input1, "|" & $List19)
Case "Core Servers"
MsgBox(0, "", GuiCtrlRead($ip[1]))

EndSwitch

; Get new count <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iCount = _GUICtrlListBox_GetCount($Input1)


Case $Button_2
WakeOnLan()


Case $Button_3
Run("notepad")
_local()


If ProcessExists("PCICTLUI.EXE") Then
;~ Netsupport()
;~ Else
;~ Run("C:\Program Files (x86)\NetSupport\NetSupport Manager\PCICTLUI.EXE", "")
;~ Netsupport()
;~ EndIf


Case $Button_4
RDP()


Case $Button_5
VNC()


Case $Button_6
WHD_Start()


Case $Button_7
WHD_Stop()


EndSwitch

If $fPing Then
; Have we waited long enough since the last ping?
If TimerDiff($iBegin) > 1000 Then ; 1 sec delay
; Click the current item
_GUICtrlListBox_ClickItem($Input1, $iIndex)
; Read the current item
$sItem = GUICtrlRead($Input1)
$var = Ping(GUICtrlRead($Input1), 999)
If $var <> 0 Then
GUICtrlSetData($Display1, $sItem) ; & " - " & $var & " ms")
GUICtrlSetBkColor($Display1, 0x00FF00)
GUICtrlSetColor($Display1, 0x000000)
GUICtrlSetData($Display2, " " & $var & " ms")
GUICtrlSetBkColor($Display2, 0x00FF00)
GUICtrlSetColor($Display2, 0x000000)
Else
GUICtrlSetData($Display1, $sItem)
GUICtrlSetBkColor($Display1, 0)
GUICtrlSetColor($Display1, 0xFFFFFF)
GUICtrlSetData($Display2, "Request Timed Out ")
GUICtrlSetBkColor($Display2, 0)
GUICtrlSetColor($Display2, 0xFFFFFF)
EndIf
; Reset the timestamp for the next ping
$iBegin = TimerInit()
; Increase the index to select the next item
$iIndex = Mod($iIndex + 1, $iCount)
EndIf
EndIf

WEnd

Func _AddHorzSep($iX, $iY, $iW)

GUICtrlCreateLabel("", $iX, $iY, $iW, 1)
GUICtrlSetBkColor(-1, 0x000000)

EndFunc ;==>_AddHorzSep

Func WHD_Start()
Run("cmd.exe")
Sleep(1000)
Send("cd /{Enter}")
Sleep(1000)
Send("cd pstools{Enter}")
Sleep(1000)
Send("psexec \\192.168.26.17\cmd.exe{Enter}")
Sleep(5000)
Send("cd /{Enter}")
Sleep(1000)
Send("cd Program Files\WebHelpDesk{Enter}")
Sleep(1000)
Send("whd_start.bat{Enter}")
EndFunc

Func WHD_Stop()
Run("cmd.exe")
Sleep(1000)
Send("cd /{Enter}")
Sleep(1000)
Send("cd pstools{Enter}")
Sleep(1000)
Send("psexec \\192.168.26.17\ cmd.exe{Enter}")
Sleep(5000)
Send("cd /{Enter}")
Sleep(1000)
Send("cd Program Files\WebHelpDesk{Enter}")
Sleep(1000)
Send("whd_stop.bat{Enter}")
EndFunc

Func VNC()
Run("C:\Program Files\RealVNC\VNC Viewer\vncviewer.exe")
WinWaitActive("VNC Viewer")
Send(GUICtrlRead($Input1))
Sleep(1000)
Send("{ENTER}")
EndFunc

Func RDP()
Run("mstsc.exe /console")
WinWaitActive("Remote Desktop Connection")
Send(GUICtrlRead($Input1))
Sleep(1000)
Send("{ENTER}")
EndFunc

Func Netsupport()
WinActivate("NetSupport : ")
Send("!C{Down}")
Send("Q")
Sleep(1000)
Send("^A")
Sleep(1000)
_local()
Send("{ENTER}")
Sleep(1000)
If WinActive("Security") Then
Send("{Tab}")
Sleep(1000)
Send("password")
Sleep(2000)
Send("{Enter}")
Sleep(1000)
Else
Send("!C{Down}")
Send("w{Enter}")

EndIf

EndFunc

Func _local()
Local $Input3 = GUICtrlRead($Input1)
Local $Input4 = StringTrimRight(GUICtrlRead($Input1), 12) ; << Remove everything from the first .
If StringInStr(GuiCtrlRead($Input1), ".local") Then
Send($Input4)
Sleep(1000)
Else
Send($Input3)
Sleep(1000)
EndIf
EndFunc

Func WakeOnLan() ; need to fix this so that it removes all that funky stuff I need it to
$IPAddress = GuiCtrlRead() ; I want to be able to have this use the IP address associated with the computer name in $Input1
$MACAddress = GUICtrlRead() ; I want to be able to have this use the MAC address associated with the computer name in $Input1


UDPStartUp()

$connexion = UDPOpen($IPAddress, 7)
$res = UDPSend($connexion, GenerateMagicPacket($MACAddress))
MsgBox(0, "", $res)

UDPCloseSocket($connexion)
UDPShutdown()

EndFunc

; ===================================================================
; Functions
; ===================================================================


; This function convert a MAC Address Byte (e.g. "1f") to a char
Func HexToChar($strHex)

Return Chr(Dec($strHex))

EndFunc

; This function generate the "Magic Packet"
Func GenerateMagicPacket($strMACAddress)

$MagicPacket = ""
$MACData = ""

For $p = 1 To 11 Step 2
$MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2))
Next

For $p = 1 To 6
$MagicPacket = HexToChar("ff") & $MagicPacket
Next

For $p = 1 To 16
$MagicPacket = $MagicPacket & $MACData
Next

Return $MagicPacket

EndFunc

:)


Thanks

Grimm

Share this post


Link to post
Share on other sites



You're going to need to split the information read from the control yourself, there's no built-in function to do that. Seeing as how there's a space in between the name and the IP address, you could use StringSplit to do that with the space as the character to split on.

Also, why are you using the cmd console to run the programs you're running, why not just use the Run command and save yourself the heartache of Send commands to the console?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewManNH,

Thank you for the quick reply, I figured I would have to use a stringsplit, I am just not sure where it goes in order to do what I am trying to accomplish. Would creating a new function be the best way to accomplish the springsplit?

To answer your second question about Run and send, it is because I am still learning and for me it is easier to use Send.

Thanks :)


Thanks

Grimm

Share this post


Link to post
Share on other sites

You would stringsplit the string you get from GUICtrlRead($Input1), just remember StringSplit returns an array so you'd have to take that into account.

Send will not be easier if someone moves the mouse, hits a key on the keyboard, or changes which window is focused. Learning to do it the best way, not the "easiest" way, is always going to be a winner.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewmanNH,

Thank you for the advice. I will take it and learn how to do things in the best way :), as for the stringsplit, thank you as well for helping me with the placement of it.

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

So I stripped a lot out of the script so that I could focus on just 1 item at a time. When I push the Wake On Lan button it displays a list view however it only shows a 0 in the list2, any ideas?

#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <GUIComboBox.au3>
#Include <String.au3>
#include <mysql.au3>
#include <guilistview.au3>


; Declare a flag
Global $fPing = False
Global $Input1 = False
Global $Input2 = False


GUICreate("Am I Asleep?", 850, 850)


GUISetState()

;~ IP Addresses
$List1 = ("Testingpc.testnet.local 192.168.2.1 00-00-00-00-00|Testing2pc.testnet.local 192.168.2.2 00-00-00-00-00-01") ; Branch1
$List2 = ("Testpc.testnet.local 192.168.1.1 00-00-00-00-02|Test2pc.testnet.local 192.168.1.2 00-00-00-00-00-03") ; Branch2



Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 125, 10)
GUICtrlSetData(-1, "Branch1|Branch2|")

; Set Cuebanner rather than add an extra element to the combo <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Get handle of combo edit
$tInfo = $tagCOMBOBOXINFO
_GUICtrlComboBox_GetComboBoxInfo($Combo1, $tInfo)
$hComboEdit = DllStructGetData($tInfo, "hEdit")
; Write CueBanner
$tText = _WinAPI_MultiByteToWideChar("Select one")
_SendMessage($hComboEdit, $EM_SETCUEBANNER, False, $tText, 0, "wparam", "struct*")

Local $Input1 = GUICtrlCreateList("", 150, 20, 150, 815, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
Local $Input2 = GUICtrlCreateList("", 440, 20, 150, 815, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
;~ GUICtrlSetState(-1, $GUI_HIDE)

;~ Controls

Local $Button_2 = GUICtrlCreateButton("Wake On Lan", 10, 380, 115)
Local $Button_3 = GUICtrlCreateButton("Netsupport Manager", 10, 440, 115)
Local $Display1 = GUICtrlCreateEdit("", 10, 70, 125, 30, BitOR($ES_READONLY, $ES_CENTER)) ;, 0)
Local $Display2 = GUICtrlCreateEdit("", 10, 110, 125, 30, BitOR($ES_READONLY, $ES_CENTER)) ;, 0)


$iIndex = 0
_GUICtrlListBox_ClickItem($Input1, $iIndex)
$iCount = _GUICtrlListBox_GetCount($Input1)


; Get a timestamp
$iBegin = TimerInit()

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit



Case $Combo1
Switch GUICtrlRead($Combo1)
Case "Branch1"
;~ ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch1
GUICtrlSetData($Input1, "|" & $List1)


Case "Branch2"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch2
GUICtrlSetData($Input1, "|" & $List2)

Case "Branch3"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch3
GUICtrlSetData($Input1, "|" & $List3)

Case "Branch4"
ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch4
GUICtrlSetData($Input1, "|" & $List4)



EndSwitch

; Get new count <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iCount = _GUICtrlListBox_GetCount($Input1)

; <<<Added

Case $Button_2
GuiCtrlSetData($Input2, GuiCtrlRead(Test()))

Case $Button_3
Run("notepad")
_local()

EndSwitch
WEnd

Func Test()

Local $listview = GUICtrlCreateListView("Test", 600, 20, 200, 100)
Local $string = GuiCtrlRead($Input1)
Local $splited = StringSplit($string, " ")
For $i = 3 To $splited[0]
$test = GUICtrlCreateListViewItem($splited[$i], $listview)
Next
Sleep(2000)
_GUICtrlListView_DeleteAllItems("Test")
EndFunc

Func _local()
Local $Input3 = GUICtrlRead($Input1)
Local $Input4 = StringTrimRight(GUICtrlRead($Input1), 12) ; << Remove everything from the first .
If StringInStr(GuiCtrlRead($Input1), ".local") Then
Send($Input4)
Sleep(1000)
Else
Send($Input3)
Sleep(1000)
EndIf
EndFunc

Thanks!!

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites

Completely re-did my code, and everything works with the exception of this.

When I select branch 1 from the drop down the desired result is to populate $Input1 with the just the name of the PC (1Testingpc.testnet.local)

My code is setup to show a message box with the results instead of putting them into the input box so that i can get a better result. Any help would be greatly appreciated

#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <GUIComboBox.au3>
#Include <String.au3>
#include <mysql.au3>
#include <guilistview.au3>


; Declare a flag

GUICreate("Am I Asleep?", 315, 325)

GUISetState()

;~ IP Addresses
$List1 = ("1Testingpc.testnet.local 192.168.2.1 D0-67-E5-39-E9-85|2Testing2pc.testnet.local 192.168.2.2 00-00-00-00-00-01") ; Branch1
$List2 = ("3Testpc.testnet.local 192.168.1.1 00-00-00-00-02|4Test2pc.testnet.local 192.168.1.2 00-00-00-00-00-03") ; Branch2

Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 125, 10)
GUICtrlSetData(-1, "Branch1|Branch2")

; Set Cuebanner rather than add an extra element to the combo <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Get handle of combo edit
$tInfo = $tagCOMBOBOXINFO
_GUICtrlComboBox_GetComboBoxInfo($Combo1, $tInfo)
$hComboEdit = DllStructGetData($tInfo, "hEdit")
; Write CueBanner
$tText = _WinAPI_MultiByteToWideChar("Select one")
_SendMessage($hComboEdit, $EM_SETCUEBANNER, False, $tText, 0, "wparam", "struct*")

Local $Input1 = GUICtrlCreateList("", 150, 20, 150, 300, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling


;~ Controls

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit



Case $Combo1
Switch GUICtrlRead($Combo1)
Case "Branch1"
Global $Menu1 = $List1
_local()


Case "Branch2"
;~ ConsoleWrite("Hit" & @CRLF) ; <<<<<<<<<<<<< Branch2
Global $Menu2 = $List2
_local()

EndSwitch


EndSwitch
WEnd

Func _local()
Local $string = $Menu1
Local $splited = StringSplit($string, " ")
$i = 1
MsgBox(0, "", $string & $splited[$i])

Sleep(2000)
EndFunc

Thanks in advance :)

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

grimmlock,

I think this does what you want: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <WinAPI.au3>
#include <EditConstants.au3>
#include <Array.au3>

;~ IP Addresses
$List1 = ("1Testingpc.testnet.local 192.168.2.1 D0-67-E5-39-E9-85|2Testing2pc.testnet.local 192.168.2.2 00-00-00-00-00-01") ; Branch1
$List2 = ("3Testpc.testnet.local 192.168.1.1 00-00-00-00-02|4Test2pc.testnet.local 192.168.1.2 00-00-00-00-00-03") ; Branch2

GUICreate("Am I Asleep?", 315, 325)

GUISetState()

Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 125, 10)
GUICtrlSetData(-1, "Branch1|Branch2")

; Set Cuebanner rather than add an extra element to the combo
$tInfo = $tagCOMBOBOXINFO
_GUICtrlComboBox_GetComboBoxInfo($Combo1, $tInfo)
$hComboEdit = DllStructGetData($tInfo, "hEdit")
; Write CueBanner
$tText = _WinAPI_MultiByteToWideChar("Select one")
_SendMessage($hComboEdit, $EM_SETCUEBANNER, False, $tText, 0, "wparam", "struct*")

Local $Input1 = GUICtrlCreateList("", 150, 20, 150, 300, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Branch1"
                    ; Pass the required data as a parameter
                    _local($List1)
                Case "Branch2"
                    _local($List2)
            EndSwitch
    EndSwitch
WEnd

Func _local($Menu1)
    ; Now $Menu1 is always the correct list ;)
    ; Firstly split the list into the separate items
    Local $aSplit_1 = StringSplit($Menu1, "|")
    ; Now we extract the info you want from each element
    For $i = 1 To $aSplit_1[0]
        Local $aSplit_2 = StringSplit($aSplit_1[$i], " ")
        ; And just store that bit
        $aSplit_1[$i] = $aSplit_2[1]
    Next
    ; Now recreate the string to add to the list control
    $sList = "|" & _ArrayToString($aSplit_1, "|", 1)
    ; And then add it
    GUICtrlSetData($Input1, $sList)
EndFunc   ;==>_local

Questions? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

So I was kind of close ;)

let me give that a try thank you :)


Thanks

Grimm

Share this post


Link to post
Share on other sites

Dumb question, what happens to the data after the spaces (the IP and MAC) once $list1 is populated?

The reason I ask is because I have another function that needs to call the same data only use the IP and/or the Mac. If you would like I can post the code for the func I was working on for sending the IP to notepad.


Thanks

Grimm

Share this post


Link to post
Share on other sites

grimmlock,

The data in $List1 and $List2 remains intact - you are only modifying the array returned by StringSplit within the function. So you can do the same sort of thing again to extract different parts of the data just by changing the delimiter character. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

So in this case I would change this

From "For $i = 1 To $aSplit_1[0]" to For $i = 2 To $aSplit_1[0]" and that would send the IP address?

Thanks

Grimm :)


Thanks

Grimm

Share this post


Link to post
Share on other sites

Sorry should have tested first, it turns out it is this line

Changed from $aSplit_1[$i] = $aSplit_2[1] To $aSplit_1[$i] = $aSplit_2[2]

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

Can you copy the same function to a new function just label it differently? like copy _local() to _local(2) and simply change this line $aSplit_1[$i] = $aSplit_2[2]?

The reason I ask is I tried that and I get the error: Incorrect number of parameters in function call :(

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

grimmlock,

You need to change the name only - the items in the brackets are the parameters. So _local_2($Menu1) should work. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Wierd I tried that and it gives me that error every time :(


Thanks

Grimm

Share this post


Link to post
Share on other sites

I know why...i am so....

Would it be because I have it set so that when the button is pressed it is calling _local_2() and the actual function is called _local_2($Menu1)?


Thanks

Grimm

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Nope still getting the crazy error grrrr

Here is the code I am using

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <WinAPI.au3>
#include <EditConstants.au3>
#include <Array.au3>

;~ IP Addresses
$List1 = ("1Testingpc.testnet.local 192.168.2.1 D0-67-E5-39-E9-85|2Testing2pc.testnet.local 192.168.2.2 00-00-00-00-00-01") ; Branch1
$List2 = ("3Testpc.testnet.local 192.168.1.1 00-00-00-00-02|4Test2pc.testnet.local 192.168.1.2 00-00-00-00-00-03") ; Branch2

GUICreate("Am I Asleep?", 315, 325)

Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 125, 10)
GUICtrlSetData(-1, "Branch1|Branch2")

; Set Cuebanner rather than add an extra element to the combo
$tInfo = $tagCOMBOBOXINFO
_GUICtrlComboBox_GetComboBoxInfo($Combo1, $tInfo)
$hComboEdit = DllStructGetData($tInfo, "hEdit")
; Write CueBanner
$tText = _WinAPI_MultiByteToWideChar("Select one")
_SendMessage($hComboEdit, $EM_SETCUEBANNER, False, $tText, 0, "wparam", "struct*")

Local $Input1 = GUICtrlCreateList("", 150, 20, 150, 300, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling

$button1 = GuiCtrlCreateButton("Test", 10, 50, 125)
GuiCtrlSetState(-1, $GUI_DISABLE)

GUISetState()

While 1

Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
GuiCtrlSetState($button1, $GUI_ENABLE)
Switch GUICtrlRead($Combo1)
;~ GUICtrlSetState($button1, @SW_ENABLE)
Case "Branch1"
; Pass the required data as a parameter
_local($List1)
Case "Branch2"
_local($List2)
EndSwitch

Case $button1
_local_2($Menu1)

EndSwitch
WEnd

Func _local_2($Menu1)
; Now $Menu1 is always the correct list ;)
; Firstly split the list into the separate items
Local $aSplit_1 = StringSplit($Menu1, "|")
; Now we extract the info you want from each element
For $i = 1 To $aSplit_1[0]
Local $aSplit_2 = StringSplit($aSplit_1[$i], " ")
; And just store that bit
$aSplit_1[$i] = $aSplit_2[2]
Next
; Now recreate the string to add to the list control
$sList = _ArrayToString($aSplit_1, "|", 1)
; And then add it
Msgbox(0, "", $sList)
EndFunc

Func _local($Menu1)
; Now $Menu1 is always the correct list ;)
; Firstly split the list into the separate items
Local $aSplit_1 = StringSplit($Menu1, "|")
; Now we extract the info you want from each element
For $i = 1 To $aSplit_1[0]
Local $aSplit_2 = StringSplit($aSplit_1[$i], " ")
; And just store that bit
$aSplit_1[$i] = $aSplit_2[1]
Next
; Now recreate the string to add to the list control
$sList = "|" & _ArrayToString($aSplit_1, "|", 1)
; And then add it
GUICtrlSetData($Input1, $sList)
EndFunc ;==>_local

Thank you, Thank you, Thank you :)

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites

grimmlock,

So what is supposed to happen when you press the button? We have spoken of this before - we cannot read your mind! ;)

From our previous threads I assume you want to extract the IP related to the PC selected in the list. If that is the case then, as I have already shown you, you need to look for that PC in the data and then work on that element alone. So you need a different function - perhaps something like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <WinAPI.au3>
#include <EditConstants.au3>
#include <Array.au3>

;~ IP Addresses
$List1 = ("1Testingpc.testnet.local 192.168.2.1 D0-67-E5-39-E9-85|2Testing2pc.testnet.local 192.168.2.2 00-00-00-00-00-01") ; Branch1
$List2 = ("3Testpc.testnet.local 192.168.1.1 00-00-00-00-02|4Test2pc.testnet.local 192.168.1.2 00-00-00-00-00-03") ; Branch2

GUICreate("Am I Asleep?", 315, 325)

Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 125, 10)
GUICtrlSetData(-1, "Branch1|Branch2")

; Set Cuebanner rather than add an extra element to the combo
$tInfo = $tagCOMBOBOXINFO
_GUICtrlComboBox_GetComboBoxInfo($Combo1, $tInfo)
$hComboEdit = DllStructGetData($tInfo, "hEdit")
; Write CueBanner
$tText = _WinAPI_MultiByteToWideChar("Select one")
_SendMessage($hComboEdit, $EM_SETCUEBANNER, False, $tText, 0, "wparam", "struct*")

Local $Input1 = GUICtrlCreateList("", 150, 20, 150, 300, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling

$button1 = GUICtrlCreateButton("Test", 10, 50, 125)
GUICtrlSetState(-1, $GUI_DISABLE)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            GUICtrlSetState($button1, $GUI_ENABLE)
            Switch GUICtrlRead($Combo1)
;~ GUICtrlSetState($button1, @SW_ENABLE)
                Case "Branch1"
                    ; Pass the required data as a parameter
                    _local($List1)
                Case "Branch2"
                    _local($List2)
            EndSwitch

        Case $button1
            _local_2()

    EndSwitch
WEnd

Func _local_2()

    Local $Menu1

    ; Which PC in the list has been selected:
    $sSelection = GUICtrlRead($Input1)
    ; Has a selecting been made?
    If $sSelection <> "" Then
        ; Now we need to know which list we must use
        Switch GUICtrlRead($Combo1)
            Case "Branch1"
                $Menu1 = $List1
            Case "Branch2"
                $Menu1 = $List2
        EndSwitch
        ; Now we split the list into elements
        Local $aSplit_1 = StringSplit($Menu1, "|")
        ; Now we split each of these elements
        For $i = 1 To $aSplit_1[0]
            Local $aSplit_2 = StringSplit($aSplit_1[$i], " ")
            ; Have we found the PC name?
            If $aSplit_2[1] = $sSelection Then
                ; The IP should be the [2] element
                MsgBox(0, $sSelection, $aSplit_2[2])

                ; And here you put the code you need to use it

                ; No point in looking any further
                ExitLoop
            EndIf
        Next
    EndIf

EndFunc   ;==>_local_2

Func _local($Menu1)
    ; Now $Menu1 is always the correct list ;)
    ; Firstly split the list into the separate items
    Local $aSplit_1 = StringSplit($Menu1, "|")
    ; Now we extract the info you want from each element
    For $i = 1 To $aSplit_1[0]
        Local $aSplit_2 = StringSplit($aSplit_1[$i], " ")
        ; And just store that bit
        $aSplit_1[$i] = $aSplit_2[1]
    Next
    ; Now recreate the string to add to the list control
    $sList = "|" & _ArrayToString($aSplit_1, "|", 1)
    ; And then add it
    GUICtrlSetData($Input1, $sList)
EndFunc   ;==>_local

This is a virtual repeat of what we went through in your last thread - I get the impression that none of this is really sinking in - am I correct? :huh:

If that is indeed the case, then please start asking basic questions about the various functions and code structures we are using because if you do not understand the principles behind the code I post there is very little point in you trying to use these snippets to create more elaborate scripts. All you will do is keep coming back askign the same old questions. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You are not initialising/setting any value for $Menu1.

Use the Full version of SciTE4AutoIt3 which runs au3check for you and tells you about these issues.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • kawliga751
      By kawliga751
      I have a workplace GUI that has a search field function that pulls up customer records to allow changes. I am attempting to 1)LOGIN 2)Enter Search field, enter a number and then {ENTER} 3)change specific field once customer record loads. I have very limited experience in GUI manipulation but I am able to login using the below:
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/ASAG/index.htm') Call ("RacksheetSignIn") Func RacksheetSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/RackSheets/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc However I can't seem to use the _IEGetObjByName or Mouseclick to focus on the search field to allow me to enter my search criteria. When I "inspect element" in the Search field I get the attached:
       
      Any help would be MUCH appreciated
       
       
       

    • Jibberish
      By Jibberish
      I am having difficulties getting updated results from GUICtrlCreateInput. I wrote a small script to demonstrate what I am trying to do.
      This script reads a text file into an array and displays the Name and Number from the text file.
      The user can check a name and change the number, and the results are displayed in _ArrayDisplay.
      Only the Checked names are displayed in their original position. This is necessary for future
      plumbing.
      The problem with this script is the original number is returned, not the changed number. I cannot
      figure out how to get the updated number to be displayed.
      ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; This script reads a text file into an array and displays the Name and Number from the text file. ; The user can check a name and change the number, and the results are displayed in _ArrayDisplay. ; Only the Checked names are displayed in their original position. This is necessary for future ; plumbing. ; ; The problem with this script is the original number is returned, not the changed number. I cannot ; figure out how to get the updated number to be displayed. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include-once #include <MsgBoxConstants.au3> #include <array.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $iMax = 6 ;Default number of Videos - 1 for the array counter Dim $aTextFile[$iMax][2] ; [start with 5 entries][Name, Number] Don't get confused! [Row][Column] Local $i = 0 Local $iLeft = 30 Local $iTop = 30 Local $sName Local $sNumber Local $aArray Local $iMaxCol = 5 Local $iRow = 0 Local $iCol = 0 Local $aNumberCount[$iMaxCol][2] $aArray1 = ReadFile() $aNamesNumbers = DisplayNames($aArray1) _ArrayDisplay($aNamesNumbers) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; ReadFile() places the contents of the NameNumber.txt file in an array ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func ReadFile() Local $sFileData = @ScriptDir & "\NameNumber.txt" Local $iStrReturn = 0 Local $aArrayFile Local $aTextFile[$iMaxCol][2] Local $aName Local $sCheckBox1 Const $iL = 10 ; Count from Left for GUI so all buttons line up Local $sFill Local $iA = 0, $iN = 0 ; Put the Names into an Array _FileReadToArray($sFileData, $aArrayFile) For $iA = 0 To $aArrayFile[0] ; Step through the array looking for Names If StringInStr($aArrayFile[$iA], "Name:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next $iCol = 1 $iRow = 0 $sFill = "" For $iA = 1 To $aArrayFile[0] ; Step through the array looking for Numbers If StringInStr($aArrayFile[$iA], "Number:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next Return $aTextFile EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the Name and Number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayNames($aArray1) Local $aName[$iMax] Local $aNumbers[$iMax] $iMMCount = UBound($aArray1) $iMMCount -=1 Local $iWidth = 300 Local $iLength = 300;$iMMCount * 30 GUISetFont(12) $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1) GUICtrlCreateLabel(" Name Number",1,5) ;$iTop += 30 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display Name with a Checkbox. Only Checked Names should be saved. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For $i = 0 to $iMMCount Step 1 $sNameText = $aArray1[$i][0] $iNameLength = StringLen($sNameText) $aName[$i] = GUICtrlCreateCheckbox($sNameText,$iLeft, $iTop) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the number from the text file below each name. Allow the user to change the number and display the ; new number. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iLeft = 60 GUIStartGroup() $iTop = 28 For $i = 0 to $iMMCount Step 1 $sNumberText = $aArray1[$i][1] $aNumberCount[$i][1] = $sNumberText $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aNumberCount[$i][0],200) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Read the checked names and (possibly updated) number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iMMCount = UBound($aNumberCount) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedNameNumber[$iMMCount][2] $iLeft = 30 Local $idCloseGUI = GUICtrlCreateButton("Close",$iLeft, $iTop) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aName[$i]) Case $GUI_CHECKED $aCheckedNameNumber[$i][0] = $aArray1[$i][0] Case $GUI_UNCHECKED EndSwitch Switch GUICtrlRead($aNumberCount[$i][0]) Case $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][1]) EndSwitch Next ExitLoop EndSwitch WEnd For $i = 0 to $iMMNewCount step 1 GUICtrlRead($aNumberCount[$i][0]) If $aCheckedNameNumber[$i][0] <> "" Then $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1] EndIf Next GUIDelete($hGUI) Return $aCheckedNameNumber EndFunc This is the text file I am reading. If you want to try this out put the NameNumber.txt file in your script directory. It's attached to the post.
      * This is a dummy file with a Name and Number * The only purpose of this file is to read the updated Number. Name:Taggart Number:916 Name:Mongo Number:90 Name:Hedley Lamarr Number:22 Name:Bart Number:9999 Name:The Waco Kid Number:2244 If I change the number, the original number is displayed at the end, not the updated/modified number. I need the modified number to be displayed.
      Thanks in advance for any assistance!
      Jibberish
      NameNumber.txt
    • FMS
      By FMS
      Hello,
      As I was searching this forum I came along something intresting what was new to me.
      CUI/GUI hybrid.
      Whish sounds very usefull to me to compile it all into 1 script.
      So i was fideling around whit it but couldn't get it to work.
      In the real script (not this simplified version) i got a lot of functions whish i can use whan talking to it by commandline and switches.
      I could not get this to work and hope somebody could give me some pointers on how to make it work.
      Also I was hoping iff somebody could help me whit the /? function?
      (I don't know how to output the help text back to the commandline or the function that can help me do it)
      please advice and thanks in advanced.
      #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include <Process.au3> #include <Array.au3> If $CmdLine[0] = 0 Then If _ProcessGetName(ProcessGetParent(@AutoItPID)) = "cmd.exe" Then ;ConsoleWrite("Program was started in CMD" & @CRLF) If Mod($CmdLine[0], 2) <> 0 Then Exit MsgBox(16, $sTitle, "Invalid number of parameters! has to be a multiple of 2!") If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!") For $i = 1 To $CmdLine[0] Step 2 If $CmdLine[$i] = "/switch" Then MsgBox(64, "Passed Parameters", "/switch is " & $CmdLine[$i+1]) If $CmdLine[$i] = "/?" Then MsgBox(64, "Passed Parameters", "/? " ) Next _ArrayDisplay($CmdLine) Else #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 239, 65, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 32, 24, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 120, 24, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 button1() Case $button2 button2() EndSwitch WEnd EndIf EndIf Exit Func button1() MsgBox(16, "title", "button1()!") EndFunc Func button2() MsgBox(16, "title", "button1()!") EndFunc Func ProcessGetParent($i_PID) ;get PID from parent process done by SmOke_N Local $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_PID) Local $tagPROCESSENTRY32 = _ DllStructCreate( _ "dword dwsize;" & _ "dword cntUsage;" & _ "dword th32ProcessID;" & _ "uint th32DefaultHeapID;" & _ "dword th32ModuleID;" & _ "dword cntThreads;" & _ "dword th32ParentProcessID;" & _ "long pcPriClassBase;" & _ "dword dwFlags;" & _ "char szExeFile[260]" _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_PID) Local $a_pnext, $i_return = 0 If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) If $i_return Then Return $i_return Return $i_PID EndIf While @error = 0 $a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") If $i_return Then ExitLoop $i_return = $i_PID ExitLoop EndIf WEnd DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) Return $i_return EndFunc ;==>ProcessGetParent  
    • Jibberish
      By Jibberish
      Hello,
      I have used this forum to get help many times. I thought it was time to (hopefully) help others.
      I created a script that reads a text file with a list of videos, displays the videos in a GUI with checkboxes next to the names, and displays the selected videos. This will become a part of a larger script I am creating to test a video player. The tough part for me was creating the GUI and Dynamic list of videos. I had a lot of trouble finding samples to help me, but finally found one  written by Melba23. The link is in the code, so he gets credit for helping! I also have not used arrays much and they are very picky about looping through the arrays without getting the dreaded error " Array variable has incorrect number of subscripts or subscript dimension range exceeded."  However diligence paid off!
      To run this code, take the video names commented below and create a videos.txt file in your script execution directory. You can put however many video names in this list. Thus the dynamic features of the code.
      Cheers!
      Jibberish
      #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Local $sMediaFile = @ScriptDir & "\videos.txt" ;~ Videos in videos.txt are: ;~ bbb_1080_60s.mp4 ;~ bbb_1080_60s_1.mp4 ;~ bbb_1080_60s_2.mp4 ;~ tos_4K_60s_HEVC.mp4 ;~ tos_4K_60s_HEVC_1.mp4 ;~ tos_4K_60s_HEVC_2.mp4 ;~ ;~ Additional videos can be added to this list. The functions are Dynamic. Dim $aMediaManifest Local $aArrayFile Local $aVideos Local $sVideoName Local $i ; MAIN ; Put the Video File Names into an Array _FileReadToArray($sMediaFile, $aArrayFile) Local $iVideoCount = UBound($aArrayFile) -1 ; Get the number of videos - 1 to prevent errors _ArrayDelete($aArrayFile, 0) ;Counter just gets in the way ; Move backwards through the array deleting the blank lines For $i = $iVideoCount - 1 To 0 Step -1 If $aArrayFile[$i] = "" Then _ArrayDelete($aArrayFile, $i) EndIf Next $aVideos = DisplayVideos($aArrayFile) $iVideoCount = UBound($aArrayFile) -1 _ArrayDisplay($aVideos) ; Display the checked videos ;~ End of MAIN ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; GUI to display Videos in checkboxes ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayVideos($aArrayFile) Local $iTop = -1 Local $iLeft = -1 Local $iWidth Local $iHeight = $iVideoCount * 30 Local $iL = 10 Local $iT = 10 Local $iRow = 0 Local $aVideo Local $iA = 0, $iB = 0 Local $sFill = "" $iMMCount = UBound($aArrayFile) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedVideos[$iMMCount] ; Put the Video File Names into an Array $hGUI = GUICreate("Video Checkbox", $iLeft, $iTop, $iWidth, $iHeight) GUICtrlCreateLabel("Videos", 180, $iT) $iT = $iT + 30 ; This is a great example of using arrays to create GUI check boxes or radio buttons For $i = 0 To $iMMNewCount Step 1 $sMP4Text = $aArrayFile[$i] $aGUICheckbox[$i] = GUICtrlCreateCheckbox($sMP4Text, 30, $iT) $iT += 30 Next $idClose1 = GUICtrlCreateButton("Start", $iL, $iT) GUISetState(@SW_SHOW) ; This section reads the checkboxes and puts the video names in an array in their original position ; in case this is important (as it is to me) ; This was the toughest part to code, and I found no samples online until I saw Melba23's sample here: ; https://www.autoitscript.com/forum/topic/119843-dynamic-gui-problem/#comment-832672 ; I got this working with only a little modification. THANK YOU MELBA23 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idClose1 For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aGUICheckbox[$i]) Case $GUI_CHECKED $aCheckedVideos[$i] = $aArrayFile[$i] Case $GUI_UNCHECKED EndSwitch Next ExitLoop EndSwitch WEnd GUIDelete($hGUI) Return $aCheckedVideos EndFunc ;==>DisplayVideos  
    • thoms
      By thoms
      Hello Forum,
      As said in the title, I'm searching a way to disable all tabstops in a GUI. My GUI includes 15 buttons and 3 edit controls.
      My questions:
      - is there a way to disable all tabstops at a time
      - is there a way to list all controls of a GUI and then disable tabstops one by one
      - or should I use the following line after each button creation:
      _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) Thanks in advance for your valuable help!
      Thoms
      Edit: or maybe disable TAB key? I don't remember how to do!