Leaderboard
Popular Content
Showing content with the highest reputation on 05/15/2023 in all areas
-
GuiFlatButton UDF : Change Colors of Regular Buttons
mumpel reacted to kurtykurtyboy for a topic
GuiFlatButton is a UDF to easily create regular buttons with different colors for background, foreground, border, hover, focus, etc.. This started as an effort to change the background color of a button and eventually grew into a full UDF. If you've looked around forums for changing button background colors, you have probably noticed that each proposed workaround has its own set of issues/side-effects. The answers usually circle back to 'use ownerdrawn buttons' and 'not worth it'. Well, now it is possible for anyone to easily create ownerdrawn buttons - totally worth it! Some issues with other workarounds such as drawing with GDI+ or using a colored label as a 'button': Not 'real' buttons so you lose built-in functionality that windows gives to buttons Messy / inefficient code in the main while loop to check for mouse position Slow to respond to click, paint, etc... Having to deal with GUIRegisterMsg messages Not straight-forward to implement GuiFlatButton is not a workaround; it is a technique to respond to Windows' built-in owner-drawn button events. With minimal effort, we can now create true simple colored buttons. The idea is to create an owner-drawn button using GUICtrlCreateButton then subclass the GUI and controls to handle the button-specific events to paint it however we want. This UDF magically does all of this for us! No need to worry about event handling or main while loop logic. How to use It couldn't be any easier! Simply create a new button using the familiar syntax. This creates an ownerdrawn button with default colors. $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) If you want to change the background and text colors: GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) Advanced Usage Set background/text/border all at once GuiFlatButton_SetColors(-1, 0x0000FF, 0xFFFFFF, 0x9999FF) Set ALL colors for ALL button states! (normal, focus, hover, selected) Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetColorsEx(-1, $aColorsEx) Set default colors to apply to any future buttons ;set colors GuiFlatButton_SetDefaultColors(0x0000FF, 0xFFFFFF, 0x9999FF) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Set ALL color defaults ;set colors Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Available Functions Simple Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;GUI with one button Func Example() Local $hGUI, $mybutton1 $hGUI = GUICreate("GuiFlatButton Ex0", 275, 120) GUISetBkColor(0x333333) Local $idLabel = GUICtrlCreateLabel("Click the button", 10, 100, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) ;create new button then set the background and foreground colors $mybutton1 = GuiFlatButton_Create("Button 1" & @CRLF & "Line 2", 78, 20, 120, 40, $BS_MULTILINE) GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $mybutton1 $i += 1 GUICtrlSetData($idLabel, $i) ConsoleWrite($i & @CRLF) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Menu/Toolbar Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;Example GUI with toolbar Func Example() Local $hGUI, $idLabel, $aButtons, $iTbSize $hGUI = GUICreate("GuiFlatButton Ex2", 300, 200) GUISetBkColor(0x444444) $idLabel = GUICtrlCreateLabel("Click a button", 10, 180, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) $aButtons = createToolbar() $iTbSize = UBound($aButtons) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButtons[0] To $aButtons[$iTbSize - 1] ConsoleWrite("1") GUICtrlSetData($idLabel, GuiFlatButton_Read($iMsg)) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Func createToolbar() Local $aButtons[6] Local $bkColor = 0x777777 Local $textColor = 0xFFFFFF Local $borderColor = 0x999999 Local $aBtnClrs[12] = [0x777777, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x888888, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x999999, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x666666, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT] For $i = 0 To UBound($aButtons) - 1 $aButtons[$i] = GuiFlatButton_Create("B" & $i, $i * 50, 0, 50, 17) GuiFlatButton_SetColorsEx($aButtons[$i], $aBtnClrs) Next Return $aButtons EndFunc ;==>createToolbar Icon Example You can even easily add icons to your buttons -- just create a new button and send it an icon! #include <GDIPlus.au3> #include "GuiFlatButton.au3" Example() ;buttons with Icon images Func Example() ;get images for demonstration _GDIPlus_Startup() ;initialize GDI+ Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 258, 24, 24) ;extract the 'Save' icon Local $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) ;Create Bitmap from Icon (for demonstration) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap _GDIPlus_Shutdown() ;done with GDI+ Local $hGUI = GUICreate("GuiFlatButton Ex5", 255, 400) GUISetBkColor(0xEEEEEE) ;set default colors of future buttons Local $aColorsEx = _ [0xE2E5E8, 0X000000, 0x888888, _ ; normal : Background, Text, Border 0xE2E5E8, 0X000000, 0x333333, _ ; focus : Background, Text, Border 0xE8E8E8, 0X000000, 0x666666, _ ; hover : Background, Text, Border 0xDDDDDD, 0X000000, 0xAAAAAA] ; selected : Background, Text, Border GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;normal button with icon $label1 = GUICtrlCreateLabel( "$BS_TOOLBUTTON -->", 5, 10) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Local $mybutton1 = GuiFlatButton_Create("Save", 130, 5, 50, 48, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybutton1), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top Local $mybuttonT = GuiFlatButton_Create("Top", 5, 65, 120, 55, $BS_TOP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonT), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-left Local $mybuttonTL = GuiFlatButton_Create("Top-Left", 5, 125, 120, 55, BITOR($BS_TOP, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-right Local $mybuttonTR = GuiFlatButton_Create("Top-Right", 5, 185, 120, 55, BITOR($BS_TOP, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align left Local $mybuttonL = GuiFlatButton_Create("Left", 5, 245, 120, 55, $BS_LEFT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom Local $mybuttonB = GuiFlatButton_Create("Bottom", 130, 65, 120, 55, $BS_BOTTOM) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonB), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-left Local $mybuttonBL = GuiFlatButton_Create("Bottom-Left", 130, 125, 120, 55, BITOR($BS_BOTTOM, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-right Local $mybuttonBR = GuiFlatButton_Create("Bottom-Right", 130, 185, 120, 55, BITOR($BS_BOTTOM, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align right Local $mybuttonR = GuiFlatButton_Create("Right", 130, 245, 120, 55, $BS_RIGHT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) GuiFlatButton_SetState($mybuttonR, $GUI_DISABLE ) ;disabled Local $mybuttonDisable = GuiFlatButton_Create("Disabled", 130, 310, 120, 55, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonDisable), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GuiFlatButton_SetState($mybuttonDisable, $GUI_DISABLE ) ;clean up! _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DeleteObject( $hHBitmap ) GUISetState(@SW_SHOW, $hGUI) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example I'm sure there are some use-cases I've forgotten, so feedback is welcome! Download the latest UDF and several more examples: GuiFlatButton_20220919.zip (1,121) Update 2022-09-19 Added update from 05/25 back in after it was accidentally removed Update 2022-09-01 Added $BS_MULTILINE button style Added ellipses when text is longer than the button Fixed compatibility with Opt("MustDeclareVars", 1) Update 2022-05-25 Fixed issue, buttons disappear when a GUI containing a child window with WS_EX_MDICHILD extended style is moved Update 2022-05-24 Fixed issue releasing subclassing when GUI is deleted but program is not closed Fixed occasional white background flicker Added function GuiFlatButton_GetPos Update 2021-01-02 Fixed bug, not drawing correctly after deleting GUI with GUIDelete() Fixed bug, changing default colors changed all buttons, even previously created buttons Made some internal functions more efficient Update 2019-04-14 Fixed bug, not showing pressed down state when clicking rapidly Added Icon/Bitmap support! Added function GuiFlatButton_SetPos to change the position and/or size of a button Update 2019-02-09 Added 2 new functions to set the button colors globally for all future buttons. GuiFlatButton_SetDefaultColors GuiFlatButton_SetDefaultColorsEx Credits to: Melba23 (UDF template) LarsJ (general subclassing code) 4ggr35510n (TrackMouseEvent example) binhnx (disable dragging with $WS_EX_CONTROLPARENT) GUIRegisterMsg in AutoIt Help (owner-draw button example) funkey (_WinAPI_DrawState example)1 point -
ScreenColorPicker snap color from screen with the mouse pointer
kurtykurtyboy reacted to ioa747 for a topic
ScreenColorPicker snap color from screen with the mouse pointer to clipboard the idea comes from @Melba23's Magnify post. Thanks for that! ;https://www.autoitscript.com/forum/topic/209412-screencolorpicker-snap-color-from-screen-with-the-mouse-pointer/ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;ScreenColorPicker.au3 ;snap color from screen with the mouse pointer #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <Misc.au3> #include <StringConstants.au3> #include <TrayConstants.au3> ; to avoid running it multiple times! If _Singleton(@ScriptName, 1) = 0 Then Exit Opt("TrayMenuMode", 3) ; These are options 1 and 2 for TrayMenuMode. Global $hMag_GUI, $hMagDC, $hDeskDC, $hPen, $oObj, $aMouse_Pos[2], $iLast_Mouse_X = 0, $iLast_Mouse_Y = 0 Local $mColor, $hColor_Win, $ColorLabel, $ColorRec TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Red.ico") TraySetToolTip("ColorPicker") #Region === Tray_Menu === ;~ Local $idPaused = TrayCreateItem("Pause", -1, -1, $TRAY_ITEM_RADIO) ;~ TrayItemSetState(-1, $TRAY_UNCHECKED) Local $TrayColorPicker = TrayCreateItem("ColorPicker") Local $TrayHelp = TrayCreateItem("Help") TrayCreateItem("") ; Create a separator line. Local $TrayExit = TrayCreateItem("Exit") #EndRegion === Tray_Menu === Local $hDLL = DllOpen("user32.dll") While 1 Switch TrayGetMsg() Case $TRAY_EVENT_PRIMARYDOUBLE ;* ColorPicker ColorPicker() Case $TrayColorPicker ; ColorPicker ColorPicker() Case $TrayHelp ; Help HelpInfo() Case $TrayExit ; Exit GoToExit() EndSwitch ;if END key close ColorPicker If _IsPressed("23", $hDLL) Then Sleep(300) ColorPicker() EndIf Sleep(50) WEnd GoToExit() ;---------------------------------------------------------------------------------------- Func GoToExit() ; exit CloseColorPicker() DllClose($hDLL) Exit EndFunc ;==>GoToExit ;---------------------------------------------------------------------------------------- Func ColorPicker() ; Create Color GUI $hColor_Win = GUICreate("Color", 100, 30, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUICtrlCreateLabel("Label1", 0, 0, 100, 30, $SS_BLACKFRAME) $ColorLabel = GUICtrlCreateLabel(" ", 26, 7, 74, 20) $ColorRec = GUICtrlCreateLabel(" ", 1, 1, 25, 28) GUICtrlSetFont($ColorLabel, 10, 600, 0, "Consolas") GUICtrlSetBkColor($ColorLabel, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_SHOW, $hColor_Win) ; Create MAG GUI $hMag_GUI = GUICreate("MAG", 100, 100, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetState(@SW_SHOW, $hMag_GUI) ; Get device context for Mag GUI $hMagDC = _WinAPI_GetDC($hMag_GUI) If @error Then Exit ; Get device context for desktop $hDeskDC = _WinAPI_GetDC(0) If @error Then _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) Exit EndIf ; Create pen $hPen = _WinAPI_CreatePen($PS_SOLID, 5, 0x7E7E7E) $oObj = _WinAPI_SelectObject($hMagDC, $hPen) While 1 ; Check if cursor has moved $aMouse_Pos = MouseGetPos() If $aMouse_Pos[0] <> $iLast_Mouse_X Or $aMouse_Pos[1] <> $iLast_Mouse_Y Then ; Redraw Mag GUI Loupe($aMouse_Pos) ; Reset position $iLast_Mouse_X = $aMouse_Pos[0] $iLast_Mouse_Y = $aMouse_Pos[1] EndIf Select Case _IsPressed("02", $hDLL) Or _IsPressed("10", $hDLL) ; 02 = Right mouse button ; 10 = SHIFT key TakeSnap() Return Case _IsPressed("23", $hDLL) ;23 END key TakeSnap() Return Case _IsPressed("1B", $hDLL) ;1B = ESC key CloseColorPicker() Return Case _IsPressed("25", $hDLL) ; 25 = LEFT ARROW key MouseMove($aMouse_Pos[0] - 1, $aMouse_Pos[1]) Sleep(100) Case _IsPressed("26", $hDLL) ; 26 = UP ARROW key MouseMove($aMouse_Pos[0], $aMouse_Pos[1] - 1) Sleep(100) Case _IsPressed("27", $hDLL) ; 27 = RIGHT ARROW key MouseMove($aMouse_Pos[0] + 1, $aMouse_Pos[1]) Sleep(100) Case _IsPressed("28", $hDLL) ; 28 = DOWN ARROW key MouseMove($aMouse_Pos[0], $aMouse_Pos[1] + 1) Sleep(100) EndSelect WEnd EndFunc ;==>ColorPicker ;---------------------------------------------------------------------------------------- Func Loupe($aMouse_Pos) Local $iX, $iY ; Fill Mag GUI with 10x expanded contents of desktop area (5 pixels around mouse) DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 0, "int", 0, "int", 100, "int", 100, _ "int", $hDeskDC, "int", $aMouse_Pos[0] - 5, "int", $aMouse_Pos[1] - 5, "int", 10, "int", 10, _ "long", $SRCCOPY) ; Original 10 x 10 expanded to 100 x 100 - 10x magnification $mColor = PixelGetColor($aMouse_Pos[0], $aMouse_Pos[1]) $mColor = "0x" & Hex($mColor, 6) ; * <-------------- color converted to hexadecimal GUICtrlSetData($ColorLabel, $mColor) GUICtrlSetBkColor($ColorRec, $mColor) ; Keep Mag GUI on screen If $aMouse_Pos[0] < (@DesktopWidth - 120) Then $iX = $aMouse_Pos[0] + 20 Else $iX = $aMouse_Pos[0] - 120 EndIf If $aMouse_Pos[1] < (@DesktopHeight - 150) Then $iY = $aMouse_Pos[1] + 20 Else $iY = $aMouse_Pos[1] - 120 EndIf WinMove($hMag_GUI, "", $iX, $iY, 100, 100) WinMove($hColor_Win, "", $iX, $iY + 100) EndFunc ;==>Loupe ;---------------------------------------------------------------------------------------- Func TakeSnap() ClipPut($mColor) ConsoleWrite($mColor & @CRLF) WinMove($hColor_Win, "", @DesktopWidth - 120, @DesktopHeight - 75) GUISetState(@SW_HIDE, $hMag_GUI) WinWait("[CLASS:#32768]", "", 1) If WinExists("[CLASS:#32768]") Then Send("{ESC}") Sleep(3000) CloseColorPicker() EndFunc ;==>TakeSnap ;---------------------------------------------------------------------------------------- Func CloseColorPicker() ; Clear up Mag GUI _WinAPI_SelectObject($hMagDC, $oObj) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDeskDC) _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) GUIDelete($hMag_GUI) GUIDelete($hColor_Win) EndFunc ;==>CloseColorPicker ;---------------------------------------------------------------------------------------- Func HelpInfo() Local $Msg = @CRLF & "HotKey {END} call ColorPicker." & @CRLF & @CRLF _ & "During ColorPicker is active" & @CRLF & @CRLF _ & "{END} or {SHIFT} or Right mouse button" & @TAB & @CRLF _ & "snap the Color to clipboard " & @CRLF & @CRLF _ & "{LEFT}, {UP}, {RIGHT}, {DOWN}" & @CRLF _ & "moves the mouse by 1 pixel" & @CRLF & @CRLF _ & "{ESC} close ColorPicker to tray" & @CRLF & @CRLF _ & "---> Press {ESC} to exit <--- " & @CRLF _ & " " & @CRLF ToolTip($Msg, @DesktopWidth / 2, @DesktopHeight / 5, "info", 1) GUICtrlSetFont(-1, 14, 600, 0, "Arial") Do Sleep(100) Until _IsPressed("1B", $hDLL) ; 1B ESC key ToolTip("") EndFunc ;==>HelpInfo Please, leave your suggestion , comments , experiences here. Thank you!1 point -
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase ;~ WinWaitActive("[TITLE:CHARON; CLASS:#32770]", "", 5) WinWait("[TITLE:CHARON; CLASS:#32770]", "", 5) ; Better to exempt it from having to be Active1 point
-
Try to activate the window manually and see if WinWaitActive gets triggered. If yes, don't use WinWaitActivate, instead use WinActivate in combination with WinActive. Example: Local $bWndIsActive = False Do WinActivate($hWnd) Sleep(1000) $bWndIsActive = WinActive($hWnd) Until ($bWndIsActive) Of course, you can add something like $iMaxAttempts to quit the loop.1 point
-
@uvlights, I do understand the emotions one gets when when being told that you could have searched and find the answer yourself, but don't you agree there's also some truth in that statement and did you really try to search ? (No need to answer this here, but rather only to yourself. The real answer is shown when you click the link) Here's my advice to you: don't start the "you don't belong here" battle in public unless you know who you are dealing with, and simply ignore comments when you don't like them. 😉 PS: There is no need to make 2 reports on posts you don't like.... one will suffice and welcome to the Internet in case these posts are bothering you.1 point
-
nobody needs people like you in a forum. if you're not willing to answer, or if you just had a bad day, please don't reply at all the next time. thanks.1 point
-
Here's a simple example using _ArrayShuffle -- #include <array.au3> Global $iCount = 3 Global $randomnumber[$iCount] For $i = 0 To $iCount - 1 $randomnumber[$i] = $i + 1 Next _ArrayDisplay($randomnumber, 'pre-shuffle') _ArrayShuffle($randomnumber) _ArrayDisplay($randomnumber, 'post-shuffle')1 point
-
and here's a tool I made a while ago for the correct name of the call ;------------------------------------------------------------------------------ ; Title...........: CaptureMenuInfo.au3 ; Description.....: Capture Menu Information from selected win ;------------------------------------------------------------------------------ #include <MsgBoxConstants.au3> #include <GuiMenu.au3> CaptureMenuInfo() ;----------------------------------------------------------------------------------- Func CaptureMenuInfo() ; item 1197 - Capture Menu Information Local $hWnd, $hMenu, $Txt Local $iMsgBoxAnswer, $Msg $Msg = "First Select (Activate) the window" & @CRLF _ & " you wand the information " & @CRLF _ & "and then click ok" $iMsgBoxAnswer = MsgBox($MB_OKCANCEL + $MB_TOPMOST + $MB_ICONINFORMATION, "Get Menu Information", $Msg) Select Case $iMsgBoxAnswer = 1 ;OK ; ok Case $iMsgBoxAnswer = 2 ;Cancel Return False EndSelect ; Retrieve the class of the active window. $hWnd = WinGetHandle("[ACTIVE]") Local $pClassName = DllStructCreate("char[256]") DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", DllStructGetPtr($pClassName), "int", 255) Local $cText = DllStructGetData($pClassName, 1) $hWnd = WinGetHandle("[CLASS:" & $cText & "]") $hMenu = _GUICtrlMenu_GetMenu($hWnd) Local $sTitle = WinGetTitle($hWnd) Local Const $sFilePath = @DesktopDir & "\Menu-Information.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the txt file.") Return False EndIf FileWriteLine($hFileOpen, "Window title: " & $sTitle) Local $mCount, $m, $hSubMenu ; Display system menu $mCount = _GUICtrlMenu_GetItemCount($hMenu) FileWriteLine($hFileOpen, "Menu handle: 0x" & Hex($hMenu)) FileWriteLine($hFileOpen, "SubMenu count: " & $mCount) FileWriteLine($hFileOpen, " ") For $m = 0 To $mCount - 1 FileWriteLine($hFileOpen, "-----------------------------------------------------------------------") FileWriteLine($hFileOpen, "SubMenu " & $m & ": " & _GUICtrlMenu_GetItemText($hMenu, $m)) FileWriteLine($hFileOpen, "-----------------------------------------------------------------------") $hSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $m) Local $sCount, $s ; Display system menu $sCount = _GUICtrlMenu_GetItemCount($hSubMenu) FileWriteLine($hFileOpen, @TAB & "SubMenu handle: 0x" & Hex($hSubMenu)) FileWriteLine($hFileOpen, @TAB & "Item count: " & $sCount) FileWriteLine($hFileOpen, " ") For $s = 0 To $sCount - 1 FileWriteLine($hFileOpen, @TAB & "Item " & $s & ": " & _GUICtrlMenu_GetItemText($hSubMenu, $s)) Next FileWriteLine($hFileOpen, " ") Next FileClose($hFileOpen) Sleep(50) ShellExecute($sFilePath) EndFunc ;==>CaptureMenuInfo ;--------------------------------------------------------------------------------------------1 point
-
StringRegExp doesn't match ^
littlebigman reacted to pixelsearch for a topic
Don't you need (?m) to do that ? (?m) Multiline: ^ and $ match at newline sequences within data. By default, multiline is off.1 point -
Autoit + browser profiles
uvlights reacted to TendernessCup for a topic
Hello everyone and thank you in advance for your help. Bottom line: the site displays information then asks randomly for a few lines with a JS easy to do, like this: const listArray = document**.querySelectorAll('div.relative > span.absolute'); listArray.forEach(function (element) { element.innerText})**; But how to combine JS and AutoIT, or how to solve this task in general? I've never worked with browser-based automation. Thank you :31 point -
Autoit + browser profiles
uvlights reacted to TendernessCup for a topic
no, but in future problem of captcha can appear1 point -
Bulldozer
argumentum reacted to Andreik for a topic
Usually it's not a good practice to store assets in database but since I have only fifteen assets and each around 2 - 3 Kb in size, it works in my case.1 point -
Asynchronous callbacks?
argumentum reacted to Danp2 for a topic
Yes, they are very likely one and the same. The first post from @janeer was deleted due to spam that was added during an edit of the original post. Chances are that @Janiir will meet the same fate.1 point -
Display .xcu file in richedit control
pixelsearch reacted to mike1950r for a topic
Pixelsearch, I tried this modification to automate the wrap if needed: Func _GUICtrlRichEdit_WordWrapAuto($hWnd, $sText) Local $bEnable $bEnable = False If StringLen($sText) > 8192 Then If Not StringInStr($sText, @CRLF) Then $bEnable = True EndIf EndIf If (IsHWnd($hWnd) = False) Then Return SetError(1, 0, False) EndIf DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $EM_SETTARGETDEVICE, "wparam", 0, "lparam", Not $bEnable) If (@Error) Then Return SetError(2, @extended, False) EndIf Return True EndFunc cheers and thanks again mike1 point -
Display .xcu file in richedit control
mike1950r reacted to pixelsearch for a topic
@mike1950r I did a few tests, here are the results : _GUICtrlRichEdit_SetLimitOnText isn't required if we paste directly Plain text in a RichEdit control, but it is required to bypass the 32KB/64KB limits when we paste RTF text ( e.g a long string starting with "{\rtf or "{urtf" ) . Also, the limit value we indicate is the number of characters in the string of RTF text, minus the RTF keywords lenght present in the string (more or less) In my tests, the value I indicated in _GUICtrlRichEdit_SetLimitOnText was much more than 64KB : I indicated 2.000.000 characters as a limit, then pasted an RTF string of 1.000.000 RTF text characters in the RichEdit control : all the RTF text appeared correctly (especially the very last characters) so I don't know why this 64KB limit is mentioned everywhere. Please anyone, share your knowledge about this if you got infos, thanks. Now let's talk about the string found in your file "registrymodifications.xcu", it's a string of 41KB which contains characters and spaces, but doesn't contain any line break. Let's see what happens in NotePad, WordPad, an AutoIt RichEdit control or Scite, when Wrap is not ticked 1) Scite : the easiest one first. The 41KB string is displayed on 1 line (when Wrap is unticked) and fully visible from the beginning till the end, great ! 2) NotePad : the string is displayed on 41 lines, when Wrap is unticked (as Notepad's right limit is 1024 chars) so 1024 *41 is more or less 41KB (the file size) If Wrap is ticked, then of course much more of than 41 lines are displayed (wrapping occurs if a space is found between words, or if a 'line' covers the whole width of the Notepad window, without any space in it, then it wraps inside a word as no space has been found). So we can say all text is always visible in NotePad, as you indicated in your post. 3) WordPad : now the issues start when Wrap is unticked : - If a string got less than 10.772 characters (and doesn't contain any line break) then it is correctly displayed and fully visible on 1 line, there is an horizontal (scrollbar and if you press Home/End keys, the caret will be placed automatically at the beginning or the end of the string : so far so good. - If the string got exactly 10.772 characters, then the scrollbar disappears, the End key isn't functional and you see only a part of the string. - If the string got more than 10.772 characters then nothing good will happen too (you won't be able to see the end of the line, because Wrap is unticked. The horizontal scrollbar may appear or not, depending on how many characters have been added to 10.772 , a kind of cycle) 4) AutoIt RichEdit control (with Wrap unticked) : It's exactly the same issues than WordPad, except the limit is 8.192 characters (instead of 10.772 for WordPad) The solution (in WordPad and RichEdit control) should be to check Wrap in this case, so all lines appear on the screen. A good thing could be to have an option, in a GUI containing a RichEdit control, to wrap/unwrap the content of the control, when user needs it. @InunoTaishouindicated in this post how to do it for a RichEdit control (wrap/unwrap, on the fly) There's also a post here where we discussed the way to do it for a regular edit control, which could be handy when needed. Hope it helps1 point -
WinWaitActive behavior inconsistent on different servers?
ipc1234 reacted to mistersquirrle for a topic
Keep in mind that if these are headless servers, you may be running into limitations with Win* actions because the windows don't "really" exist, check out: https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F For this use-case locked and headless (as in no remotely connected session with a monitor, or monitor connected to the system) are the same. Otherwise, there's an issue with your WinWaitActive, where you're using the wrong parameters: WinWaitActive("CHARON Launcher", 5) Is wrong, and it should be: WinWaitActive("CHARON Launcher", "", 5) Because you're saying that the window must have the "Text" of "5": WinWaitActive ( "title" [, "text" [, timeout = 0]] ) That's probably why your other WinWaitActive works better, you have the parameters in the correct order there.1 point -
Autoit + browser profiles
TendernessCup reacted to JLogan3o13 for a topic
@TendernessCup This appears to be solving some sort of Captcha, is that correct? =====Note to others. This is a Mod stepping into a thread, stay out until the Okay is given=====1 point -
Autoit + browser profiles
uvlights reacted to TendernessCup for a topic
thank you very much! but i am pretty novice at it all, can you help me to to that?1 point -
Autoit + browser profiles
uvlights reacted to TendernessCup for a topic
thank you for you help, i really appreciate it! 1. I use antidetect browser "dolphin anty" which is based on chrome, with many profiles (account's), so as i understand - WebDriver will not work in this case, but maybe i am wrong. I never worked with it, so i really don't know. 2. My attempts to run the javascript were unsuccessful, apparently it needs WebDriver or something. At the moment I can only see a solution through OCR or picture comparison, but I'm sure there is a more elegant solution. Hope for your help :31 point -
Autoit + browser profiles
uvlights reacted to TendernessCup for a topic
custom browser what is WD UDF? tell me please1 point -
Version 1.5.0.1
952 downloads
The F1 key in SciTE displays the documentation for the word on which the cursor is located. Up to now this was only available for AutoIt. But times change and we change with them Now with Advanced.Help ANY CHM help file (Compressed HTML Help) can be called with the F1 key. The only prerequisite: All function names have to start with the same identifier (like _AD_, _OL_ etc.). This tool, created by BugFix from the german forum and the help of Musashi, allows custom CHM help files to be included in SciTE. The existing help key is used to call either the AutoIt help or the corresponding custom help. Depending on which keyword the cursor is currently on. For unknown keywords the AutoIt help is called. For AutoIt a separate window is opened and for the user-defined UDFs another window is opened, so you can work with both helps at the same time. The ZIP file contains an installation guide in German (Install_Deutsch.txt) and English (Install_English.txt) in which the installation and configuration is described in detail. Most CHM help files come with UDFs you can download from this forum section (AD, OutlookEX, TaskScheduler). In addition we have added the preliminary release of the WebDriver help file. The most current CHM help file is now only distributed with the WebDriver UDF. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort Known Bugs: (last changed: 2022-07-20) None1 point -
Combine columns in an array (Solved)
GreeNerO reacted to xcaliber13 for a topic
Malkey, That is exactly what I needed. Just had to adjust one line to make it fit my needs perfectly. Changed: $aArray_Base[$i][$aColsToCombine[0]] &= $aArray_Base[$i][$aColsToCombine[$j]] & " " ; Space used to separate data from each column. To $aArray_Base[$i][$aColsToCombine[0]] &=" "&$aArray_Base[$i][$aColsToCombine[$j]] & " " ; Space used to separate data from each column. That gave me the correct spacing I needed. Again Thank you1 point -
For jerk Jos
krejasisoj reacted to Ytachi1000 for a topic
So what is your problem? So what you closed my topic caz was included "crackcaptcha on it"? Tell me you have mental problems? I just find a tutorial on youtube for tessereact on a video is called crack captcha,, and i download a code from it, so what? Do I said I want crack anything? even so what the fuck is your problem, You said "you have a legitimate purpose for a script" hahaha you kiddin? no you dont you are just so stupid if you realy think i was going something ilegitible , you wanr me without reasin still you repeat yourself like a dumb kid, you have courage behind a screen i see. Anyone can have any proposes bro, is not that your consern , you are here to help or what?? or just annoy people Well if so this you make look this forum like an useful place. Just scrub all around here, You realy think u know what people do with scrips,is alway 100% legit oh really? You realy think some gives a shit about your rules, i just come to find an answer, people like you just make ppl to don't enter here "You should read the rules first" ooooh my god dude you SO FKING rightttt, like i dont know them ahaahah YOU SHOULD TlHINK TWICE BEFORE YOU SAY SOMETHING IDIOT, YOU RLY THINK I DONT KNOW THE RUULES? Of corse i doont need for that , but you just rage with your rulse, who the fuck I can put as a joke that im /biggest hack on the planet i want hack google with this scrips/ And? tell me should i still read your rules, who actualy are the same everyone.1 point -
Hi all, I make this thread in reference to this help topic. Call it my "thank you" for the help. This actually came about as a random thought while I was taking a smoke break. I personally almost never use the capslock button, so why not find a way to make it more useful right? And yes, the title is a play on MAGA. No political attachment , just thought it funny. Anyway, here is code. Global Const $VK_CAPITAL = 0x14 $WshShell = ObjCreate("WScript.Shell") While 1 Sleep(100) If _Key_Is_On($VK_CAPITAL) Then Run("notepad.exe") $WshShell.SendKeys("{CAPSLOCK}") EndIf WEnd Func _Key_Is_On($nVK_KEY, $vDLL = 'User32.dll') Local $a_Ret = DllCall($vDLL, "short", "GetKeyState", "int", $nVK_KEY) Return Not @error And BitAND($a_Ret[0], 0xFF) = 1 EndFunc This is autoit that we are talking about, so you can probably come up with a number of functions and scripts to be fired on press. I hope someone finds this useful.1 point
-
_UskinLibrary.au3 (UDF) - Skin with DLL free (no ads) and fully functional!
abberration reacted to JScript for a topic
Hello everyone! Use skins for free is not an easy task and not very elegant, so I developed this UDF that I had been using in some programs that I did but that was not in the way of UDF! Are just two files: 1 - _USkinDLL.au3 2 - _UskinLibrary.au3 And only these three lines to add to your scripts: ; #include "_UskinLibrary.au3" _Uskin_LoadDLL() _USkin_Init(@ScriptDir & "SkinsOldSkool.msstyles"); <-- Put here your favorite skin... ;Run or compile the script and enjoy! Note: You can use the FileInstall() to attach the skin you want in your executable, or use the program ?do=embed' frameborder='0' data-embedContent> to embed the skin you want, there you will have to use this case as follows: ; #include "_UskinLibrary.au3" #include ".SkinsOldSkool.au3"; <-- This is an skin ".msstyles" embedded _Uskin_LoadDLL() _USkin_Init(_OldSkool(True)); <-- Put here your favorite Skin!!! ;See the program documentation ?do=embed' frameborder='0' data-embedContent> for more information about how to call files embedded! Note: Some skins have problems if the program is compiled using UPX compression, to circumvent this problem compile your program with the following options added to the top of the source code: #AutoIt3Wrapper_Compression=0 ;Compression parameter 0-4 0=Low 2=normal 4=High. Default=2 #AutoIt3Wrapper_UseUpx=n ;(Y/N) Compress output program. Default=YExample image Download (Updated 14/07/2012) Source with 57 Skins (.msstyles) and embedded (.au3): Example_UskinLibrary_(RedirectLink).html 17.8k (Previous downloads: 588) More Skins downloads http://www.skinbase.org/Skins/msstyles/135 http://www.lotsofskins.com/?num=41&page=browse_category Note: Only files are supported is "msstyles", but it is not a bother, since there are many sites with free downloads of these skins! The use of this DLL is free, ad-free and fully functional! About dll: http://www.neemedia.com João Carlos.1 point -
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel _Example() Func _Example() Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") #forceref $oErrorHandler Local $oXmlDoc = ObjCreate("Msxml2.DOMDocument.3.0") $oXmlDoc.loadXml('<start></start>') If @error Then MsgBox(0, '1. @error', @error) If $oXmlDoc.parseError.errorCode Then MsgBox(0, '1. $oXmlDoc.parseError.', $oXmlDoc.parseError.errorCode & @CRLF & $oXmlDoc.parseError.reason) Local $oNode_Selected = $oXmlDoc.selectSingleNode('/book') If @error Then MsgBox(0, '2. @error', @error) MsgBox(0, IsObj($oNode_Selected), VarGetType($oNode_Selected)) EndFunc ;==>_Example Func _ErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc_CustomUserHandler Whats wrong with this line: MsgBox(0, IsObj($oNode_Selected), VarGetType($oNode_Selected))Why IsObj = 0 and VarGetType = Object ??? How it is possible.1 point