# 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

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

## Create an account

Register a new account

• ### Similar Content

• Good morning,

I am trying to align a two-line text in a button so that it would be centered in the button but can't succeed to do it for the vertical part.
Can someone tell me what I do wrong ?
Here is my code:
$btn3 = GUICtrlCreateButton("Execute " & @LF & " file 1", 100, 65, 60, 50, _ BitOr($BS_CENTER,$BS_BOTTOM,$BS_MULTILINE)) and here is the resulting layout I get in my window.
I tried to follow the help, made a lot of different parameter combinations (here it's $BS_BOTTOM, but I tried $BS_VCENTER and BS_TOP), still get the same result : vertical alignement is a no go for me. Can someone help ? TIA Gilles • So basically need to pull text from a .txt file or .sql and use that text to replace something within a different file. First File: jumps Or: Text1 = jumps Text2 = fence Second File: My Dog XXXXX over the YYYYY. After Script: My Dog jumps over the fence I have found a good start, I'm basic programmer at best, I have some experience but this gets out of my wheel house. Any help is appreciated. • hi dears, i have a question please am now working for an audio player for the blind users and i added an option to open a file from the right click context menu. but here there is a small problem, i hope that you can help me to find a solution for it. the problem is as follow : when i added the problem into the context menu it work with successfuly if the user select just one file. but if the user selected more then one file, here the problem a multiple sections of the program will open. my question is : how i can detect the multiple selection from the context menu? i know that it so hard, but i know also that you are harder than it for that dears please try to give me an solution for that problem. thanks in advance • By misioooo Hi! I am writing some GUI and i need to use images as buttons, but with text on them (text is from INI file). Part with button looks like this:ankieta1 = GUICtrlCreateButton($txtAnk1, 100,350,765,164) GUICtrlSetFont(-1, 22, 800, -1, "Arial") ;GUICtrlSetColor(-1,0xffffff)$hImageBtn_1 = _GUIImageList_Create(765, 164) _GUIImageList_AddBitmap($hImageBtn_1, "c:\path\to\ankieta_clean.bmp") _GUICtrlButton_SetImageList($ankieta1, \$hImageBtn_1, 4) GUICtrlSetOnEvent(-1, "On_Ankieta1") The problem - if i uncomment GUICtrlSetColor, color of text changes, but button is just plain gray (no image). How i can change text color not touching image on a button here?
• By Skeletor
Hey All,
Yes, this is an odd request.
But is there a way to bulk up the size of the compiled program?
I know many want to reduce it's size, but I want to increase it.
What methods do you suggest?
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...