Jump to content
Sign in to follow this  
grimmlock

Need to send data from List

Recommended Posts

grimmlock

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
BrewManNH

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
grimmlock

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
BrewManNH

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
grimmlock

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
grimmlock

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
grimmlock

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
Melba23

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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
grimmlock

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
grimmlock

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
Melba23

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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
grimmlock

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
grimmlock

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
grimmlock

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
Melba23

grimmlock,

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

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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
grimmlock

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


Thanks

Grimm

Share this post


Link to post
Share on other sites
grimmlock

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
grimmlock

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
Melba23

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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
Jos

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


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        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  

  • Similar Content

    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
×