coderusa Posted August 2, 2023 Posted August 2, 2023 (edited) Hey guys, my current AutoIT project is giving me some issues. I'm using v3.3.8.1 (Specifically this version because there was a change in TCPSend/Recv, or something, in a AutoIT update and the script doesn't work properly in newer versions of AutoIt. Spent days trying to figure it out, gave up and reverted back to known working version). NOT MY ISSUE. My issue lies in a couple things. First off, ToolTip() if I assign a tooltip for something, the moment I run the script, the ToolTip pops up regardless of mouse position and stays on the screen until I close out the script. I know to get the ToolTip off the screen I have to call ToolTip() again, but I only want the ToolTip to display when the mouse is over a certain GUI control. I was thinking about assigning the X/Y value for ToolTip() by using GUIGetMsg(1) to get a $GUI_EVENT_MOUSEMOVE, using the advanced options in GUIGetMsg(1) the $array[4] and $array[5] which are supposed to carry the mouse position X, Y, but they do not return anything no matter what I try to do (Constantly getting array dimension exceeded, or variable not array type errors) . All I want to achieve here is when the mouse moves over a GUI button, a tooltip will popup. I've searched google and the help file, I am getting the understanding of what I need to do, but not sure why I cant retrieve the mouse position INSIDE the GUI. If I use MouseGetPos() I can get the mouse position wherever it is on the screen, but I only need mouse position while inside the GUI. EDIT: In fact I dont even get a $GUI_EVENT_MOUSEMOVE from GUIGetMsg (1) when the mouse is moved inside the GUI... Second issue, using IE embedded elements. I've noticed when I put text into the IE element, the lowermost bottom portion of the text is cut off, the area where letters like p, q, g, y it cuts the bottom part of the text off if I go over a certain text size. Not sure what I can do about this. Last thing is, coloring text on GUICtrlCreateGroup() and GUICtrlCreateCheckbox(), none of the GUI set color functions seem work for changing text color on these two controls. Everything else the text color seems to be working fine for me. (One way around this is I create the group or checkbox without text and use GUICtrlCreateLabel() to put a colored, matching label over the controls, works aesthetically, but in the case of checkboxes, you arent able to click the label text to make the checkbox checked/unchecked.... Am I missing something or do these two controls just not like being painted? Here is the current code I have for this GUI. I'm not going to post all 8000 or so lines, but this snippet here works the same outisde the script and shows my issues. I'm using ConsoleWrite() to display the mouse poisition in the SciTe debug window. expandcollapse popup#Include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Global $oIE = " " Global $_RPGui = " " $sHTML = "<HTML>" & @CR $sHTML &= "<HEAD>" & @CR $sHTML &= '<style type="text/css"><!-- body { margin: 4px; line-height: 16px;} --></style>' $sHTML &= "</HEAD>" & @CR $sHTML &= "<BODY bgcolor=""#050565"">" & @CR $sHTML &= "</BODY>" $sHTML &= "</HTML>" _RPGui() ;Keep GUIs open, keep IRC connection open While 1 ;----=====> $_RPGui - Main GUI If $_RPGui Then $GUIGetMsg = GUIGetMsg(1) Switch $GUIGetMsg[0] Case 0 ContinueLoop Case $GUI_EVENT_CLOSE ;Need to add more here Exit EndSwitch EndIf WEnd ;Main GUI Func _RPGui() ;Prepare IE elements $oIE = _IECreateEmbedded() $oIE2 = _IECreateEmbedded() ;GUI $_RPGui = GUICreate("RPG", 1495, 975, 5, 5, $WS_CAPTION+$WS_POPUP+$WS_MAXIMIZEBOX+$WS_EX_APPWINDOW) GUISetFont("12", "680", "", "Courier", $_RPGui) GUISetBkColor(0x050565) ;Royal Blue ;GUICtrlSetDefColor(0xAABBFF) ; RPG Text ;----=====> FileMenu $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Exit", $filemenu) ;----=====> ToolBar $TB1 = GUICtrlCreateButton("", 1, 1, 40, 40, $BS_DEFPUSHBUTTON+$BS_ICON) GUICtrlSetImage($TB1, "Comp1.ico") GUICtrlSetResizing($TB1, $GUI_DOCKALL) ;Tool Tip for $TB1 ToolTip("Info here", 40, 40, "ToolTip", 1) $TB2 = GUICtrlCreateButton("", 42, 1, 40, 40, $BS_DEFPUSHBUTTON+$BS_ICON) GUICtrlSetImage($TB2, "Globe.ico") GUICtrlSetResizing($TB2, $GUI_DOCKALL) $TB3 = GUICtrlCreateButton("", 84, 1, 40, 40, $BS_DEFPUSHBUTTON+$BS_ICON) GUICtrlSetImage($TB3, "Book2.ico") GUICtrlSetResizing($TB3, $GUI_DOCKALL) ;----=====> Status Bar GUICtrlCreateGroup("", 1, 38, 1490, 40) $Label1 = GUICtrlCreateLabel("<----------------------------------------------Status info here-------------------------------------------->", 5, 48, 1400, 15) GUICtrlSetColor($Label1, "0xAABBFF") ;----=====> Main Input Box And ">" Button $InputBox = GUICtrlCreateInput("Main text input/command line", 10, 925, 1150, 21) GUICtrlSetResizing($InputBox, $GUI_DOCKAUTO) $InputButton = GUICtrlCreateButton(">", 1165, 922, 90, 26) GUICtrlSetResizing($InputButton, $GUI_DOCKAUTO) ;----=====> Channel Users List & Buttons GUICtrlCreateGroup("Channel Users List", 1260, 605, 230, 185) $UserBox = GUICtrlCreateList("Offline", 1265, 625, 220, 125) ;----=====> Friends List & Buttons GUICtrlCreateGroup("Friends", 1260, 780, 230, 170) $FriendBox = GUICtrlCreateList("Offline", 1265, 800, 220, 110) ;----=====> Text/Image Display $_RPGie1 = GUICtrlCreateObj($oIE, 5, 610, 1250, 305) GUICtrlSetResizing($_RPGie1, $GUI_DOCKAUTO) _IENavigate($oIE, "about:blank") _IEDocWriteHTML($oIE, $sHTML) _IEHeadInsertEventScript($oIE, "document", "oncontextmenu", "return false") _IEBodyWriteHTML($oIE, "<br><br><font face=""Lucida Console"" color=""#AABBFF"" size=""6"">_IE_Object: $_RPGie1 - HTML Text/Image display.</font>") ;----=====> Visual Display $_RPGie2 = GUICtrlCreateObj($oIE2, 265, 90, 990, 510) GUICtrlSetResizing($_RPGie2, $GUI_DOCKAUTO) _IENavigate($oIE2, "about:blank") _IEDocWriteHTML($oIE2, $sHTML) _IEHeadInsertEventScript($oIE2, "document", "oncontextmenu", "return false") _IEBodyWriteHTML($oIE2, "<br><br><font face=""Lucida Console"" color=""#AABBFF"" size=""6"">_IE_Object: $_RPGie2 - HTML visual display.</font>") Sleep(800) GUISetState() EndFunc Edited August 2, 2023 by coderusa
Andreik Posted August 2, 2023 Posted August 2, 2023 To deal with your first issue, just use GUICtrlSetTip(). This will allow you to set the tooltip for each control individually. Second issue has nothing to do with AutoIt, it's in your CSS. $sHTML &= '<style type="text/css"><!-- body { margin: 4px; line-height: 16px;} --></style>' Basically you set the line-height at 16px but obviously it's not enough to display the text at your size. Your third issue has been addressed many times on this forum and you just need to remove the default theme from your control. You have an example here.
coderusa Posted August 2, 2023 Author Posted August 2, 2023 (edited) Quote To deal with your first issue, just use GUICtrlSetTip(). This will allow you to set the tooltip for each control individually. Second issue has nothing to do with AutoIt, it's in your CSS. Basically you set the line-height at 16px but obviously it's not enough to display the text at your size. Your third issue has been addressed many times on this forum and you just need to remove the default theme from your control. You have an example here. Thank for explaining that bit about the CSS, I've been researching but I didn't fully understand that part, but now I do. Ive used AutoIT a bit but this is honestly my first in depth leap into AutoIT GUI stuff. Coding most of the functionality was the easy part, I'm finding that applying the functionality into the GUI and having it work and look good is the tricky part but I'm picking it up as I go. 😉 As for the 3rd Issue, I had tried that example before and, as I recall, it didn't make a change, but I will re-read the example and try again.... ...And after reviewing that I think I've got that part taken care of now.... So that's fixed, Thank you Andreik That's two checks off the list. Here is the updated snippet expandcollapse popup#Include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Global $oIE = " " Global $_RPGui = " " $sHTML = "<HTML>" & @CR $sHTML &= "<HEAD>" & @CR $sHTML &= '<style type="text/css"><!-- body { margin: 8px; line-height: 24px;} --></style>' $sHTML &= "</HEAD>" & @CR $sHTML &= "<BODY bgcolor=""#050565"">" & @CR $sHTML &= "</BODY>" $sHTML &= "</HTML>" _RPGui() ;Keep GUIs open, keep IRC connection open While 1 ;----=====> $_RPGui - Main GUI If $_RPGui Then $GUIGetMsg = GUIGetMsg(1) Switch $GUIGetMsg[0] Case 0 ContinueLoop Case $GUI_EVENT_CLOSE ;Need to add more here Exit Case $GUI_EVENT_MOUSEMOVE ;Mouse position in GUI If $GUIGetMsg[0] >= 1 Then ConsoleWrite("MOUSE POS GUI - X: " & $GUIGetMsg[4] & " Y: " & $GUIGetMsg[5] & @CRLF) EndIf EndSwitch ;Mouse position on screen ;ConsoleWrite("MOUSE POS AutoIT - X: " & MouseGetPos(0) & " Y: " & MouseGetPos(1) & @CRLF) EndIf WEnd ;DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hCheckbox), "wstr", 0, "wstr", 0) ;Main GUI Func _RPGui() ;Prepare IE elements $oIE = _IECreateEmbedded() $oIE2 = _IECreateEmbedded() ;GUI $_RPGui = GUICreate("RPG", 1495, 975, 5, 5, $WS_CAPTION+$WS_POPUP+$WS_MAXIMIZEBOX+$WS_EX_APPWINDOW) GUISetFont("12", "680", "", "Courier", $_RPGui) GUISetBkColor(0x050565) ;Royal Blue ;----=====> FileMenu $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Exit", $filemenu) ;----=====> ToolBar $TB1 = GUICtrlCreateButton("", 1, 1, 40, 40, $BS_DEFPUSHBUTTON+$BS_ICON) GUICtrlSetImage($TB1, "Comp1.ico") GUICtrlSetResizing($TB1, $GUI_DOCKALL) GUICtrlSetTip($TB1, "Connect", "", 1) $TB2 = GUICtrlCreateButton("", 42, 1, 40, 40, $BS_DEFPUSHBUTTON+$BS_ICON) GUICtrlSetImage($TB2, "Globe.ico") GUICtrlSetResizing($TB2, $GUI_DOCKALL) GUICtrlSetTip($TB2, "Server Options", "", 1) $TB3 = GUICtrlCreateButton("", 84, 1, 40, 40, $BS_DEFPUSHBUTTON+$BS_ICON) GUICtrlSetImage($TB3, "Book2.ico") GUICtrlSetResizing($TB3, $GUI_DOCKALL) GUICtrlSetTip($TB3, "Profile", "", 1) ;----=====> Status Bar GUICtrlCreateGroup("", 1, 38, 1490, 40) $Label1 = GUICtrlCreateLabel("<----------------------------------------------Status info here-------------------------------------------->", 5, 52, 1400, 15) GUICtrlSetColor($Label1, "0xAABBFF") ;----=====> Main Input Box And ">" Button $InputBox = GUICtrlCreateInput("Main text input/command line", 10, 925, 1150, 21) GUICtrlSetResizing($InputBox, $GUI_DOCKAUTO) $InputButton = GUICtrlCreateButton(">", 1165, 922, 90, 26) GUICtrlSetResizing($InputButton, $GUI_DOCKAUTO) ;----=====> Channel Users List & Buttons $Group1 = GUICtrlCreateGroup("Channel Users List", 1260, 605, 230, 185) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group1), "wstr", 0, "wstr", 0) GUICtrlSetColor($Group1, 0xAABBFF) $UserBox = GUICtrlCreateList("Offline", 1265, 625, 220, 125) ;----=====> Friends List & Buttons $Group2 = GUICtrlCreateGroup("Friends", 1260, 780, 230, 170) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group2), "wstr", 0, "wstr", 0) GUICtrlSetColor($Group2, 0xAABBFF) $FriendBox = GUICtrlCreateList("Offline", 1265, 800, 220, 110) ;----=====> Text/Image Display $_RPGie1 = GUICtrlCreateObj($oIE, 5, 610, 1250, 305) GUICtrlSetResizing($_RPGie1, $GUI_DOCKAUTO) _IENavigate($oIE, "about:blank") _IEDocWriteHTML($oIE, $sHTML) _IEHeadInsertEventScript($oIE, "document", "oncontextmenu", "return false") _IEBodyWriteHTML($oIE, "<br><br><font face=""Lucida Console"" color=""#AABBFF"" size=""6"">_IE_Object: $_RPGie1 - HTML Text/Image display.</font>") ;----=====> Visual Display $_RPGie2 = GUICtrlCreateObj($oIE2, 265, 90, 990, 510) GUICtrlSetResizing($_RPGie2, $GUI_DOCKAUTO) _IENavigate($oIE2, "about:blank") _IEDocWriteHTML($oIE2, $sHTML) _IEHeadInsertEventScript($oIE2, "document", "oncontextmenu", "return false") _IEBodyWriteHTML($oIE2, "<br><br><font face=""Lucida Console"" color=""#AABBFF"" size=""6"">_IE_Object: $_RPGie2 - HTML visual display.</font>") Sleep(800) GUISetState() EndFunc Edited August 2, 2023 by coderusa
Andreik Posted August 2, 2023 Posted August 2, 2023 Seems you managed to use tooltips for buttons, to change the CSS and to change the color of groups. Is there anything else not working as you expect? I will just add that probably it's a good idea to style elements with CSS with classes. From what I see it's some sort of chat GUI so you might not want always to have a line height of 24 px but just for some elements. This is why I think that setting line height in body it's way too general and it's better to use classes for your html elements so you can style them accordingly.
coderusa Posted August 2, 2023 Author Posted August 2, 2023 Quote Seems you managed to use tooltips for buttons, to change the CSS and to change the color of groups. Is there anything else not working as you expect? I will just add that probably it's a good idea to style elements with CSS with classes. From what I see it's some sort of chat GUI so you might not want always to have a line height of 24 px but just for some elements. This is why I think that setting line height in body it's way too general and it's better to use classes for your html elements so you can style them accordingly. Those are the only issues that have had me scratching my head. The rest is just stuff that needs to be tweaked or finished into the GUI. Tho, Its going to be more than just a chat script, the end goal is a online role playing game that uses IRC protocol for users to connect a server, chat and play. Game interaction will use a numeric data system I've designed that sends numeric type CTCP data (almost like raw data) between users and/or an automated chat bot. Still a long way from finished but the base core script does work pretty well.
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