Jump to content

I give up.


Recommended Posts

#include <GUIConstants.au3>
; == GUI generated with Koda ==
Opt("GUIOnEventMode", 1)
$Drive = DriveSpaceFree ( "" & DriveGetDrive ( "Removable" ) )
$Form1 = GUICreate("USBer", 199, 249, 439, 296)
$RemoveProg = GUICtrlCreateButton("Remove prog", 120, 56, 73, 25)
guictrlsetonevent ($RemoveProg, "RemoveProg")
$Launchpad1 = GUICtrlCreateList ("Programs", 0, 32, 113, 201)
GUICtrlSetOnEvent ( $Launchpad1, "LaunchIt")
$ExploreDrive = GUICtrlCreateButton("ExploreDrive", 120, 104, 73, 25)
guictrlsetonevent ($ExploreDrive, "ExploreDrive")
$AddProgram = GUICtrlCreateButton("Add program", 120, 8, 73, 25)
guictrlsetonevent ($AddProgram, "AddProgram")
$Save = GUICtrlCreateButton("Save", 120, 208, 73, 25)
guictrlsetonevent ($Save, "Save")
$SpaceOnDrive = GUICtrlCreateButton("Space Free", 0, 0, 81, 25)
guictrlsetonevent ($SpaceOnDrive, "SpaceOnDrive")
$Rename = GUICtrlCreateButton("Rename", 120, 152, 73, 25)
guictrlsetonevent ($Rename, "Rename")
GUISetOnEvent ($GUI_EVENT_CLOSE, "Exit1")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func SpaceOnDrive()
    MsgBox(4096, "Space free", $Drive & " MB" )
EndFunc

Func RemoveProg()
    $Var2 = GUICtrlRead ( $Launchpad1 )
    GUICtrlDelete ( $Var2 )
    ;This doesn't work.
    ;Why.
EndFunc

Func ExploreDrive()
    $var4 = DriveGetDrive ( "Removable" )
    ;There seems to be no function to open a path given, so how would I go about doing this?
    ;(I want it to open $var4)
EndFunc

Func AddProgram()
    $Var1  = FileOpenDialog ( "Select File To Add", DriveGetDrive ( "Removable" ), "(*.*)" )
    Guictrlsetdata ( $Launchpad1, $var1)
    ;This works, yay.
EndFunc

Func LaunchIt()
    $Open = GUICtrlRead ( $Launchpad1 )
    $Open2 = FileGetShortName($Open)
        Run($Open)
EndFunc

Func Save()
    ;working on it later
    EndFunc
    
    Func Rename()
        $WhattoRename = GuictrlRead ($Launchpad1)
        $InputBox = InputBox ("Rename To...", "What would you like to rename " & $WhatToRename & " to?")
        $Rename = GUICtrlRead ($InputBox)
        GUICtrlSetData ( $WhattoRename, $InputBox)
        ;I think I;m doing something wrong with the GUIctrlread, But I can't tell what...
        ;(I want it to read the input box and set the data to the input box)
        endFunc
        
        func Exit1()
   Exit
endfunc

Read the comments. It's where my problems are.

Also, For the rename, is there a simple way to show the datas name as something else? Like, rename it to notepad, but the value still equals C:\File\Notepad.exe? (<- Example)

Edit: I fixed the launch program part.

Edited by alex OF DEATH
Link to comment
Share on other sites

Read the comments. It's where my problems are.

You did. But at least at one occasion you did not tell us what you wanted it to do, so we/I have to guess. :D

For instance this :

Func RemoveProg()
    $Var2 = GUICtrlRead ( $Launchpad1 )
    GUICtrlDelete ( $Var2 )
    ;This doesn't work.
    ;Why.
EndFunc
I assume you want to delete a file. But why than are you not doing that, but instead are trying to delete a control ? :) See what "FileDelete(...)" can do for you :P

As for the function "ExploreDrive()" ? Would looking for a file-function perhaps be apropriate ? like "FileOpenDialog", "FileSaveDialog" or "FileSelectFolder" ?

And in "FuncRename()" ? The only thing you are doing there, in the line "GUICtrlSetData ( $WhattoRename, $InputBox)", is to set a control's data (the wrong way, as the first argument should be a control-ID, not some text), not to actually rename a file. In this case, again a function starting with "File". But, as a "FileRename" does not exist you will need to use the "FileMove" for that.

