Jump to content

Keep text from last input


Go to solution Solved by Melba23,

Recommended Posts

Hi

I am looking for a way for the GUICtrlCreateInput function to keep track of the input text until a new text will be send as input.

For example if 'abc' is entered, keep on display 'abc' until 'def' is typed over the 'abc'.

With GUICtrlCreateInput I managed to have only blank space at each launch of the script (it will not keep the last input as kind of history input)

Thank you

Link to comment
Share on other sites

  • Moderators

mentosan,

You will have to save the current input when you close the script and then re-read and use GUICtrlSetData to load the value when you next run it. An ini file would probably be the simplest solution - look at the Ini* functions in the Help file. :)

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

 

Link to comment
Share on other sites

I prefer to do it without an *.ini file. I just want to have the compiled *.exe file as standalone file as I will be moving this small app from one laptop to another.

Do you have an example to provide ?

Many thanks!

Link to comment
Share on other sites

  • Moderators

mentosan,

Adding the value internally to the .exe is not possible - or at least not without a great deal of effort which seeing you want a single standalone file would be completely excessive. So I regret that I cannot provide an example. :)

But why do you need to display the user input entered on a previous machine when launching this exe on a new one? If you could explain we might be able to offer some advice. ;)

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

 

Link to comment
Share on other sites

There is an option on latest Android KitKat to transfer files between the PC and mobile phone using the Wifi network. The things are much easier in this way, you don't need to attach the USB cable everytime you want to copy just one file, for example. In Windows you need to set up a couple of things in order to have the so-called adhoc network, but I found that this could be accomplish using also the command prompt. So I managed to create an app (which basically sends commands in background on Windows) with GUI showing buttons to START and to STOP a local wifi network, with 2 fields to fill up with the SSID of the wireless newtork to be created and with the password. We are getting close now to my ambition.:) You need one-time setting on the phone and then it will connect automatically once the wireless network is detected. Unless you change the SSID or password on the Windows machine. Since I'm using three laptops, two at home and one at work, I would like to simplify my job when making the connection between laptop and mobile, just using my mouse - I don't want to fill each time the SSID and the password. On the 3rd laptop I need to create another wireless network SSID with different settings for the proxy (at work) - useful if the last connection from the phone was made on this laptop, again I will not need to fill up the fields for SSID and password.

Link to comment
Share on other sites

  • Moderators

mentosan,

If I understand correctly, you need the option to complete 2 fields and you wish these to be prefilled to avoid having to use the keyboard. Could I suggest using combos in which you can select the correct value from a predetermined list? That way you need not fill in the value but merely select the correct SSID or password from the list using the mouse. Sound reasonable? Or have I completely missed the point? :huh:

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

 

Link to comment
Share on other sites

  • Moderators

mentosan,

It seems the crystal ball is working well today - here is an example of the sort of combos you will need:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $sSSID = "SSID_1|SSID_2|SSID_3"
Global $sPass = "Pass_1|Pass_2|Pass_3"

$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreateLabel("SSID:", 10, 10, 200, 20)
$cCombo_SSID = GUICtrlCreateCombo("", 10, 30, 200, 20)
GUICtrlSetData($cCombo_SSID, $sSSID)

GUICtrlCreateLabel("Password:", 10, 60, 200, 20)
$cCombo_Pass = GUICtrlCreateCombo("", 10, 80, 200, 20)
GUICtrlSetData($cCombo_Pass, $sPass)

$cStart = GUICtrlCreateButton("Start", 10, 200, 80, 30)

$cStop = GUICtrlCreateButton("Stop", 100, 200, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cStart
            $sSSID_To_Use = GUICtrlRead($cCombo_SSID)
            $sPass_To_Use = GUICtrlRead($cCombo_Pass)
            If $sSSID_To_Use = "" Or  $sPass_To_Use = "" Then
                MsgBox($MB_SYSTEMMODAL, "Error", "Please select both an SSID and a Password")
            Else
                MsgBox($MB_SYSTEMMODAL, "OK", "You selected:" & @CRLF & "SSID: " & $sSSID_To_Use & @CRLF & "Password: " & $sPass_To_Use)
            EndIf
    EndSwitch

WEnd
Press the "Start" button to see how it works. Please ask if you have any 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

 

Link to comment
Share on other sites

I conformed the code you have posted to my needs, thanks again !

One more last thing - in case I want to change anytime the SSID/password, this would be now hardcoded in the builded exe file; The only approach to make it change is the ini file ? 

Link to comment
Share on other sites

  • Moderators

mentosan,

I thought you did not want an ini file? :wacko:

Why not just replace the exe with a newly compiled version if you need to change anything? ;)

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

 

