Jump to content
Sign in to follow this  
grimmlock

AutoScroll and return values

Recommended Posts

grimmlock

Hello,

I have a gui that includes a list which pulls it data from a txt file. What I was hoping for, is to get some help with getting a auto scroller that will highlight the line and then perform an action and display the results in a seperate readonly input box. In this case I have a list of computers (by name) that I would like to have ping every couple of seconds (one at a time) and display the results (either ping time or request timed out) in a seperate (read only) input box.

Here is what I have so far ...

GUICreate("Am I Asleep?", 500, 235)
GUISetState(@SW_SHOW)
$List = FileRead("C:\List.txt")
Local $Input1 = GUICtrlCreateList("", 20, 20, 150, 150, BitOr($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
GUICtrlSetData(-1, $List)
Local $Button_1 = GUICtrlCreateButton("Ping", 20, 200, 75)
Local $Button_2 = GUICtrlCreateButton("Wake Up", 100, 200, 75)
Local $Display1 = GUICtrlCreateInput("", 200, 20, 115, 20, $ES_READONLY)


While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit


Case $Button_1

local $var = Ping(GUICtrlRead($Input1), 250)

If $var <> 0 Then
GUICtrlSetData($Display1, $var & " ms", "")
GUICtrlSetBkColor($Display1, 0x00ff00)
GUICtrlSetColor ($Display1, 0x000000)

Else
;SplashTextOn("Error", @error, 100, 50)
;Sleep(1000)
;SplashOff()
GUICtrlSetData($Display1, " Request Timed Out ")
GUICtrlSetBkColor($Display1, 0)
GUICtrlSetColor ($Display1, 0xffffff)
; GUICtrlSetData($Input1, "")

EndIf

Case $Button_2
MsgBox(0, "Test", "Test")

EndSwitch

WEnd

Thanks

Grimm

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

Do you mean something like this: :huh:

#include <GUIConstantsEx.au3> ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <WindowsConstants.au3> ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <GUIListBox.au3>
#include <EditConstants.au3> ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICreate("Am I Asleep?", 500, 235)

$List = "Comp 1|Comp 2|Comp 3|Comp 4|Comp 5"
Local $Input1 = GUICtrlCreateList("", 20, 20, 150, 150, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
GUICtrlSetData(-1, $List)
Local $Button_1 = GUICtrlCreateButton("Ping", 20, 200, 75)
Local $Button_2 = GUICtrlCreateButton("Wake Up", 100, 200, 75)
Local $Display1 = GUICtrlCreateInput("", 200, 20, 115, 20, $ES_READONLY)

GUISetState(@SW_SHOW)

; The index of the current item in the list
$iIndex = 0
; The number of items
$iCount = _GUICtrlListBox_GetCount($Input1)

; Click the top item
_GUICtrlListBox_ClickItem($Input1, $iIndex)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Case $Button_1
            ; Simulate a Ping
            $var = Random(0, 1, 1)
            If $var <> 0 Then
                GUICtrlSetData($Display1, $var & " ms")
                GUICtrlSetBkColor($Display1, 0x00FF00)
                GUICtrlSetColor($Display1, 0x000000)
            Else
                GUICtrlSetData($Display1, " Request Timed Out ")
                GUICtrlSetBkColor($Display1, 0)
                GUICtrlSetColor($Display1, 0xFFFFFF)
            EndIf
            ; Increase the index and loop if necessary
            $iIndex = Mod($iIndex + 1, $iCount)
            ; Click the next item
            _GUICtrlListBox_ClickItem($Input1, $iIndex)
        Case $Button_2
            MsgBox(0, "Test", "Test")
    EndSwitch

WEnd

By the way, take note of the lines I had to add (<<<<<<<<<<<<<<) to get the basic posted script to even run. If you post an example, please make sure it runs - not everyone will take the time to add all the required includes, etc. ;)

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

Yes that is so close, let me apologize, I meant to copy and paste the #includes :(

Is there a way to set a timer? so that it waits 1 or 2 seconds and then moves onto the next line?

Thanks,

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

A timer like that is very easy to implement - use TimerInit/Diff and increase the index each time they fire. :)

Have a go yourself and see how you get on - you know where I am if you get stuck. ;)

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 now is scrolls but does not return the correct results. Could you take a look at this and show me where I went wrong please?

If $var <> 0 Then
GUICtrlSetData($Display1, $var & " ms", "")
GUICtrlSetBkColor($Display1, 0x00ff00)
GUICtrlSetColor ($Display1, 0x000000)
;Sleep(1000)
Do
$iIndex = Mod($iIndex + 1, $iCount)
_GUICtrlListBox_ClickItem($Input1, $iIndex)
Local $Begin = TimerInit()
Sleep(3000)
Local $dif = TimerDiff($Begin)
Until @error

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

