Sign in to follow this  
Followers 0
Elephant007

[Q] Refresh Combo Reading File Without Restarting Script

5 posts in this topic

Once again I am here asking for assistance, it's been awhile since I haven't been able to figure something out on my own, thank you in advance for everyone's help. So let me get to my question

My script brings up a GUI a tech enters computer name, click on REMOTE to connect to client

A list of computer names is generated to use for historical reference, this history is populated in a dropdown menu

The problem: Script has to be closed and restarted to see the most recent history in the dropdown

Is there away to refresh list without having to close and restart the script?

Dirty Script

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <ComboConstants.au3>

Local $msg

GUICreate ( "SCCM Remote Control", 325, 250 )
GUISetState(@SW_SHOW)
GUISetFont ( 12, 400, 1, "Calibri" )

;~ Computer Name
GUICtrlCreateGroup ( "", 10, 5, 305, 83)
GUIStartGroup()
GUICtrlCreateLabel ( "Computer Name:", 20, 25, 200, 20, $SS_LEFT)
$CompName = GUICtrlCreateInput( '', 150, 24, 150, 20 )

;~ ComboBox
$FILE = FileOpen( @ScriptDir & '\RemoteHistory')
$LINE = FileRead($FILE)
FileClose ($FILE)
GUICtrlCreateGroup ( "", 10, 85, 305, 60 )
GUIStartGroup()
GUICtrlCreateLabel ( "Remote History:", 20, 105, 200, 20, $SS_LEFT)
$History = GUICtrlCreateCombo ( '', 150, 105, 150, -1 )
GUICtrlSetData(-1, $LINE, "text3")

GUICtrlCreateGroup ( '', 110, 43, 112, 34 )
GUIStartGroup()
$ClickRemote = GUICtrlCreateLabel ( "Remote Control", 115, 55, 102, 20, $SS_LEFT )
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState()
GUISetState(@SW_SHOW); will display an empty dialog box
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord
Switch $iIDFrom
Case $ClickRemote
If GUICtrlRead($CompName) = "" Then
MsgBox ( 48, 'Empty Computer Name', 'Computer Name is empty' & @CRLF & 'Enter Computer Name and try again...' )
Else
FileOpen ( @ScriptDir & '\RemoteHistory', 1 )
_FileWriteToLine ( @ScriptDir & '\RemoteHistory', 1, GUICtrlRead($CompName) & '|', 0)
FileClose ( @ScriptDir & '\RemoteHistory' )
Run ( @ScriptDir & '\remote\CmRcViewer.exe ' & GUICtrlRead($CompName) )
EndIf
EndSwitch
EndFunc

Share this post


Link to post
Share on other sites



Hi,

You can use the _GUICtrlComboBox functions to manage the combo items (like _GUICtrlComboBox_AddString) OR you can set the data of the combo to empty and then set the content of the combo like when you start your script.

But it's too easy, I'm maybe missing something?

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I would suggest to put your FileRead code in a function then call the function to re-read the list

and update combo with GUICtrlSetData(Combo, "|" & NewList)

Share this post


Link to post
Share on other sites

well I have tried to figure out both of your recommendation and couldn't quite get it going, could you elaborate for me please?

Share this post


Link to post
Share on other sites

@Elephant007

C'mon... it's not a problem of understanding AutoIt.

;NOT TESTED

;connection to computer successful
_GUICtrlComboBox_InsertString($History, $lastcomputerID, 0)
$sHistory &= $lastcomputerID & "|"

FileWrite(..., StringTrimRight($sHistory, 1))


;retreive history list
$sHistory = FileRead(...) ;better to save data in INI files.
GUICtrlSetData($History, $sHistory, StringLeft($sHistory, StringInStr($sHistory, "|") -1))

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0