Jump to content
Sign in to follow this  
jpaytoncfd

Simple GUI

Recommended Posts

jpaytoncfd

I found a useful application that someone else built that checks a Windows XP KEY to find the PID. unfotunitly its only a CMD line app. that outputs a messy looking CSV of several things. So I want to make a GUI that will let you enter a key run the CMD and show just the PID in a text box so a user can copy and paste. I am wondering where to start. I have no software coding knowledge at all. Just some web design. So I appoligize in advance for all the questions I am sure I'll be asking.

Share this post


Link to post
Share on other sites
somdcomputerguy

I am wondering where to start.

Welcome to the Forum. The best place to start is page 1 in the Help file! :) In particular, browse thru the GUI Management section, and look at the GUICreate & GUICtrlInput functions.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
jpaytoncfd

Do you want to change your PID?

Nope Just get one for a users key.

Definitely start with Koda

In this tool you can visually create GUI and then it will generate Autoit source code for GUI part of AU3 script.

That was extremely Helpfull (I Think) Now I have a GUI that looks good.Just have to figure out what im doing.

Welcome to the Forum. The best place to start is page 1 in the Help file! :) In particular, browse thru the GUI Management section, and look at the GUICreate & GUICtrlInput functions.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Docs\Joe\Desktop\Koda\Forms\PIDCHK.kxf
$Form1 = GUICreate("Form1", 314, 173, 192, 124)
$Input1 = GUICtrlCreateInput("", 24, 56, 41, 21)
$Input2 = GUICtrlCreateInput("", 80, 56, 41, 21)
$Input3 = GUICtrlCreateInput("", 136, 56, 41, 21)
$Input4 = GUICtrlCreateInput("", 192, 56, 41, 21)
$Input5 = GUICtrlCreateInput("", 248, 56, 41, 21)
$Button1 = GUICtrlCreateButton("Get PID", 184, 104, 75, 25)
$Button2 = GUICtrlCreateButton("Cancel", 56, 104, 75, 25)
$Label1 = GUICtrlCreateLabel("LRIT PID Checker", 80, 16, 153, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("CHKPIDS v0.93 by CusterBeaten", 144, 144, 162, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
    EndSwitch
WEnd

Thats what koda gave me. How do I turn the entered text into variables? I am thinking this should be simple. All I need it to do is run:

CHKPIDS XXXXX-XXXXX-XXXXX-XXXXX-XXXXX > PID.id

And maybe send the file to the e-mail program file. But thats uninportant

Share this post


Link to post
Share on other sites
pieeater

you can use GUICtrlRead(), look it up in the help file


[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites
jpaytoncfd

ok, this makes a file great. But it dosent wait for the button press. It blinks and makes the file with defult values. Which I expected because I havent setup a command for the button.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Docs\Joe\Desktop\Koda\Forms\PIDCHK.kxf
Opt('MustDeclareVars', 1)

Func Example()

GUICreate("Form1", 314, 173, 192, 124)
$Input1 = GUICtrlCreateInput("", 24, 56, 41, 21)
$Input2 = GUICtrlCreateInput("", 80, 56, 41, 21)
$Input3 = GUICtrlCreateInput("", 136, 56, 41, 21)
$Input4 = GUICtrlCreateInput("", 192, 56, 41, 21)
$Input5 = GUICtrlCreateInput("", 248, 56, 41, 21)
$Button1 = GUICtrlCreateButton("Get PID", 184, 104, 75, 25)
GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button
$Button2 = GUICtrlCreateButton("Cancel", 56, 104, 75, 25)
$Label1 = GUICtrlCreateLabel("LRIT PID Checker", 80, 16, 153, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("CHKPIDS v0.93 by CusterBeaten", 144, 144, 162, 17)

    GUISetState() ; will display an empty dialog box
    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
        If $msg = $n2 Then

        FileChangeDir(@ScriptDir)
        $file = FileOpen("pid.cmd", 1)

        ; Check if file opened for writing OK
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf

        FileWrite($file, "@echo off" & @CRLF)
        FileWrite($file, "CHKPIDS " & GUICtrlRead($Input1) & "-" & GUICtrlRead($Input2) & "-" & GUICtrlRead($Input3) & "-" & GUICtrlRead($Input4) & "-" & GUICtrlRead($Input5) & " > file.txt" & @CRLF)
        FileWrite($file, "pause" & @CRLF)
        FileWrite($file, "END" & @CRLF)

        FileClose($file)
        EndIf
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites
jpaytoncfd

I tried doing everything in the GUICtrlRead() example but it just blinks

Share this post


Link to post
Share on other sites
jpaytoncfd

Still playing, now it dosent do anything. But the syntax checker dosent show anything Wrong.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Docs\Joe\Desktop\Koda\Forms\PIDCHK.kxf


Func Example()
    Local $Input1, $Input2, $Input3, $Input4, $Input5, $Button1, $Button2, $Label1, $Label2

GUICreate("Form1", 314, 173, 192, 124)
$Input1 = GUICtrlCreateInput("", 24, 56, 41, 21)
$Input2 = GUICtrlCreateInput("", 80, 56, 41, 21)
$Input3 = GUICtrlCreateInput("", 136, 56, 41, 21)
$Input4 = GUICtrlCreateInput("", 192, 56, 41, 21)
$Input5 = GUICtrlCreateInput("", 248, 56, 41, 21)
$Button1 = GUICtrlCreateButton("Get PID", 184, 104, 75, 25)
GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button
$Button2 = GUICtrlCreateButton("Cancel", 56, 104, 75, 25)
$Label1 = GUICtrlCreateLabel("LRIT PID Checker", 80, 16, 153, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("CHKPIDS v0.93 by CusterBeaten", 144, 144, 162, 17)

    GUISetState() ; will display an empty dialog box
    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
        If $msg = $Button1 Then

        FileChangeDir(@ScriptDir)
        $file = FileOpen("pid.cmd", 1)

        ; Check if file opened for writing OK
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf

        FileWrite($file, "@echo off" & @CRLF)
        FileWrite($file, "CHKPIDS " & GUICtrlRead($Input1) & "-" & GUICtrlRead($Input2) & "-" & GUICtrlRead($Input3) & "-" & GUICtrlRead($Input4) & "-" & GUICtrlRead($Input5) & " > file.txt" & @CRLF)
        FileWrite($file, "pause" & @CRLF)
        FileWrite($file, "END" & @CRLF)

        FileClose($file)
        EndIf
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites
pieeater

this part:

FileWrite($file, "@echo off" & @CRLF)
        FileWrite($file, "CHKPIDS " & GUICtrlRead($Input1) & "-" & GUICtrlRead($Input2) & "-" & GUICtrlRead($Input3) & "-" & GUICtrlRead($Input4) & "-" & GUICtrlRead($Input5) & " > file.txt" & @CRLF)
        FileWrite($file, "pause" & @CRLF)
        FileWrite($file, "END" & @CRLF)

happens over again because you havent made it wait to run those commands. heres what i did to fix it:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Docs\Joe\Desktop\Koda\Forms\PIDCHK.kxf
                                                ;<<<<<took out the unneeded function commands
GUICreate("Form1", 314, 173, 192, 124)
$Input1 = GUICtrlCreateInput("", 24, 56, 41, 21)
$Input2 = GUICtrlCreateInput("", 80, 56, 41, 21)
$Input3 = GUICtrlCreateInput("", 136, 56, 41, 21)
$Input4 = GUICtrlCreateInput("", 192, 56, 41, 21)
$Input5 = GUICtrlCreateInput("", 248, 56, 41, 21)
$Button1 = GUICtrlCreateButton("Get PID", 184, 104, 75, 25)
GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button
$Button2 = GUICtrlCreateButton("Cancel", 56, 104, 75, 25)
$Label1 = GUICtrlCreateLabel("LRIT PID Checker", 80, 16, 153, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("CHKPIDS v0.93 by CusterBeaten", 144, 144, 162, 17)

GUISetState() ; will display an empty dialog box
; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    If $msg = $Button1 Then  ;<<<< the problem was you used the wrong variable, its $button1 not $n2
        FileChangeDir(@ScriptDir)
        $file = FileOpen("pid.cmd", 1)

        ; Check if file opened for writing OK
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf

        FileWrite($file, "@echo off" & @CRLF)
        FileWrite($file, "CHKPIDS " & GUICtrlRead($Input1) & "-" & GUICtrlRead($Input2) & "-" & GUICtrlRead($Input3) & "-" & GUICtrlRead($Input4) & "-" & GUICtrlRead($Input5) & " > file.txt" & @CRLF)
        FileWrite($file, "pause" & @CRLF)
        FileWrite($file, "END" & @CRLF)

        FileClose($file)
    ElseIf $msg = $Button2 Then
        Exit
    EndIf
Until $msg = $GUI_EVENT_CLOSE

also the reason your second attempt wasn't working was because autoit functions have to be called, they won't start otherwise, you would have to put this : Example() at the top of your script to call it.

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites
jpaytoncfd

No for running the .cmd file that makes. I have tried run and runwait.

Local $val = RunWait("\pid.cmd", @WindowsDir, @SW_MAXIMIZE)
    MsgBox(0, "Program returned with exit code:", $val)

It just pops up with a 0 and dosent run the script. I am trying ShellExecuteWait next. Is there a way to make and run the cmd directly, rather than making a file and running that?

Can It read the outcome of the CMD? Which is a CSV that looks like this?

"Key","Grade","PID","Flags"
"MxxRW-xxxxx-HHxxP-xxxxx-Y7xxM","{;OEM-CH_HOME-SP2-37973878;}","(55274-OEM-00119
03-00584)","[;OEM;OEM-]"
Press any key to continue . . .

Share this post


Link to post
Share on other sites
jpaytoncfd

It runs great now, enter the key and it opens the file made but the .cmd. and I even limited the text boxes to 5 characters. Is there something that will automatically move to the next box when one gets filled? and not allow the "-". (so someone could copy and paste into the first box)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.