Zacam Posted October 7, 2009 Posted October 7, 2009 This is my 3rd project script for here at work. It's just a front end GUI for passing an ID string to a fixed location via VNC Single-Click application. It probably is not the best or most efficient way to handle the process, I will admit, but I developed it to be as simple as possible. The "key-pad" is because not all of the systems this will be used on may have a keyboard/mouse, but will always have a touch screen, though manual entry is still possible as well. The only issue I have with it is that the "CONNECT" button flickers when the 3rd button/number is selected. You can even modify this a bit more in the event you don't have a static repeater via a combo-box or what not. This runs just fine for me, but any feedback on how to potentially optimize all the Case statements that I have would be great. :-) You will need your own winvnc.exe\vnchooks.dll. UltraVNC offers a single click tool that works based off a 24 HOSTS connection txt file, but for what we needed, we didn't want 5 different execs. The end result exe it provides is just a 7z SFX that contains the two necessary pieces. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Remote Support", 180, 320, 405, 380) $Label1 = GUICtrlCreateLabel("Only use this Tool by request" & @crlf & " of the Help Desk.", 10, 10, 155, 30, $ES_CENTER) $Input1 = GUICtrlCreateInput("", 20, 40, 135, 20, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit($Input1, 4) $Clear = GUICtrlCreateButton("Clear", 20, 65, 135, 20, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($Clear, 0) $B01 = GUICtrlCreateButton("1", 20, 100, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B01, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B02 = GUICtrlCreateButton("2", 75, 100, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B02, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B03 = GUICtrlCreateButton("3", 125, 100, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B03, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B04 = GUICtrlCreateButton("4", 20, 150, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B04, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B05 = GUICtrlCreateButton("5", 75, 150, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B05, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B06 = GUICtrlCreateButton("6", 125, 150, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B06, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B07 = GUICtrlCreateButton("7", 20, 200, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B07, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B08 = GUICtrlCreateButton("8", 75, 200, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B08, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B09 = GUICtrlCreateButton("9", 125, 200, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B09, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $B10 = GUICtrlCreateButton("0", 75, 250, 30, 30, BitOR($BS_CENTER, $BS_PUSHLIKE, $WS_GROUP)) GUICtrlSetCursor($B10, 0) GUICtrlSetFont(-1, 10, 800, 0, "System") $Cancel = GUICtrlCreateButton("Cancel", 10, 290, 60, 25, $WS_GROUP) GUICtrlSetCursor($Cancel, 0) $Connect = GUICtrlCreateButton("CONNECT", 110, 290, 60, 25, $WS_GROUP) GUICtrlSetCursor($Connect, 0) GUICtrlSetState($Connect, $GUI_DISABLE) GUISetState(@SW_SHOW) While 1 Key() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If FileExists(@WindowsDir & "\winvnc.exe") Then FileDelete(@WindowsDir & "\winvnc.exe") If FileExists(@WindowsDir & "\vnchooks.dll") Then FileDelete(@WindowsDir & "\vnchooks.dll") Exit Case $Clear GUICtrlSetData($Input1, "") GUICtrlSetState($Connect, $GUI_DISABLE) Case $B01 B01SET() Case $B02 B02SET() Case $B03 B03SET() Case $B04 B04SET() Case $B05 B05SET() Case $B06 B06SET() Case $B07 B07SET() Case $B08 B08SET() Case $B09 B09SET() Case $B10 B10SET() Case $Connect VNC() Case $Cancel If FileExists(@WindowsDir & "\winvnc.exe") Then FileDelete(@WindowsDir & "\winvnc.exe") If FileExists(@WindowsDir & "\vnchooks.dll") Then FileDelete(@WindowsDir & "\vnchooks.dll") Exit EndSwitch WEnd Func KEY() $LENGTH = StringLen(GUICtrlRead($Input1)) If $LENGTH = 3 Then GUICtrlSetState($Connect, BitOR($GUI_SHOW, $GUI_ENABLE, $GUI_ONTOP)) EndFunc Func B01SET() If $B01 Then GUICtrlSetData($Input1, "1", "0") EndFunc Func B02SET() If $B02 Then GUICtrlSetData($Input1, "2", "0") EndFunc Func B03SET() If $B03 Then GUICtrlSetData($Input1, "3", "0") EndFunc Func B04SET() If $B04 Then GUICtrlSetData($Input1, "4", "0") EndFunc Func B05SET() If $B05 Then GUICtrlSetData($Input1, "5", "0") EndFunc Func B06SET() If $B06 Then GUICtrlSetData($Input1, "6", "0") EndFunc Func B07SET() If $B07 Then GUICtrlSetData($Input1, "7", "0") EndFunc Func B08SET() If $B08 Then GUICtrlSetData($Input1, "8", "0") EndFunc Func B09SET() If $B09 Then GUICtrlSetData($Input1, "9", "0") EndFunc Func B10SET() If $B10 Then GUICtrlSetData($Input1, "0", "0") EndFunc Func VNC() $ID = GUICtrlRead($Input1) Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(4164,"Connection Settings","You are about to establish a connection with Agent " & $ID & @crlf & "Proceed with this connection?") Select Case $iMsgBoxAnswer = 6 ;Yes GUISetState(@SW_HIDE) FileInstall("winvnc.exe", @WindowsDir & "\winvnc.exe", 1) FileInstall("vnchooks.dll", @WindowsDir & "\vnchooks.dll", 1) ; RunWait("winvnc.exe -id " & $ID & " -connect $PYRHERE$ -noregistry", @WindowsDir, @SW_SHOW) ;Un-comment the above line after setting the Repeater in place of $PYRHERE$. $ID is generated based off input in the Input1 box. GUISetState(@SW_SHOW) GUICtrlSetData($Input1, "") GUICtrlSetState($Connect, $GUI_DISABLE) Case $iMsgBoxAnswer = 7 ;No GUICtrlSetData($Input1, "") GUICtrlSetState($Connect, $GUI_DISABLE) EndSelect EndFunc
ResNullius Posted October 9, 2009 Posted October 9, 2009 The only issue I have with it is that the "CONNECT" button flickers when the 3rd button/number is selected. That's because your Key() function is constantly refreshing the Button State even after it's set once. Try adding a global variable to store the old value of the key and do a comparison before refreshing the button state Global $oldKey Then modify your Key function like so: Func KEY() $key = GUICtrlRead($Input1) If $key <> $oldKey then If StringLen($key) = 3 then GUICtrlSetState($Connect, BitOR($GUI_SHOW, $GUI_ENABLE, $GUI_ONTOP)) Else GUICtrlSetState($Connect, $GUI_DISABLE) EndIf EndIf $oldKey = $key EndFunc
Zacam Posted October 9, 2009 Author Posted October 9, 2009 Thanks! With the above, the StringLen needs correction to 4 in order to work, but that is so much better. Thank you.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now