Hope that helps.

Link to comment
Share on other sites

You did. But at least at one occasion you did not tell us what you wanted it to do, so we/I have to guess. :D

For instance this :

Func RemoveProg()
    $Var2 = GUICtrlRead ( $Launchpad1 )
    GUICtrlDelete ( $Var2 )
    ;This doesn't work.
    ;Why.
EndFunc
I assume you want to delete a file. But why than are you not doing that, but instead are trying to delete a control ? :) See what "FileDelete(...)" can do for you :P

As for the function "ExploreDrive()" ? Would looking for a file-function perhaps be apropriate ? like "FileOpenDialog", "FileSaveDialog" or "FileSelectFolder" ?

And in "FuncRename()" ? The only thing you are doing there, in the line "GUICtrlSetData ( $WhattoRename, $InputBox)", is to set a control's data (the wrong way, as the first argument should be a control-ID, not some text), not to actually rename a file. In this case, again a function starting with "File". But, as a "FileRename" does not exist you will need to use the "FileMove" for that.

Hope that helps.

I should have been more clear on my comments, but did you actually run the program?

Removeprog() Removes a program from $launchpad1 Launchpad1 is a list. It simply removes the program from the list. $Var2 Reads what is highlighted on the launchpad, Then GUICtrldelete removes $Var2.

I want Exploredrive() to Open the USB's drive path. I would assume to use:

(Example)

$RandomVariable = DriveGetDrive("Removable")

Open $RandomVariable

(end example)

In MY case, DriveGetDrive would return "H:\" and the hypothetical "open" function would open "H:\", But I don't know how I could open it. (Since "Open" Isn't a function for this)

For Rename(), $WhatToRename = The highlighted thing in the list ($Launchpad1), correct? $InputBox = A Input box, $rename = Guictrl read The text inputted to the input box. The GUIctrlSetData (Whattorename = what is highlighted in the launchpad1 List, then it sets it to THe text in the input box, correct? Well, It dont work for some reason. What it's SUPPOSED to do is rename what is highlighted in the list. to what the user puts into the input box.

Also, "(the wrong way, as the first argument should be a control-ID, not some text)" Whattorename = Guictrlread $Launchpad1. So it reads the data from the controlID. I don't see how it is incorrect, but I see how you see it is incorrect.

Link to comment
Share on other sites

This should do it...

:)

#include <GUIConstants.au3>
#include <GUIList.au3>
; == GUI generated with Koda ==
Opt("GUIOnEventMode", 1)
$Drive = DriveSpaceFree ( "" & DriveGetDrive ( "Removable" ) )
$Form1 = GUICreate("USBer", 199, 249, 439, 296)
$RemoveProg = GUICtrlCreateButton("Remove prog", 120, 56, 73, 25)
guictrlsetonevent ($RemoveProg, "RemoveProg")
$Launchpad1 = GUICtrlCreateList ("Programs", 0, 32, 113, 201)
GUICtrlSetOnEvent ( $Launchpad1, "LaunchIt")
$ExploreDrive = GUICtrlCreateButton("ExploreDrive", 120, 104, 73, 25)
guictrlsetonevent ($ExploreDrive, "ExploreDrive")
$AddProgram = GUICtrlCreateButton("Add program", 120, 8, 73, 25)
guictrlsetonevent ($AddProgram, "AddProgram")
$Save = GUICtrlCreateButton("Save", 120, 208, 73, 25)
guictrlsetonevent ($Save, "Save")
$SpaceOnDrive = GUICtrlCreateButton("Space Free", 0, 0, 81, 25)
guictrlsetonevent ($SpaceOnDrive, "SpaceOnDrive")
$Rename = GUICtrlCreateButton("Rename", 120, 152, 73, 25)
guictrlsetonevent ($Rename, "Rename")
GUISetOnEvent ($GUI_EVENT_CLOSE, "Exit1")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func SpaceOnDrive()
    MsgBox(4096, "Space free", $Drive & " MB" )
EndFunc

Func RemoveProg()
    _GUICtrlListDeleteItem($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1))
EndFunc

Func ExploreDrive()
    $var4 = DriveGetDrive ( "Removable" )
    Run(@WindowsDir & "\explorer.exe " & $var4)
