Jump to content

Creating actions for dynamic buttons.


Recommended Posts

First of all I'm new to Autoit and it is refreshing to see that there is a community that is willing to help the noobs out with their coding misadventures. My question, I hope it's an easy solve for most of you, is that I created a function that will create some buttons based on a search in a directory for a specific file name. What happens is my buttons get named the same as the file names. What should happen is if I click on any of the buttons, Notepad runs and opens the specific file based on the button.

Here's the code:

FUNC SearchServer()

$xlocation = 20

$ylocation = 145

$width = 100

$height = 20

$i = 0

FileChangeDir("H:\common")

$search = FileFindFirstFile("*.txt")

While $i <= 10

$filearray[$i] = FileFindNextFile($search)

$PXEarray[$i] = $filearray[$i]

If @error Then

$i = $i - 1

ExitLoop

Else

$i = $i + 1

EndIf

Wend

$i = 0

While $i <= 10

If $filearray[$i] = "" Then

ExitLoop

Else

If $i = 5 Then

$xlocation = 200

$ylocation = 150

EndIf

$filearray[$i] = StringUpper($filearray[$i])

GuICtrlCreateButton($filearray[$i], $xlocation, $ylocation, $width, $height)

GUICtrlSetOnEvent(-1, "PXEbuttonexec")

$t = FileGetTime($filearray[$i],1)

$date = $t[1] & "/" & $t[2] & "/" & $t[0]

GUICtrlCreateLabel($date,$xlocation + 110,$ylocation,70,20)

EndIf

$ylocation = $ylocation + 25

$i = $i + 1

Wend

Link to comment
Share on other sites

Is it just me or do you get syntax errors as well as some other errors when you run this script?

Is it possible for you to post your whole code or enough of it to test with?

Edited by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
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...