Jump to content

When i make a button how do i make it open a file?


Recommended Posts

You have a few options, but it depends on what exactly you are trying to do? For a start try this.

Case $msg = $button1
  $file = FileOpenDialog("File to open",@WorkingDir,)
  msgbox(0,"You Chose",$file)

That's just off the top of my head. I don't have AutoIt on this computer. But there's an idea of how to get started with whatever you're trying to acheive.

Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Link to comment
Share on other sites

  • Moderators

wow, i am still confused i just want to open up a folder by pressing a button wtf? would i use it as a link with shellExecute? to like my documents

ShellExecute(@MyDocumentsDir)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

ShellExecute(@MyDocumentsDir)

i just tried that and it doesnt open up my docs here is my script... i am trying to make a program that opens up then you choose were you want to go around your cpu so i want to hit a button then go to that folder...

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 441, 166, 193, 125)

$Button1 = GUICtrlCreateButton("School", 320, 128, 105, 25, 0)

$Button2 = GUICtrlCreateButton("Music", 168, 128, 105, 25, 0)

$Button3 = GUICtrlCreateButton("Programs", 8, 128, 105, 25, 0)

$Label1 = GUICtrlCreateLabel("Desktop In A BoX...Chose What You Would Like To Do?", 8, 80, 419, 27)

GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS")

$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\IBM\My Documents\My Pictures\BOX!.bmp", 0, 0, 76, 68, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\IBM\My Documents\My Pictures\BETA.bmp", 320, 8, 108, 60, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button1

ShellExecute(@MyDocumentsDir)

EndSelect

Wend

Link to comment
Share on other sites

  • Moderators

Works fine for me:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 441, 166, 193, 125)
$Button1 = GUICtrlCreateButton("School", 320, 128, 105, 25, 0)
$Button2 = GUICtrlCreateButton("Music", 168, 128, 105, 25, 0)
$Button3 = GUICtrlCreateButton("Programs", 8, 128, 105, 25, 0)
$Label1 = GUICtrlCreateLabel("Desktop In A BoX...Chose What You Would Like To Do?", 8, 80, 419, 27)
GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS")
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\IBM\My Documents\My Pictures\BOX!.bmp", 0, 0, 76, 68, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\IBM\My Documents\My Pictures\BETA.bmp", 320, 8, 108, 60, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            ShellExecute(@MyDocumentsDir)
    EndSelect
WEnd
Be sure you are using the "School" button which is button 1 in your gui.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...