Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Problems with my script..


  • Please log in to reply
2 replies to this topic

#1 VixinG

VixinG

    Adventurer

  • Active Members
  • PipPip
  • 107 posts

Posted 11 May 2012 - 01:20 AM

Hi, I started re-writing my script, and now I am in place, where everything works individually, but together it isn't.
There are no errors, and I can't find solutions (as always). I lost 2 hours and I don't know what to do now.

The application is simple, but I am overwhelmed by it.

Here is the old script, which is working as intended, but It looks like written by 6 years old...
AutoIt         
#NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "Icons.au3" #include "WinSnap.au3" ;-------------------hotkeys----------------------------------------- $k_all = IniRead("keys.ini", "HOTKEYS", "All_Omniwave", '"{F1}"') $k_game = IniRead("keys.ini", "HOTKEYS", "Game_Rainwave", '"{F2}"') $k_chiptune = IniRead("keys.ini", "HOTKEYS", "Chiptune_Bitwave", '"{F3}"') $k_covers = IniRead("keys.ini", "HOTKEYS", "Covers_Mixwave", '"{F4}"') $k_ocremix = IniRead("keys.ini", "HOTKEYS", "OCRemix", '"{F5}"') $k_top = IniRead("keys.ini", "HOTKEYS", "TopMost", '"{F6}"') HotKeySet($k_top, "TopMost") HotKeySet($k_all, "Station_omniwave") HotKeySet($k_game, "Station_rainwave") HotKeySet($k_chiptune, "Station_bitwave") HotKeySet($k_covers, "Station_mixwave") HotKeySet($k_ocremix, "Station_ocr_radio") ;-------------------------------------------------------------------- ;  Rainwave Station Switcher ;-------------------------------------------------------------------- $GUI = GUICreate("RSSwitcher", 480, 25, 0, 0, $WS_POPUP + $WS_VISIBLE) Global $topmost = True $rainwave = GUICtrlCreatePic('', 1, 1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) $all = GUICtrlCreatePic('', 110, 1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) $game = GUICtrlCreatePic('', 154, 1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) $chiptune = GUICtrlCreatePic('', 214, 1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) $covers = GUICtrlCreatePic('', 310, 1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) $ocremix = GUICtrlCreatePic('', 390, 1, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel('',309,1,81,23) GUICtrlCreateLabel('',390,1,89,23) Dim $m3us[5] = (".\resources\omniwave.m3u", ".\resources\rainwave.m3u", ".\resources\bitwave.m3u", ".\resources\mixwave.m3u",".\resources\ocr_radio.m3u") $rainwave_png = ".\resources\rainwave.png" $all_png = ".\resources\all.png" $game_png = ".\resources\game.png" $chiptune_png = ".\resources\chiptune.png" $covers_png = ".\resources\covers.png" $ocremix_png = ".\resources\ocremix.png" $all_png2 = ".\resources\all2.png" $game_png2 = ".\resources\game2.png" $chiptune_png2 = ".\resources\chiptune2.png" $covers_png2 = ".\resources\covers2.png" $ocremix_png2 = ".\resources\ocremix2.png" _SetImage($rainwave, $rainwave_png) _SetImage($all, $all_png) _SetImage($game, $game_png) _SetImage($chiptune, $chiptune_png) _SetImage($covers, $covers_png) _SetImage($ocremix, $ocremix_png) $hLabel = GUICtrlCreateLabel('', 0, 0, 110, 23, -1, $GUI_WS_EX_PARENTDRAG) $all_label = GUICtrlCreateLabel('', 110, 1, 44, 23) $game_label = GUICtrlCreateLabel('', 154, 1, 60, 23) $chiptune_label = GUICtrlCreateLabel('', 214, 1, 96, 23) $covers_label = GUICtrlCreateLabel('', 309, 1, 81, 23) $ocremix_label = GUICtrlCreateLabel('', 390, 1, 89, 23) GUICtrlSetBkColor($hLabel, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($all_label, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($game_label, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($chiptune_label, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($covers_label, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($ocremix_label, $GUI_BKCOLOR_TRANSPARENT) WinSetOnTop($GUI, "", 1) GUISetState(@SW_SHOW) $all_UnderCursor = False $game_UnderCursor = False $chiptune_UnderCursor = False $covers_UnderCursor = False $ocremix_UnderCursor = False _WinSnap_Set($GUI) While 1 $msg = GUIGetMsg() $cursor = GUIGetCursorInfo($GUI) If Not @error Then   Select    Case $msg = $GUI_EVENT_CLOSE     ExitLoop    Case $cursor[4] = $all_label And $all_UnderCursor = False     _SetImage($all, $all_png2)     $all_UnderCursor = True    Case $cursor[4] = $game_label And $game_UnderCursor = False     _SetImage($game, $game_png2)     $game_UnderCursor = True    Case $cursor[4] = $chiptune_label And $chiptune_UnderCursor = False     _SetImage($chiptune, $chiptune_png2)     $chiptune_UnderCursor = True    Case $cursor[4] = $covers_label And $covers_UnderCursor = False     _SetImage($covers, $covers_png2)     $covers_UnderCursor = True    Case $cursor[4] = $ocremix_label And $ocremix_UnderCursor = False     _SetImage($ocremix, $ocremix_png2)     $ocremix_UnderCursor = True    Case $cursor[4] <> $all_label And $all_UnderCursor     _SetImage($all, $all_png)     $all_UnderCursor = False    Case $cursor[4] <> $game_label And $game_UnderCursor     _SetImage($game, $game_png)     $game_UnderCursor = False    Case $cursor[4] <> $chiptune_label And $chiptune_UnderCursor     _SetImage($chiptune, $chiptune_png)     $chiptune_UnderCursor = False    Case $cursor[4] <> $covers_label And $covers_UnderCursor     _SetImage($covers, $covers_png)     $covers_UnderCursor = False    Case $cursor[4] <> $ocremix_label And $ocremix_UnderCursor     _SetImage($ocremix, $ocremix_png)     $ocremix_UnderCursor = False    Case $msg = $all_label     ShellExecute(".\resources\omniwave.m3u")    Case $msg = $game_label     ShellExecute(".\resources\rainwave.m3u")    Case $msg = $chiptune_label     ShellExecute(".\resources\bitwave.m3u")    Case $msg = $covers_label     ShellExecute(".\resources\mixwave.m3u")    Case $msg = $ocremix_label     ShellExecute(".\resources\ocr_radio.m3u")   EndSelect EndIf WEnd Exit Func Station_omniwave() ShellExecute(".\resources\omniwave.m3u") EndFunc   ;==>Station_omniwave Func Station_rainwave() ShellExecute(".\resources\rainwave.m3u") EndFunc   ;==>Station_rainwave Func Station_bitwave() ShellExecute(".\resources\bitwave.m3u") EndFunc   ;==>Station_bitwave Func Station_mixwave() ShellExecute(".\resources\mixwave.m3u") EndFunc   ;==>Station_mixwave Func Station_ocr_radio() ShellExecute(".\resources\ocr_radio.m3u") EndFunc   ;==>Station_ocr_radio Func TopMost() If $topmost = True Then   WinSetOnTop($GUI, "", 0)   $topmost = False Else   WinSetOnTop($GUI, "", 1)   $topmost = True EndIf EndFunc   ;==>TopMost


