Jump to content
Sign in to follow this  
Pike

Multi use button for mp3, file, exe

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

Share this post


Link to post
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...

 

Share this post


Link to post
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???

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@careca Thanks for your reply as well... I'll start working on implementing that code into my code. I'm sure it'll work fine, of course, as a beginner I'll have to put in some work. Thanks very much!

Share this post


Link to post
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.

Share this post


Link to post
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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By kingjacob90
      Hi
      So I am trying to click the green button, this button is not always in the same place. So fare I am trying to click it by finding the color but there is also something else with the same color on the screen (circled in yellow) that is causing issues. Is there a way to use the Title and Class of the window (can't be just the window as there are more than one with the same name).
      How does AutoIt Info get this information?

    • By adjist
      Hello all! 
       
      Getting this error :
      (22) : ==> Variable used without being declared.: if $vNumber = 0 Then if ^ ERROR  
      But I'm sure I have defined the variable, as in the top of my script has 
      Global $vNumber = 0  
      How would I go about fixing this?
       
    • By MarkIT
      Hi AutoIT masters,
      Good day! Sorry to have bothered this forum but we really need help. We are working on an automation project that is running on VDI server. The BOTS are in .exe are running fine until AV detected them and deleted the files. The files were re-compiled and AV kept on deleting them. The copy of the .exe BOT deleted were sent to Symantec for whitelisting. After whitelisting, it is no longer deleted but no longer working as designed (showing Line script error). We checked the scripts and there were no issues since we run it using SciTE editor and it performed the desired task. Good thing we found on this thread the solution using .a3x and the BOTS worked fine and no longer deleted. Now, the problem is they are asking why the BOTS won't run in .EXE and what is the reason behind Symantec AV deleting them. We raised a case with Symantec but they cannot provide further information as they are always seeing the file as "False Positive". We even tested with Symantec turned off and those .EXE files are working fine, however, after re-enabling, it got deleted.
      Just seeking help on how to better convince them that it is really Symantec causing the issue and the .a3x file.
    • By AutoitMike
      Scite 3.4.4
      Win 10
      I click "Help" or press F1, there is no response
      If I use the file explorer and double click Autoit.chm or Autoit3.chm help opens.
      There is no dialog to check or uncheck "Always ask before opening this file" when clicking on these files.
       
      If you are curious as to why I dont have the latest version, I am creating a back up laptop that has a VERY extensive automation application that I have written over the past 15 years.
       
      An extremely potent, powerful, needed function has been deleted in the upgrade of Autoit in recent years that I can not do without. If my main laptop dies, which it almost did, I am in a very bad position. So I bought the exact same laptop and I am "cofiguring" it to work exactly the same as my main laptop. However, this one has been "Upgraded" to Win 10 which I hope is not the problem. 
      Thanks for any help
    • By Scriptmaster
      <NEWBIE ALERT>
      Is it possible to unzip a zip file in Autoit without using a dll!
      My script downloads a zip file to a temporary directory (successfully) and it must be unzipped to (Or moved to after unzip) another a folder which just happens to be
      @scriptdir & "file.exe" Thanks in advance
×
×
  • Create New...