IanN1990 Posted October 17, 2011 Author Share Posted October 17, 2011 Thanks for everyones help i now have a mostly functional script that extends the use of my media controller and gained some useful information on syntax Very greatful to everyone Link to comment Share on other sites More sharing options...
guinness Posted October 17, 2011 Share Posted October 17, 2011 (edited) So what was the final code you used? I'm thinking it could help those in the future who might come across this post. Edited October 18, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
IanN1990 Posted October 18, 2011 Author Share Posted October 18, 2011 (edited) hmm ok Though is under the condiction you dont laugh XD I am fully aware my code doesn't look proffesional but it works which makes me happy and in a crazy/mad sciencest way i understand but anyways.. expandcollapse popup#NoTrayIcon #include <Misc.au3> $dll = DllOpen("user32.dll") local $MediaPlayer=0 While 1 Sleep ( 25 ) If _IsPressed("B3", $dll) Then ;Pause If $MediaPlayer=1 Then send("{MEDIA_PlAY_PAUSE}") sleep(50) SendKeepActive("[Class:Winamp v1.x]") Send("{SPACE}") run ("D:\Desktop\Pause.exe") EndIf EndIf If _IsPressed("B1", $dll) Then ;<- Track If $MediaPlayer=1 Then send("{MEDIA_NEXT}") sleep(50) SendKeepActive("[Class:Winamp v1.x]") Send("^{LEFT}") run ("D:\Desktop\Prev.exe") EndIf EndIf If _IsPressed("B0", $dll) Then ;-> Track If $MediaPlayer=1 Then send("{MEDIA_PREV}") sleep(50) SendKeepActive("[Class:Winamp v1.x]") Send("^{RIGHT}") run ("D:\Desktop\Next.exe") EndIf EndIf If _IsPressed("B2", $dll) Then ;Stop if $MediaPlayer=1 Then $MediaPlayer = 0 Else $MediaPlayer = 1 EndIf EndIf WEnd DllClose($dll) Code for Pause.exe #NoTrayIcon HotKeySet("{MEDIA_PLAY_PAUSE}", "_Play") local $time=0 While $time=0 Sleep(500) $time=1 WEnd Func _Play() if $time=0 Then sleep (50) SendKeepActive("[Class:Winamp v1.x]") Send("{ENTER}") EndIf $time=1 exit EndFunc ;==>_Function Edited October 18, 2011 by IanN1990 Link to comment Share on other sites More sharing options...
IanN1990 Posted October 18, 2011 Author Share Posted October 18, 2011 (edited) By Default Media is 0 and the script does nothing. If you press "stop" on the control, Media becomes 1 and the script bcomes active. Effectly turning the stop button into a profile switcher "This can work on manly levels but i was happy with 2 profiles on/off" Once on, if you was to press "Play/Pause", it sends Play/pause again "nullifying the effect" and sends "Space" to KMPlayer "which is the play/pause for that application" it then runs Pause.exe. The Pause exe lasts for 500 and works on the Hotkey. If it detects you press Pause again within the 500 it will then fullscreen the application. Basicly gives Play/plause and fullscreen within 1 button depending on how fast you click it. The code is just a copy/paste but with different numbers/names for the effects tending on skip 30/next track, last 30/prev track etc **I did it this way cuz all my other attempts ended in infi loops Hope this was helpful but i have a feeling the code is so basic and unproffesional no one will find it useful apart from a example of how NOT to code ^^ Edited October 18, 2011 by IanN1990 Link to comment Share on other sites More sharing options...
guinness Posted October 18, 2011 Share Posted October 18, 2011 Well it looks as though you've made a lot of progress since yesterday morning (smiley is now a little more positive) UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
IanN1990 Posted October 18, 2011 Author Share Posted October 18, 2011 (edited) Yea the script mostly works and makes the controller 10x more useful now. I am really pleased with how it worked out and that i found autoit as its insanely useful Edited October 18, 2011 by IanN1990 Link to comment Share on other sites More sharing options...
IanN1990 Posted October 20, 2011 Author Share Posted October 20, 2011 (edited) Code Improvement for better CPU performance and overall functionalaility Improved CPU Usage by 24% Improved Effectiveness by 100% "before it was hit and miss" Improved timing controls "no more using extra exes for timmers" No more double sending keys "before it detects a key has been pressed and cancels it before its sent. Now it catches it and changes it" All normal buttons work apart from stop which is now a profile switcher. 0 = Windows media player, 1 = Kmplayer Play = Play/Pause Play again within 250 seconds = fullscreen Next = Skip 30 seconds Next again within 250 seconds = next esp Prev = Prev 30 seconds Prev again within 250 seconds = prev esp expandcollapse popup#NoTrayIcon HotKeySet("{MEDIA_PlAY_PAUSE}", "_Play") HotKeySet("{MEDIA_NEXT}", "_Next") HotKeySet("{MEDIA_PREV}", "_Prev") HotKeySet("{MEDIA_STOP}", "_Stop") HotKeySet("{VOLUME_MUTE}", "_Mute") local $MediaPlayer=0 Func _Play() ; if $MediaPlayer = 1 then HotKeySet("{MEDIA_PlAY_PAUSE}") ; Disable HotKeySet. SendKeepActive("[Class:Winamp v1.x]") Send("{SPACE}") HotKeySet("{MEDIA_PlAY_PAUSE}", "_Fullscreen") ; Enable HotKeySet. sleep(1000) HotKeySet("{MEDIA_PlAY_PAUSE}", "_Play") ; Enable HotKeySet. Else HotKeySet("{MEDIA_PlAY_PAUSE}") ; Disable HotKeySet. Send("{MEDIA_PlAY_PAUSE}") HotKeySet("{MEDIA_PlAY_PAUSE}", "_Play") ; Enable HotKeySet. EndIf EndFunc Func _Fullscreen() ; if $MediaPlayer = 1 then SendKeepActive("[Class:Winamp v1.x]") Send("{SPACE}") Send("{ENTER}") HotKeySet("{MEDIA_PlAY_PAUSE}", "_Play") ; Enable HotKeySet. EndIf EndFunc Func _Next() ; if $MediaPlayer = 1 then HotKeySet("{MEDIA_NEXT}") ; Disable HotKeySet. SendKeepActive("[Class:Winamp v1.x]") Send("^{RIGHT}") HotKeySet("{MEDIA_NEXT}", "_NextTrack") ; Disable HotKeySet. sleep(250) HotKeySet("{MEDIA_NEXT}", "_Next") ; EnableHotKeySet. Else HotKeySet("{MEDIA_NEXT}") ; Enable HotKeySet. send("{MEDIA_NEXT}") HotKeySet("{MEDIA_NEXT}", "_Next") ; EnableHotKeySet. EndIf EndFunc Func _NextTrack() ; if $MediaPlayer = 1 then SendKeepActive("[Class:Winamp v1.x]") Send("{PGDN}") HotKeySet("{MEDIA_NEXT}", "_Next") ; Disable HotKeySet. EndIf EndFunc Func _Prev() ; if $MediaPlayer = 1 then HotKeySet("{MEDIA_PREV}") ; Disable HotKeySet. SendKeepActive("[Class:Winamp v1.x]") Send("^{LEFT}") HotKeySet("{MEDIA_PREV}", "_PrevTrack") ; Disable HotKeySet. Sleep(250) HotKeySet("{MEDIA_PREV}", "_Prev") ; Disable HotKeySet. Else HotKeySet("{MEDIA_PREV}") ; Enable HotKeySet. send("{MEDIA_PREV}") HotKeySet("{MEDIA_PREV}", "_Next") ; EnableHotKeySet. EndIf EndFunc Func _PrevTrack() ; if $MediaPlayer = 1 then SendKeepActive("[Class:Winamp v1.x]") Send("{PGUP}") HotKeySet("{MEDIA_PREV}", "_Prev") ; Disable HotKeySet. EndIf EndFunc Func _Stop() ; if $MediaPlayer=1 Then $MediaPlayer = 0 Else $MediaPlayer = 1 EndIf EndFunc Edited October 20, 2011 by IanN1990 Link to comment Share on other sites More sharing options...
AndreyS Posted November 25, 2012 Share Posted November 25, 2012 Do not want to create a new topic, because I think my question is on the topic. But if you need that will create a new topic. Also trying to understand what the code corresponds to the keys on my wireless headset (next track, previous, volume up and volume down). But there is no response from 0 to 254. Maybe there is someone any ideas how to find the code for those keys? And can it be that the headset works around user32.dll? I would be grateful for any ideas and help! Link to comment Share on other sites More sharing options...
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