Rather than critique your code, I did it like this: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <EditConstants.au3>

; Declare a flag
Global $fPing = False

GUICreate("Am I Asleep?", 500, 235)
GUISetState(@SW_SHOW)
$List = "Comp 1|Comp 2|Comp 3|Comp 4|Comp 5"
Local $Input1 = GUICtrlCreateList("", 20, 20, 150, 150, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
GUICtrlSetData(-1, $List)
Local $Button_1 = GUICtrlCreateButton("Ping", 20, 200, 75)
Local $Button_2 = GUICtrlCreateButton("Wake Up", 100, 200, 75)
Local $Display1 = GUICtrlCreateInput("", 200, 20, 115, 20, $ES_READONLY)

$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 $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")
                Case Else
                    ; Now we need to stop pinging
                    $fPing = False
                ; And again change the button text
                    GUICtrlSetData($Button_1, "Ping")
            EndSwitch
        Case $Button_2
            MsgBox(0, "Test", "Test")
    EndSwitch

    ; Are we pinging?
    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)
            ; Simulate a Ping
            $var = Random(0, 1, 1)
            If $var <> 0 Then
                GUICtrlSetData($Display1, $sItem & " - " & $var & " ms")
                GUICtrlSetBkColor($Display1, 0x00FF00)
                GUICtrlSetColor($Display1, 0x000000)
            Else
                GUICtrlSetData($Display1, $sItem & " - " & " Timed Out ")
                GUICtrlSetBkColor($Display1, 0)
                GUICtrlSetColor($Display1, 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

All clear? :)

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

I think so :) Thank you for teaching me, for only knowing this program for a week or so, I think I am doing pretty well :)

Thanks M23

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

My pleasure - that is why I come here. ;)

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

I know, I know....I am going to post another question about this

What I want to do is have a drop down box containing several (subnets) and each time someone chooses one of the items it displays a different list

Here is what I have (could you please take a look at it :))

#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>

; Declare a flag
Global $fPing = False

GUICreate("Am I Asleep?", 450, 900)
GUISetState(@SW_SHOW)
$List1 =  ("Test1111|Comp2|Comp3")
$List2 = ("Testing1234|Testing54321")
$List3 = ("Tst1234|Tst4321")
$List4 = ("Choose a Branch")
Local $Combo1 = GUICtrlCreateCombo("", 10, 20, 100, 10)
GUICtrlSetData(-1, "Pick One|Branch1|Branch2|Branch3", "Pick One")
Local $Input1 = GUICtrlCreateList("", 120, 20, 150, 815, BitOr($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
GUICtrlSetData(-1, $List4)
Local $Button_1 = GUICtrlCreateButton("Ping", 20, 840, 75)
Local $Display1 = GUICtrlCreateInput("", 300, 20, 115, 20, $ES_READONLY)

$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 $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")
                Case Else
                    ; Now we need to stop pinging
                    $fPing = False
                ; And again change the button text
                    GUICtrlSetData($Button_1, "Ping")
            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)
            ; Simulate a Ping
            $var = Ping(GUICtrlRead($Input1), 999)
            If $var <> 0 Then
                GUICtrlSetData($Display1, $sItem & " - " & $var & " ms")
                GUICtrlSetBkColor($Display1, 0x00FF00)
                GUICtrlSetColor($Display1, 0x000000)
            Else
                GUICtrlSetData($Display1, $sItem & " - " & " Timed Out ")
                GUICtrlSetBkColor($Display1, 0)
                GUICtrlSetColor($Display1, 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

Case $Combo1
Switch GUICtrlRead($Combo1)
Case "Branch1"
GUICTRLSetData($Input1, "")
GUICTRLSetData($Input1, $List1)

Case "Branch2"
GUICTRLSetData($Input1, "")
GUICtrlSetData($Input1, $List2)

Case Else
GUICTRLSetData($Input1, "")
GUICTRLSetData($Input1, $List3)

EndSwitch

EndSwitch

WEnd

It seems to want to ping the first item on each of the list (so the selection of the "list" from the drop down box works) however it only wants to ping the top item and not scroll and ping like it used to.

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

You need to have the elements of the script in the correct place - you had the "If $fPing" line inside the $sButton1 Case structure so it only fired once as the button was pressed. :(

Take a look at this version: ;)

#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 <Constants.au3>

; Declare a flag
Global $fPing = False

GUICreate("Am I Asleep?", 450, 900)
GUISetState(@SW_SHOW)
$List1 = ("Test1111|Comp2|Comp3")
$List2 = ("Testing1234|Testing54321")
$List3 = ("Tst1234|Tst4321")

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

; 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("Choose a branch", 120, 20, 150, 815, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
Local $Button_1 = GUICtrlCreateButton("Ping", 20, 840, 75)
Local $Display1 = GUICtrlCreateInput("", 300, 20, 115, 20, $ES_READONLY)

$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 $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"
                    ;GUICtrlSetData($Input1, "") ; No need - just start the data with "|" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    GUICtrlSetData($Input1, "|" & $List1)
                Case "Branch2"
                    GUICtrlSetData($Input1, "|" & $List2)
                Case Else
                    GUICtrlSetData($Input1, "|" & $List3)
            EndSwitch
            ; Get new count <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            $iCount = _GUICtrlListBox_GetCount($Input1)
    EndSwitch

    If $fPing Then ; This must be outside the Switch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ; 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)
            ; Simulate a Ping
            $var = Random(0, 1, 1) ; Ping(GUICtrlRead($Input1), 999)
            If $var <> 0 Then
                GUICtrlSetData($Display1, $sItem & " - " & $var & " ms")
                GUICtrlSetBkColor($Display1, 0x00FF00)
                GUICtrlSetColor($Display1, 0x000000)
            Else
                GUICtrlSetData($Display1, $sItem & " - " & " Timed Out ")
                GUICtrlSetBkColor($Display1, 0)
                GUICtrlSetColor($Display1, 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

I have also changed a few other elements. You have a CueBanner in the combo (much nicer than an extra element); the combo is now disabled if you are "Pinging" (try selecting a new value in the combo if you do not do this ;)); recalculated the item count each time you select a new list; and showed how to replace the list in the edit with a single command.

All good now? :)

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

Can I ask one more question, how do I hide the Listbox at app startup and when no branch is selected, However have the listbox show when a "branch" is selected?

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

Just code exactly as you described: ;)