EndFunc

Func AddProgram()
    $Var1  = FileOpenDialog ( "Select File To Add", DriveGetDrive ( "Removable" ), "(*.exe)" )
    _GUICtrlListAddItem($Launchpad1, $Var1)
    ;This works, yay.
EndFunc

Func LaunchIt()
    $Open = _GUICtrlListGetText($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1))
    Run($Open)
EndFunc

Func Save()
    ;working on it later
    EndFunc
    
Func Rename()
        $InputBox = InputBox ("Rename To...", "What would you like to rename " & _GUICtrlListGetText($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1)) & " to?")
        _GUICtrlListReplaceString($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1), $InputBox)
endFunc
        
func Exit1()
   Exit
endfunc
Edited by CHRIS95219
Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <GUIList.au3>
; == GUI generated with Koda ==
Opt("GUIOnEventMode", 1)
$Drive = DriveSpaceFree ( "" & DriveGetDrive ( "Removable" ) )
$Form1 = GUICreate("USBer", 199, 249, 439, 296)
$RemoveProg = GUICtrlCreateButton("Remove prog", 120, 56, 73, 25)
guictrlsetonevent ($RemoveProg, "RemoveProg")
$Launchpad1 = GUICtrlCreateList ("Programs", 0, 32, 113, 201)
GUICtrlSetOnEvent ( $Launchpad1, "LaunchIt")
$ExploreDrive = GUICtrlCreateButton("ExploreDrive", 120, 104, 73, 25)
guictrlsetonevent ($ExploreDrive, "ExploreDrive")
$AddProgram = GUICtrlCreateButton("Add program", 120, 8, 73, 25)
guictrlsetonevent ($AddProgram, "AddProgram")
$Save = GUICtrlCreateButton("Save", 120, 208, 73, 25)
guictrlsetonevent ($Save, "Save")
$SpaceOnDrive = GUICtrlCreateButton("Space Free", 0, 0, 81, 25)
guictrlsetonevent ($SpaceOnDrive, "SpaceOnDrive")
$Rename = GUICtrlCreateButton("Rename", 120, 152, 73, 25)
guictrlsetonevent ($Rename, "Rename")
GUISetOnEvent ($GUI_EVENT_CLOSE, "Exit1")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func SpaceOnDrive()
    MsgBox(4096, "Space free", $Drive & " MB" )
EndFunc

Func RemoveProg()
    _GUICtrlListDeleteItem($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1))
EndFunc

Func ExploreDrive()
    $var4 = DriveGetDrive("ALL")
    Local $message
    For $i = 1 to $var4[0]
        $message &= "("&$i&")" & $var4[$i] & " - " & DriveGetLabel($var4[$i]) & ":" & DriveGetType($var4[$i]) & @CRLF
    Next
    $INputDrive = $var4[0]+1
    while ($INputDrive > $var4[0] or $INputDrive == 0)
        $INputDrive = INputBox("Drive Selector", "Enter the number of the drive you wish to explore " & @CRLF & $message)
    WEnd
    Run(@WindowsDir & "\explorer.exe " & $var4[$INPutDrive])
EndFunc

Func AddProgram()
    $Var1  = FileOpenDialog ( "Select File To Add", DriveGetDrive ( "Removable" ), "(*.exe)" )
    _GUICtrlListAddItem($Launchpad1, $Var1)
    ;This works, yay.
EndFunc

Func LaunchIt()
    $Open = _GUICtrlListGetText($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1))
    Run($Open)
EndFunc

Func Save()
    ;working on it later
    EndFunc
    
Func Rename()
        $InputBox = InputBox ("Rename To...", "What would you like to rename " & _GUICtrlListGetText($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1)) & " to?")
        _GUICtrlListReplaceString($Launchpad1, _GUICtrlListGetCaretIndex($Launchpad1), $InputBox)
endFunc
        
func Exit1()
   Exit
endfunc

This should fix that.

Edited by CHRIS95219
Link to comment
Share on other sites

I should have been more clear on my comments, but did you actually run the program?

Nope. You got me there. :)

I don't see how it is incorrect, but I see how you see it is incorrect.

Somehow I got the notion that your "$Launchpad1" had something to do with "notepad", a simple text-file (maybe because of that last remark), and just did not bother to actually go fully thru your code. :P Sorry.
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...