Link to comment
Share on other sites

Probably a helluva lot like the examples for the ini* functions in the helpfile

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators
  • Solution

mentosan,

We could have saved a lotof time if you had listened to advice I gave you in post #2. ;)

Create an ini file "Config.ini" in the same folder as your script:

[SSID]
1=SSID_1
2=SSID_2
3=SSID_3
4=SSID_4
[Password]
1=PASS_1
2=PASS_2
3=PASS_3
4=PASS_4
Then start your script as follows:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$sIni = "Config.ini"

$sSSID = ""
$aSSID = IniReadSection($sIni, "SSID")
For $i = 1 To $aSSID[0][0]
    $sSSID &= "|" & $aSSID[$i][1]
Next

$sPass = ""
$aPass = IniReadSection($sIni, "Password")
For $i = 1 To $aPass[0][0]
    $sPass &= "|" & $aPass[$i][1]
Next

$hGUI = GUICreate("Test", 500, 500)
; and continue as before
Now you have the ini values appearing in the combos. :)

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

 

Link to comment
Share on other sites

This is the full code I got now. I inserted a comment in the line ';#include <MsgBoxConstants.au3>' because of an error when compiling. I have changed the name of some variables to my better understanding. By the way - what is the 's' and 'a' in $sSSID and $aSSID coming from ?

#include <GUIConstantsEx.au3>
;#include <MsgBoxConstants.au3>
#include <Constants.au3>


; if ini file is not beeing used, define SSID and pass

;Global $sSSID = "SSID_1|SSID_2|SSID_3"
;Global $sPass = "Pass_1|Pass_2|Pass_3"


; read from Config.ini file

$sIni = "Config.ini"

$sSSID = ""
$aSSID = IniReadSection($sIni, "SSID")
For $i = 1 To $aSSID[0][0]
    $sSSID &= "|" & $aSSID[$i][1]
Next

$sPass = ""
$aPass = IniReadSection($sIni, "Password")
For $i = 1 To $aPass[0][0]
    $sPass &= "|" & $aPass[$i][1]
Next


; create GUI

$Form = GUICreate("SSID Switch", 300, 200)

GUICtrlCreateLabel("SSID", 50, 10, 200, 20)
$Input1 = GUICtrlCreateCombo("", 50, 30, 200, 20)
GUICtrlSetData($Input1, $sSSID)

GUICtrlCreateLabel("Password", 50, 60, 200, 20)
$Input2 = GUICtrlCreateCombo("", 50, 80, 200, 20)
GUICtrlSetData($Input2, $sPass)

$Button_Start = GUICtrlCreateButton("Start", 50, 130, 90, 30)
$Button_Stop = GUICtrlCreateButton("Stop", 160, 130, 90, 30)

GUISetState()

$cmd = Run(@ComSpec, "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
While 1

    Switch GUIGetMsg()
             
         Case $GUI_EVENT_CLOSE
            Exit
        
         Case $Button_Start
            
            $sSSID_To_Use = GUICtrlRead($Input1)
            $sPass_To_Use = GUICtrlRead($Input2)
            If $sSSID_To_Use = "" Or  $sPass_To_Use = "" Then
               MsgBox($MB_SYSTEMMODAL, "Error", "Please select both an SSID and a Password")
            Else
               MsgBox($MB_SYSTEMMODAL, "OK", "You selected:" & @CRLF & "SSID: " & $sSSID_To_Use & @CRLF & "Password: " & $sPass_To_Use)
            EndIf
            
            StdinWrite($cmd, "netsh wlan start hostednetwork" & @CRLF)
            Sleep(100)
         
         Case $Button_Stop
            StdinWrite($cmd, "netsh wlan stop hostednetwork" & @CRLF)
            Sleep(100)
             
    EndSwitch

WEnd

Thank you again M23 !

Link to comment
Share on other sites

easy to identify (s)trings from (a)rrays that way.   

So returning an $aArray and setting $aArray[$i] element as $sArrayitem is quite commonly found

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

mentosan,

That type of variable naming is called Hungarian notation - or at least a subset of it. Here is the list we use for the standard UDFs. :)

There is no requirement for you to use these prefixes in your own scripts, but most of the more experienced coders do so. Personally I find it very useful to keep track of what is in a variable and so highlight a possible datatype mismatch. ;)

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...