Pike Posted February 20, 2019 Posted February 20, 2019 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 expandcollapse popupFunc _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
Nine Posted February 20, 2019 Posted February 20, 2019 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... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Pike Posted February 20, 2019 Author Posted February 20, 2019 @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???
careca Posted February 20, 2019 Posted February 20, 2019 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
Pike Posted February 21, 2019 Author Posted February 21, 2019 @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!
Pike Posted February 21, 2019 Author Posted February 21, 2019 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. Earthshine 1
careca Posted February 22, 2019 Posted February 22, 2019 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now