Diabolos Posted August 22, 2018 Share Posted August 22, 2018 Hi all, I'm working on a custom RSS app to sort of freshen up my AutoIT knowledge. Most of it is going well and I have a much better understanding of coding concepts since I've been working with C#; However, I've hit a slight wall with creating a hover effect on mouseover of a label in the top menu area. Maybe there's something about my for loop that I'm not understanding? Not sure how to resolve it but if someone has a hint about what the issue might be, I'd be forever grateful! So here's the function I created from someone's example on the forum. It works by itself in the program while loop just not with a for loop. I pass the array $button which contains the three label names. Then $fOver is an array initialized as [False, False, False] to correspond to all three buttons. I've checked with some ConsoleWrites the correct IDs are passing in Func setHover($button) $aCInfo = GUIGetCursorInfo($Form1) For $i = 0 To $i = 2 Step +1 If $aCInfo[4] = $button[$i] Then If $fOver[$i] = False Then GUICtrlSetColor($button[$i], 0xA6A6A6) $fOver[$i] = True EndIf Else If $fOver[$i] = True Then GUICtrlSetColor($button[$i], $FontThemeColor) $fOver[$i] = False EndIf EndIf Next EndFunc I achieved some success with all three as nested if statements but would like to try and condense in the event of expansion on the menu bar. expandcollapse popupFunc setHover($button) $aCInfo = GUIGetCursorInfo($Form1) If $aCInfo[4] = $button[0] Then If $fOver[0] = False Then GUICtrlSetColor($button[0], 0xA6A6A6) $fOver[0] = True EndIf Else If $fOver[0] = True Then GUICtrlSetColor($button[0], $FontThemeColor) $fOver[0] = False EndIf EndIf If $aCInfo[4] = $button[1] Then If $fOver[1] = False Then GUICtrlSetColor($button[1], 0xA6A6A6) $fOver[1] = True EndIf Else If $fOver[1] = True Then GUICtrlSetColor($button[1], $FontThemeColor) $fOver[1] = False EndIf EndIf If $aCInfo[4] = $button[2] Then If $fOver[2] = False Then GUICtrlSetColor($button[2], 0xA6A6A6) $fOver[2] = True EndIf Else If $fOver[2] = True Then GUICtrlSetColor($button[2], $FontThemeColor) $fOver[2] = False EndIf EndIf EndFunc Thanks for taking the time to read my post! Link to comment Share on other sites More sharing options...
careca Posted August 22, 2018 Share Posted August 22, 2018 Not many people will spend time on this when they have to re-create code and guess variables, just to make it run. Post a reproducible script to get answers, if any at all. 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 Link to comment Share on other sites More sharing options...
Diabolos Posted August 22, 2018 Author Share Posted August 22, 2018 (edited) Sorry, didn't see the reply immediately! I ended up finding the solution though if anyone would like the code! My apologies @careca, I should have given more context to the problem. Thank you for taking the time to respond anyway! #EDIT to everything beneath here. Fixed code causing GUI flicker. Just pass this function from your program While loop! No flickering on any of the interface. There was flickering that was caused by the original function setting the last hovered items color over and over and over. setHover(GUIGetCursorInfo($Form1)) The solution ended up being ridiculously simple. *Facepalm* #Region ================== Global GUI Vars =========================== Global $buttonhovers[3] = [$updateRSS,$addRSS,$deleteRSS] Global $lasthover = -1 #EndRegion =============== Global GUI Vars =========================== Func setHover($formCursor) If($formcursor[4] <> $lasthover) Then If(buttonSelect($lasthover) = True) Then GUICtrlSetColor($lasthover, $FontThemeColor) EndIf If(buttonSelect($formcursor[4]) = True) Then GUICtrlSetColor($formcursor[4], 0xA6A6A6) EndIf $lasthover = $formcursor[4] EndIf EndFunc Func buttonSelect($hovered) For $element in $buttonhovers If($hovered = $element) Then Return True Next Return False EndFunc Edited August 23, 2018 by Diabolos Link to comment Share on other sites More sharing options...
careca Posted August 22, 2018 Share Posted August 22, 2018 You could place this in the while loop, and then whenever the cursor id = the label, change color, else, normal color. Anyway, i figure if you're happy with it, nice. Diabolos 1 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 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