So I wanted to rewrite it, using more advanced functions and adding few more features:
AutoIt         
;#NoTrayIcon ;------------------------------------------------------------; ;  Rainwave Station Changer ;------------------------------------------------------------; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <IE.au3> #include 'Icons.au3' #include 'WinSnap.au3' Opt('GuiOnEventMode',1) GUISetOnEvent($GUI_EVENT_CLOSE,"Quit") ;------------------------------------------------------------; ; Hotkeys ;------------------------------------------------------------; $hotkey1 = IniRead('keys.ini', 'Hotkeys', 'Omniwave', '{F1}') $hotkey2 = IniRead('keys.ini', 'Hotkeys', 'Rainwave', '{F2}') $hotkey3 = IniRead('keys.ini', 'Hotkeys', 'Chiptune', '{F3}') $hotkey4 = IniRead('keys.ini', 'Hotkeys',  'Covers', '{F4}') $hotkey5 = IniRead('keys.ini', 'Hotkeys', 'OCRradio', '{F5}') $topmost = IniRead('keys.ini', 'Hotkeys', 'SetOnTop', '{F6}') HotKeySet($hotkey1, "omniwave") HotKeySet($hotkey2, "rainwave") HotKeySet($hotkey3, "bitwave") HotKeySet($hotkey4, "mixwave") HotKeySet($hotkey5, "ocr_radio") HotKeySet($topmost, "TopMost") HotKeySet("{ESC}", "Quit") ;------------------------------------------------------------; ; Variables ;------------------------------------------------------------; Global $SetOnTop = True $GUI = GUICreate('Rainwave Player', 580, 25, 0, 0, $WS_POPUP + $WS_VISIBLE) $oIE = _IECreateEmbedded() Dim $png1[5] = ['.\art\aa.png','.\art\bb.png','.\art\cc.png','.\art\dd.png','.\art\ee.png'] Dim $png2[5] = ['.\art\aa2.png','.\art\bb2.png','.\art\cc2.png','.\art\dd2.png','.\art\ee2.png'] Dim $labels[5] = [GUICtrlCreateLabel('', 110, 1, 44, 23),GUICtrlCreateLabel('', 154, 1, 60, 23),GUICtrlCreateLabel('', 214, 1, 96, 23),GUICtrlCreateLabel('', 309, 1, 81, 23),GUICtrlCreateLabel('', 390, 1, 89, 23)] Global $dragLabel = GUICtrlCreateLabel('', 0, 0, 110, 23, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) Dim $pics[5] = [GUICtrlCreatePic('', 110, 1, 0, 0),GUICtrlCreatePic('', 154, 1, 0, 0),GUICtrlCreatePic('', 214, 1, 0, 0),GUICtrlCreatePic('', 310, 1, 0, 0),GUICtrlCreatePic('', 390, 1, 0, 0)] Dim $urls[5] = ['http://www.rainwave.tk/player/omniwave.php','http://www.rainwave.tk/player/rainwave.php','http://www.rainwave.tk/player/bitwave.php','http://www.rainwave.tk/player/mixwave.php','http://www.rainwave.tk/player/ocremix.php'] Local $disable For $i = 0 to 4 Step 1 GUICtrlSetBkColor($labels[$i],$GUI_BKCOLOR_TRANSPARENT) Next For $i = 0 to 4 Step 1 _SetImage($pics[$i], $png1[$i]) GUICtrlSetState($pics[$i], $GUI_DISABLE) Next Global $00png = '.\art\00.png' Global $00obj = GUICtrlCreatePic('', 1, 1, 0, 0) _SetImage($00obj,$00png) GUICtrlSetState(-1,$GUI_DISABLE) GUISetBkColor(0x808080,$GUI) _WinSnap_Set($GUI) WinSetOnTop($GUI, "", 1) $aahover = False $bbhover = False $cchover = False $ddhover = False $eehover = False ;------------------------------------------------------------; ; Script ;------------------------------------------------------------; Sleep(1000) Local $lastCursor GUICtrlCreateObj($oIE,480,-14,150,50) _IENavigate($oIE,'http://rainwave.tk/player/omniwave.php') GUISetState() While 1 $msg = GUIGetMsg() $cursor = GUIGetCursorInfo($GUI)   If $msg = $GUI_EVENT_CLOSE Then    ExitLoop   EndIf   Select    Case $cursor[4] = $labels[0] And $aahover = False     _SetImage($pics[0], $png1[0])     $aahover = True    Case $cursor[4] = $labels[1] And $bbhover = False     _SetImage($pics[1], $png1[1])     $bbhover = True    Case $cursor[4] = $labels[2] And $cchover = False     _SetImage($pics[2], $png1[2])     $cchover = True    Case $cursor[4] = $labels[3] And $ddhover = False     _SetImage($pics[3], $png1[3])     $ddhover = True    Case $cursor[4] = $labels[4] And $eehover = False     _SetImage($pics[4], $png1[4])     $eehover = True    Case $cursor[4] <> $labels[0] And $aahover     _SetImage($pics[0], $png2[0])     $aahover = False    Case $cursor[4] <> $labels[1] And $bbhover     _SetImage($pics[1], $png2[1])     $bbhover = False    Case $cursor[4] <> $labels[2] And $cchover     _SetImage($pics[2], $png2[2])     $cchover = False    Case $cursor[4] <> $labels[3] And $ddhover     _SetImage($pics[3], $png2[3])     $ddhover = False    Case $cursor[4] <> $labels[4] And $eehover     _SetImage($pics[4], $png2[4])     $eehover = False    Case $msg = $labels[0]    _IENavigate($oIE,$urls[0])   EndSelect WEnd Exit ;------------------------------------------------------------; ; Functions ;------------------------------------------------------------; Func TopMost() If $SetOnTop = True Then WinSetOnTop($GUI, "", 0) $SetOnTop = False Else WinSetOnTop($GUI,"",1) $SetOnTop = True EndIf EndFunc Func omniwave() _IENavigate($oIE,$urls[0]) EndFunc Func rainwave() _IENavigate($oIE,$urls[1]) EndFunc Func bitwave() _IENavigate($oIE,$urls[2]) EndFunc Func mixwave() _IENavigate($oIE,$urls[3]) EndFunc Func ocr_radio() _IENavigate($oIE,$urls[4]) EndFunc Func Quit() Exit EndFunc


The first script works, but these things does not work in 2nd script:
- png pictures aren't changing on mouse over...
- clicking on transparent labels on pictures does not work..
I checked, and these controls are disabled, so labels should be clickable.
Mouse-over png changing does not work, and I don't know why. I examined every part of the code and I'm stuck.
Pretty please for help :3

Attached Files


Posted Image








#2 Spiff59

Spiff59

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,341 posts

Posted 11 May 2012 - 02:02 AM

You've enabled GUIOnEventMode in the second script.
In that mode calls to GUIGetMsg() will not register events.
You use one or the other.
Either GUIOnEventMode with assigned functions to handle specific events, or you leave that option off and poll the message queue for events using GUIGetMsg().

#3 VixinG

VixinG

    Adventurer

  • Active Members
  • PipPip
  • 107 posts

Posted 11 May 2012 - 02:26 AM

Thanks, I will try tomorrow. I'm off for today. If anyone has got any thoughts, please share ;) thanks again
/edit:
Okay, now I know what was wrong. Found few errors in the script.

Edited by VixinG, 11 May 2012 - 06:04 PM.

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users