hide the Listbox at app startup

Local $Input1 = GUICtrlCreateList("Choose a branch", 120, 20, 150, 815, BitOR($ES_READONLY, $WS_BORDER, $WS_VSCROLL))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
; Hide the list on creation <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetState(-1, $GUI_HIDE)

have the listbox show when a "branch" is selected

Case $Combo1
    ; Show the list now there is a selection <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUICtrlSetState($Input1, $GUI_SHOW)
    Switch GUICtrlRead($Combo1)

All clear? :)

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

This is what I was missing, thank you

; Show the list now there is a selection <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlSetState($Input1, $GUI_SHOW)

All Clear :)

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
grimmlock

Should I start a new post?

Would an array be the best solution (in this case) if I wanted to have a text file (with a computer name, IP address, and mac address) and create a new button that when pressed would use the data in the file to do a wake on lan?

I already have the wake on lan script. It just requires the ip address and mac address (which I have) for the computers in my text file.

Please let me know if I need to create a new post :)

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimlock,

With so little information on how exactly you are collating and using the data it is impossible to say whether an array would be the "best" solution. Certainly using an array allows you to use a single index value to access all the information available - which is why they are so useful and an essential part of a preogrammer's toolkit. :)

As to opening a new thread - if the question is not really related to the previous posts, I would recommend a new thread every time. ;)

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

M23 you answered my question in this forum.

Grimm

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites
grimmlock

However my next question which still relates to this post (I think)

Is there a way to associate a display name (TestPC) with a hidden IP, so that when I select the PC TestPC or TestPC2 is automatically knows the IP of those 2 computers?q

If so how would I go about doing this?

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

Assuming you know these "hidden IPs" (see what I mean about giving us more info ;)) then an array would be a good way to link the 2 items as the same index would let you access both items of information. This should show you how to do it. :)

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Declare the array holding the PC names and their IPs
Global $aServers[2][2] = [["PC 1", "test.test1.test1"], ["PC 2", "test1.test1.test1"]]

GUICreate("test", 400, 400)
GUISetState(@SW_SHOW)

Local $Combo1 = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "test|Branch Servers")
Local $Input1 = GUICtrlCreateList("", 10, 50, 100, 50)
Local $button1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Branch Servers"
                    ; Create a list of the PC names from the array
                    $list1 = ""
                    For $i = 0 To UBound($aServers) - 1
                        $list1 &= "|" & $aServers[$i][0]
                    Next
                    GUICtrlSetData($Input1, $list1)
                Case "test"

            EndSwitch

        Case $button1
            Local $Input3 = GUICtrlRead($Input1)
            ; Find the PC in the array
            $iIndex = _ArraySearch($aServers, $Input3)
            ; Did we find a match?
            If $iIndex <> -1 Then
                ; Get the associated IP and trim as required
                Local $Input4 = StringTrimRight($aServers[$iIndex][1], 12)
                Run("Notepad.exe")
                Sleep(1000)
                Send($Input4)
                Sleep(1000)
            EndIf

    EndSwitch
