Jump to content

Multi use button for mp3, file, exe


Pike
 Share

Recommended Posts

Hey Everyone, I haven't been here in a while and recently picked up my old project. Still an FNG!

To the point: I want to be able to push the button and either play an mp3, open a file, or open an exe program (all with the same button). The problem is that I don't know how to code for that at "case 1"

        Case 1                                                                                                                                             
            Local $sRead = IniRead("config.ini", "Config", "One", "Default")                                
            SoundPlay($sRead, @HotKeyPressed)                                                                     <-------------------------------
            Run($sRead, @HotKeyPressed)                                                                                 <------------------------------- This 'Run' doesn't work even by itself!

See code below for layout. If you need more information I will attach more code or answer any questions. Any help is greatly appreciated.

 

Much Respect,

Pike

 

Func _HandleButton()

    $iClickCount += 1
    $iTimer = TimerInit()

    AdlibRegister("CheckButtonPress", $CheckTime)

EndFunc

Func CheckButtonPress()

    If TimerDiff($iTimer) < $CheckTime Or $iTimer = 0 Then Return

    Switch $iClickCount
        Case 1
            Local $sRead = IniRead("config.ini", "Config", "One", "Default")
            SoundPlay($sRead, @HotKeyPressed)
            Run($sRead, @HotKeyPressed)

        Case 2
         MsgBox(0, "INFORMATION:", "Choose the file you want designated to this button")
         Local $sFileOpenDialog = FileOpenDialog(0, @ScriptDir & "\", "All (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
         If @error Then
         MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
         EndIf
         Local $sFileName = InputBox("INFORMATION:", "Please Name Your File?" & @CRLF _
            & @CRLF _
            & "6 Characters or Less", "")

         IniWrite(@ScriptDir & "\config.ini", "Config", "One", $sFileOpenDialog)
         IniWrite(@ScriptDir & "\config.ini", "Config", "NameOne", $sFileName)
    EndSwitch

    $iClickCount = 0
    AdlibUnRegister()

EndFunc

 

notepad++_cAF75QV35j.png

Link to comment
Share on other sites

Help file will guide you...

SoundPlay ( "filename" [, wait = 0] )

Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )

@HotKeyPressed Last hotkey pressed. See the HotKeySet() function 

No wonder your code is not working...

 

Link to comment
Share on other sites

@Nine Thanks for replying. I am about as new as it gets, which is why it's amazing that I've gotten as far as I have. So what you said I only halfway understand. I guess maybe if I explain a little further it might help you to help me haha.

I tried this and it 'kind of' works...

            SoundPlay($sRead)
            ShellExecute($sRead)
            @HotKeyPressed

 

The problem is that if I have designated an mp3 to the button it will 'soundplay' the file and it will 'shellexecute' it. However, if I designate an exe program it works the way intended, because obviously it can't 'soundplay'. How do I stop the code at 'soundplay' if an mp3 is designated to the button???

Link to comment
Share on other sites

You can do checks for the extension and add conditions to some specific situations.

This is one way

$File = @DesktopDir&'\123.mp3'
$Ext = StringRight($File, 3)
ConsoleWrite('Extension: '&$Ext &@CRLF)
If $Ext = 'mp3' Then
ConsoleWrite('Act on the mp3 file' &@CRLF)
ElseIf $Ext = 'exe' Then
ConsoleWrite('Act on the exe file' &@CRLF)
Else
ConsoleWrite('Act on the files that aren"t exe or mp3' &@CRLF)
EndIf

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

For anyone who makes it to this page hoping for an answer this is the way I implemented the code from careca. Remember, my code is probably *hi* considering I'm a newbie, but maybe you can take something from it. *This is code based on communicating with a config.ini file...

Case 1
            Local $FolderPath = IniRead("config.ini", "Config", "One", "Default")
            Local $sRead = IniRead("config.ini", "Config", "One", "Default")
            Local $Ext = StringRight($sRead, 3)
                ConsoleWrite('Extension: '&$Ext &@CRLF)
            If $Ext = 'mp3' Then
                SoundPlay($sRead, @HotKeyPressed)
            ElseIf $Ext = 'exe' Then
                ShellExecute($sRead, @HotKeyPressed)
            ElseIf $Ext = 0 Then
                ShellExecute($sRead, @HotKeyPressed)
            EndIf

The thing I'm looking around for now, is how to list the different extensions, instead of having to utilize an "If" "ElseIf" statement for each one. Other than that, Good Luck and Have Fun.

Link to comment
Share on other sites

What do you mean by "list the different extensions"?

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

×
×
  • Create New...