WEnd

All clear? :)

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

Make sense However using this script, if I have multiple text files all of which look like this

192.168.x.202 testpc02.testnet.local 0023ae77bf9d

192.168.x.203 testpc01.testnet.local 0019d1f613c4

192.168.x.204 testpc03.testnet.local 0019d1f613be

192.168.x.205 testpc05.testnet.local b8ac6f25fc46

192.168.x.206 testpc04.testnet.local 0023ae786fbe

How would get this:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <String.au3>

GUICreate("test", 400, 400)
GUISetState(@SW_SHOW)
$list1 = FileRead("C:\test.txt") ; <<<<<< file contains list of PCs listed above
$list2 = FileRead("c:\test2.txt") ; <<<<<<<< file contains just test123

Local $Combo1 = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "test|Branch Servers")
Local $Input1 = GUICtrlCreateList("", 10, 50, 100, 50)
Local $button1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)
Local $button2 = GUICtrlCreateButton("Wake On Lan", 200, 200, 100, 100) ; I want to be able to run my Wake On Lan function using the above PC information


While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit

Case $Combo1
Switch GUICtrlRead($Combo1)
Case "Branch Servers"
;~ ConsoleWrite("Hit" & @CRLF)
GUICtrlSetData($Input1, "|" & $list1)
Case "test"
;~ ConsoleWrite("Hit" & @CRLF)
GUICtrlSetData($Input1, "|" & $list2)
EndSwitch

Case $button1
Local $Input3 = GUICtrlRead($Input1)
Local $Input4 = StringTrimRight(GUICtrlRead($Input1), 12)

If StringInStr(GuiCtrlRead($Input1), ".local") Then
Run("Notepad.exe")
Sleep(1000)
Send($Input4)
Sleep(1000)
Else
Run("Notepad.exe")
Sleep(1000)
Send($Input3)
Sleep(1000)
EndIf

Case $button2
WakeonLan()


EndSwitch
WEnd

Func WakeonLan()

$IPAddress = ; IP address of selected item in list box
$MACAddress = ; MAC address of selected item in list box


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

The end script will have 18 lists :

Thanks

Grimm

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

Just who is writing this script - you or me? :D

I would solve your problem like this:

- Save all the lists as "List_1.txt", etc.

- Then amend the script so that you read the relevant list when selected in the combo like this:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <File.au3>
#include <Array.au3>

; Declare a Global array to hold the data for the currently selected list
Global $aPCData

GUICreate("test", 400, 400)
GUISetState(@SW_SHOW)

Local $cCombo = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "List_1|List_2|List_3") ; So you have all the lists able to be selected from the combo
Local $cList = GUICtrlCreateList("", 10, 50, 100, 50)
Local $cButton_1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)
Local $cButton_2 = GUICtrlCreateButton("Wake On Lan", 200, 200, 100, 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $cCombo
            ; Read the selection
            $sSelection = GUICtrlRead($cCombo)
            ; Open the file and get back a a list
            $sList = _ReadFile($sSelection)
            ; Fill the List with that data
            GUICtrlSetData($cList, $sList)

        Case $cButton_1

        Case $cButton_2

    EndSwitch
WEnd

Func _ReadFile($sFileName)

    ConsoleWrite(@ScriptDir & "\" & $sFileName & ".txt" & @CRLF)

    ; Read the required file into an array
    Local $aFileContents
    _FileReadToArray(@ScriptDir & "\" & $sFileName & ".txt", $aFileContents)
    ConsoleWrite(@error & @CRLF)
    ; Now transfer the data in that array into one we can use

    ; Firstly resize the global array which we use elsewhere
    Global $aPCData[$aFileContents[0] + 1][3]
    ; And reset the list contents
    Local $sList = ""

    ; Now loop through the data transferring it to the new array and to to the list we display
    For $i = 1 To $aFileContents[0]
        ; Split the line on the spaces
        $aSplit = StringSplit($aFileContents[$i], " ")
        ; And add the 3 parts to the larger array
        $aPCData[$i][0] = $aSplit[2]
        $aPCData[$i][1] = $aSplit[1]
        $aPCData[$i][2] = $aSplit[3]
        ; Then add the name to the list
        $sList &= "|" & $aSplit[2]
    Next

    ; And just for interest, this is what we get in the array
    _ArrayDisplay($aPCData)

    ; Finally return the list to be added to the control in the GUI
    Return $sList

EndFunc

- Use the technique of searching the array to find the other associated data you need as I showed you a few posts above - it is now all in the $aPCData array. :)

All clear? ;)

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

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!
×