Jump to content

Recommended Posts

ShowChildGuis.png.93a1a9bc8b2b78cef80cae05ee398940.pngI don't often have occasion to use Child GUIs.  I find the multitude of options confusing.

The example below I made for my own purposes, to have a visual guide to what the various Style and Extended Style options lead to.

Comments are much appreciated.  This can be extended with many more examples and comments and why certain Styles are to preferred or avoided.  Where certain types of Child GUIs are most suitable etc.

 

The code is very basic.  It is intended to show GUI Styles, not much else.

;~ ********************************************************************
;~  Author: Skysnake
;~
;~  Title:  Demo various Child Gui options
;~  Updated: 2019.01.03
;~
;~  Function:   A demo script, demonstrates various style & Extended
;~              style options for Child GUIs
;~  Comments, ideas and suggestions very welcome :)
;~
;~ ********************************************************************
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>

ShowChildGuis()

Func ShowChildGuis()

    Local $guiParent = GUICreate("The Parent GUI", 1200, 700, 0, 0) ;WHLT

    $idFilemenu = GUICtrlCreateMenu(" &Menu")

    $ButtonCancel = GUICtrlCreateButton("&Close", 0, 0, 80, 25)
    GUICtrlSetTip($ButtonCancel, "Click to close all")

    $ButtonShowChildGui = GUICtrlCreateButton("&Show", 0, 25, 80, 25)
    GUICtrlSetTip($ButtonShowChildGui, "Click to show a child GUI")

;~  #comments-start --- Toggle this and same code below to show context menu for parent or child
    Local $idContextmenu = GUICtrlCreateContextMenu()

    Local $idNewsubmenu = GUICtrlCreateMenu("This is a Context Menu", $idContextmenu)
    Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu)

    Local $idContextButton = GUICtrlCreateButton("Context", 0, 50, 80, 25)
    GUICtrlSetTip($idContextButton, "Right Click to see Context Menu")
    Local $idButtoncontext = GUICtrlCreateContextMenu($idContextButton)
    Local $idMenuAbout = GUICtrlCreateMenuItem("This is a Context Menu", $idButtoncontext)

    Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu)
    Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu)
    GUICtrlCreateMenuItem("", $idContextmenu) ; separator

    Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu)
;~  #comments-end   --- Toggle this and same code below to show context menu for parent or child



    Local $DefaultChildGui = GUICreate("Default child gui", 300, 100, 300, 300, Default, Default, $guiParent) ;;;WHLT
    GUICtrlCreateLabel("Default attributes" & @CRLF & "Cannot move; cannot resize", 0, 0, 500, 200)
    GUICtrlSetBkColor(-1, $COLOR_aqua)

    $iStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($DefaultChildGui), $GWL_STYLE)
    $iExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($DefaultChildGui), $GWL_EXSTYLE)
    GUISetStyle(BitOR($iStyle, $WS_VISIBLE), $iExStyle, $DefaultChildGui)



    Local $gChildGuiwithMenu = GUICreate("A child gui with menu", 300, 100, 50, 100, $WS_VISIBLE, BitOR($WS_EX_WINDOWEDGE, $WS_EX_MDICHILD, $WS_THICKFRAME), $guiParent) ;;;WHLT
    GUICtrlCreateLabel("Menu" & @CRLF & "Can move; cannot resize", 0, 0, 500, 200)
    GUICtrlSetBkColor(-1, $COLOR_skyblue)

    $idFilemenu = GUICtrlCreateMenu(" &File ")
    Local $idFileMenuItem = GUICtrlCreateMenuItem("An item for the File menu ", $idFilemenu)
    GUICtrlCreateMenuItem("", $idFilemenu) ; create a separator line

    ; use same dimensions for GUI and its Label
    Local $iSizeWide = 300, $iSizeHi = 100
    GUICreate("A child gui", $iSizeWide, $iSizeHi, 100, 200, $WS_VISIBLE, BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOPMOST, $WS_EX_MDICHILD, $WS_THICKFRAME), $guiParent) ;;;WHLT
    GUICtrlCreateLabel("Can move; cannot resize" & @CRLF & "Always on top", 0, 0, $iSizeWide, $iSizeHi)
    GUICtrlSetBkColor(-1, $COLOR_red)


    GUICreate("Child Gui Resizable", 300, 100, 200, 50, BitOR($WS_POPUP, $WS_SIZEBOX, $WS_CLIPCHILDREN, $WS_VISIBLE), $WS_EX_MDICHILD, $guiParent) ;;;WHLT
    GUICtrlCreateLabel("Popup Cannot move; can resize" & @CRLF & "Background", 0, 0, 500, 200) ; $WS_CHILD,
    GUICtrlSetBkColor(-1, $COLOR_blue)
    ; toggle the line below :)
    ;$idBackgroundmenu = GUICtrlCreateMenu(" &Menu ") ; give it a menu

    GUICreate("Child GUI, caption, resize", 300, 100, 300, 100, BitOR($WS_VISIBLE, $WS_POPUP, $WS_CAPTION), BitOR($WS_EX_TOOLWINDOW, $WS_EX_MDICHILD, $WS_EX_ACCEPTFILES), $guiParent)
    GUICtrlCreateLabel("Popup With Caption: Can move; cannot resize", 0, 0, 500, 200)
    GUICtrlSetBkColor(-1, $COLOR_yellow)

    GUICreate("Child GUI, abc", 300, 100, 400, 150, BitOR($WS_POPUP, $WS_VISIBLE, 0), $WS_EX_MDICHILD, $guiParent)
    GUICtrlCreateLabel("Popup Cannot move; cannot resize", 0, 0, 500, 200)
    GUICtrlSetBkColor(-1, $COLOR_green)


    ; Child GUI below has a control ............................. .............................................
    Local $gChildWithControls = GUICreate("Child GUI with Buttons", 400, 400, 500, 200, BitOR($WS_CAPTION, $WS_CHILD), -1, $guiParent)
    GUISetFont(14, $gChildWithControls)
    Local $cLabel = GUICtrlCreateLabel("Can move; cannot resize", 0, 0, 400, 50)
    GUICtrlSetBkColor($cLabel, $COLOR_white)

    Local $idChild_ButtonOkay = GUICtrlCreateButton("Okay", 0, 50, 80, 30)
    Local $idChild_ButtonHide = GUICtrlCreateButton("Hide", 0, 80, 80, 30)
    GUICtrlSetTip($idChild_ButtonHide, "Click to hide this child GUI")

;~  #comments-start --- Toggle this and same code below to show context menu for parent or child
;~  Local $idContextmenu = GUICtrlCreateContextMenu()

;~  Local $idNewsubmenu = GUICtrlCreateMenu("This is a Context Menu", $idContextmenu)
;~  Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu)

;~  Local $idContextButton = GUICtrlCreateButton("Context", 0, 110, 80, 30)
;~  GUICtrlSetTip($idContextButton, "Right Click to see Context Menu")
;~  Local $idButtoncontext = GUICtrlCreateContextMenu($idContextButton)
;~  Local $idMenuAbout = GUICtrlCreateMenuItem("This is a Context Menu", $idButtoncontext)

;~  Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu)
;~  Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu)
;~  GUICtrlCreateMenuItem("", $idContextmenu) ; separator

;~  Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu)

;~  #comments-end   --- Toggle this and same code below to show context menu for parent or child

    GUISetState(@SW_HIDE, $gChildWithControls)
    ;..........................................................................................................



    Local $gToolbar = GUICreate("A floating Tool Window", 300, 50, 100, 25, $WS_VISIBLE, $WS_EX_TOOLWINDOW, $guiParent)
    GUICtrlCreateLabel("A floating toolbar", 0, 0, 500, 200) ; this does not show :)
    GUICtrlSetBkColor(-1, $COLOR_lime)

;~  $iStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($gToolbar), $GWL_STYLE)
;~  $iExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($gToolbar), $GWL_EXSTYLE) ; BitOR($WS_EX_TOOLWINDOW, $WS_EX_MDICHILD)
;~  GUISetStyle(BitOR($iStyle, $WS_VISIBLE), $iExStyle, $gToolbar)

    $idToolmenu = GUICtrlCreateMenu(" &Tool ")
    Local $idToolMenuItem = GUICtrlCreateMenuItem("An item for the Tool menu ", $idToolmenu)
    Local $idToolMenuItemsecond = GUICtrlCreateMenuItem("A second item for the Tool menu ", $idToolmenu)
    GUICtrlCreateMenuItem("", $idToolmenu) ; create a separator line

    $idPrintmenu = GUICtrlCreateMenu(" &Print ")
    Local $idToolMenuItemPrint = GUICtrlCreateMenuItem("A Print item for the Toolbar print menu ", $idPrintmenu)
    GUICtrlCreateMenuItem("", $idPrintmenu) ; create a separator line


    #Region --- After GUI BEFORE loop starts
    GUISetState(@SW_SHOW, $guiParent)
    #EndRegion --- After GUI BEFORE loop starts


    While 1
        ;Local $nMsg = GUIGetMsg()
        Switch GUIGetMsg() ; $nMsg
            Case $GUI_EVENT_CLOSE, $ButtonCancel
                GUIDelete($guiParent)
                ExitLoop
            Case $idContextButton
                MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'Right Click to see the Contect Menu')
            Case $ButtonShowChildGui
                GUISetState(@SW_ENABLE, $gChildWithControls)
                GUISetState(@SW_SHOW, $gChildWithControls)
            Case $idChild_ButtonHide ; <<<<<<<<<<<<<<< Child Gui Control Actioned in  main loop
                ConsoleWrite("Yup, you clicked it" & @CRLF)
                GUISetState(@SW_HIDE, $gChildWithControls)
            Case $idChild_ButtonOkay ; <<<<<<<<<<<<<<< Child Gui Control Actioned in  main loop
                ConsoleWrite("Yup, you clicked it" & @CRLF)
                MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'Okay')
        EndSwitch
    WEnd
    GUIDelete()

EndFunc   ;==>ShowChildGuis

 

 

Edited by Skysnake
Improved examples

Skysnake

Why is the snake in the sky?

Link to post
Share on other sites

I hope you don't mind my asking, but I have a question regarding your use of "&text".

I've never looked into how individual characters are underlined ... in menus, for example.  But after some searching, I found a rather obscure parameter in the help file for _WinAPI_DrawText:  "$DT_PREFIXONLY - Draws only an underline at the position of the character following the ampersand (&) prefix character."

Is the underline effect what you intended? If so, is there a simpler case for "&" use that I'm missing?

I'm asking because there are no underlined characters in your posted example or in my testing. Plus, removing the &'s doesn't seem to change anything.

 

Link to post
Share on other sites

@qwert, thx for the comment.

The & makes it possible to access the menu items using the keyboard. Click the Toolbar and press ALT+T or ALT+P on the keyboard.  This allows you to access the menu items using the keyboard.  It works as is.  I see no reason to remove this.

As for your help file reference, I do not know what that does.  Perhaps it only draws the line without making the keyboard shortcut available? 

:)

 

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to post
Share on other sites
2 hours ago, Skysnake said:

The & makes it possible to access the menu items using the keyboard.

Thanks for your reply. I now see that _GUICtrlMenu_InsertMenuItem in the help file has plenty of examples of use ... but, strangely, no mention of exactly what & denotes. Oh, well. Now I know.

Link to post
Share on other sites
  • 4 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By banged
      Hello, i have issues with my code
      If not WinSetTrans (line 44.45 - Both, red and yellow), Then not Show Childs                               (--- if Func _BK run on line 6, then does no matter if WinSetTrans, Childs not show !!
      if WinSetTrans (line 44.45 - Both, red and yellow) , Then  Show Childs, why NEED WinSetTrans??             (--- if Func _BK run on line 6, then does no matter if WinSetTrans, Childs not show !!
      if WinSetTrans Child1(RED) ONLY, then Show Child1(RED)                                                     (--- if Func _BK run on line 6, then does no matter if WinSetTrans, Child not show !!
      if WinSetTrans (line 44 Child2(Yellow) ONLY), then Show Child1(RED) & Child2(Yellow), Why show Both ????     (--- if Func _BK run on line 6, then does no matter if WinSetTrans, Childs not show !!
       With $WS_POPUP (and $WS_EX_MDICHILD ) i have not above problems, but i need use $WS_CHILD
       Problems with $WS_POPUP : if change windows resolution (and restore next time), then childs change position on main form
                             : i Need WinSetTrans on all GUIS when fade,with popup i need winsettrans all guis one by one
                              : on minimize,restore Main GUI ,childs not following windows minimize/restore effect
       First i Create  Child1, Second Child2, Why Child1 is above child2 ? (i need child2 above child1, and i don't want create firts the child2 or this is only way???)
      #include <GuiConstants.au3> Global $idButton2,$pp1,$pp2,$bShow = True $Main_GUI = GUICreate("Main", 1000,500,Default,Default) ;_BK() ;<--------- FAIL $Child1_GUI = GUICreate("Child1", 700,200, 220, 200, $WS_CHILD+$WS_THICKFRAME,Default, $Main_GUI) $idButton = GUICtrlCreateButton("RED",25,25,50,30) GUISetBkColor (0xFF334C, $Child1_GUI ) ; RED $Child2_GUI = GUICreate("Child2", 700,200, 30, 200,$WS_CHILD, Default, $Main_GUI) $test = GUICtrlCreateButton("Yellow",10,10,250,20) GUISetBkColor (0xFFff4C, $Child2_GUI ) ; Yellow _BK() ;<--------- SUCCES Func _BK() GUISwitch($Main_GUI) $pp1 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg",0,0,1000,500) GUICtrlSetState($pp1,$GUI_DISABLE) $pp2 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg",200,100,600,350) GUICtrlSetState($pp2,$GUI_DISABLE) $idButton2 = GUICtrlCreateButton("Main",0,300,280,30) $idButton3 = GUICtrlCreateButton("Main2",0,315,280,30) EndFunc GUISetState(@SW_SHOW, $Main_GUI) GUISetState(@SW_SHOW, $Child1_GUI) GUISetState(@SW_SHOW, $Child2_GUI) WinSetTrans($Child1_GUI,"",200) ;RED WinSetTrans($Child2_GUI,"",100) ; Yellow while 1 $iMsg = GUIGetMsg() Switch $iMsg Case -3 _Fade($Main_GUI,"out",254) Exit Case $idButton,$test For $i = 254 To 0 Step - 4 Sleep(10) WinSetTrans($Main_GUI,"",$i) Next For $i = 0 To 254 Step 4 Sleep(10) WinSetTrans($Main_GUI,"",$i) Next Case $idButton2 If $bShow = True Then GUISetState(@SW_HIDE, $Child2_GUI) GUISetState(@SW_HIDE, $Child1_GUI) $bShow = False Else GUISetState(@SW_SHOW, $Child2_GUI) GUISetState(@SW_SHOW, $Child1_GUI) $bShow = True EndIf EndSwitch wend Func _Fade($hHdl,$InOut,$iMax = 255,$iSpeed = 4) If $InOut = "out" Then For $i = $iMax To 0 Step - $iSpeed Sleep(10) WinSetTrans($hHdl,"",$i) Next Else For $i = 0 To $iMax Step $iSpeed Sleep(10) WinSetTrans($hHdl,"",$i) Next EndIf EndFunc  
    • By therks
      I'm trying to implement a scrolling list of controls. I have it sort of working using the GUIScrollBars_Ex UDF by @Melba23 found here. I also want to be able to tab through the controls, which I have accomplished by adding $WS_EX_CONTROLPARENT to the child GUI. The problem is that with that style applied, the scrollbar doesn't act like a scrollbar, instead it acts as a title bar to the child GUI letting you drag the it around (and you can even "maximize" it by double clicking).
      Any ideas?
      #include <GUIConstants.au3> #include "GUIScrollbars_Ex.au3" $iButtonCount = 30 $hParent = GUICreate('Example', 300, 230) $hChild = GUICreate('', 300, 200, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $hParent) For $i = 0 To $iButtonCount GUICtrlCreateButton('Button in list', 0, $i*30, 300, 30) Next GUISwitch($hParent) GUICtrlCreateButton('More Buttons', 0, 200, 150, 30) GUICtrlCreateButton('More Buttons', 150, 200, 150, 30) GUISetState(@SW_SHOW, $hParent) GUISetState(@SW_SHOW, $hChild) _GUIScrollbars_Generate($hChild, 100, $iButtonCount * 30+20) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd  
    • By timmy2
      I have the impression that the traditional method for processing responses to a GUI is to assign variables to each GUICreateButton (or Pic) and then use Switch/Case/Endswitch to detect when any Control is clicked.  In the tutorials I've seen about Koda it appears to use this method, too.
      While 1 Global $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Pic2 Call("verizon") Case $Pic3 Call("skype") Case $PicExit Exit EndSwitch WEnd But in a few examples I've seen a script use a different method. The script always includes the following option near the top:
      Opt("GUIOnEventMode", 1) ...and then, later, after creating each Control for the GUI, there's the function, GUICtrlSetOnEvent.  In these cases a very simple While/WEnd loop is used to wait for the user to respond. 
      I happened to employ this second method in a recent script where I used "canned" controls (checkbox and buttons). Later in the same script I used the GuiCreatePic and Switch/Case/EndSwitch method because my GUI was all custom images. (I'm not sure if that's necessary, but it's what I've deduced.) The second GUI failed to respond to any mouse clicks, but eventually I figured out the cause was the GUIOnEvenMode being enabled at the top of the script.
      This is when I realized I don't understand the reasoning behind choosing between these two methods. And I'm having no luck phrasing an appropriate search criterion. Is there an overview somewhere that explains the two methods and -- most importantly -- describes when each is appropriate?
    • By GregEisenberg
      Hi there 
      I am building a "statistics kiosk" where we will be enumerating through Web Pages, and Excel files, PDF reports and other applications each displaying statistics relevant to our project. I want to overlay some context over each page/screen so that viewers of this "statistics kiosk" have some info about that the data they are looking at is.  I have written a function called OverlayWindow which is supposed to create a transparent window which displays some text. The function SEEMS to work BUT 
      The handle returned from CreateGUI is 0 (despite there being NO error or extended information)  The window is created but not maintained.  In other words it appears but since it is not really maintained it is repainted as other content changes.  The result is that the overlay appears BUT as soon as there is a reason for the underlying windows to repaint the overlay starts to "disappear"  I have extracted the relevant code and created the most simplistic of samples here. 
      #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ; #FUNCTION# ==================================================================================================================== ; Name ..........: OverlayWindow ; Description ...: Throws up a child window with transparent background over current window ; ; Parameters : ; $hwndParent parent hwnd ; $rectToHighlight rect to draw (or if null, skip) ; $rectForText rect for textToWrite ; $textToWrite the text to write ; =============================================================================================================================== Func OverlayWindow($hwndParent, $rectToHighlight, $rectForText, $textToWrite) $style = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS) $exstyle = BitOR($WS_EX_TOPMOST, $WS_EX_COMPOSITED, $WS_EX_TRANSPARENT) $hGUI = GUICreate("transparent overlay", -1, -1, -1, -1, $style, $exstyle) ConsoleWrite("**** $hGUI: " & $hGUI & @CRLF) ConsoleWrite("**** @error: " & @error & @CRLF) ConsoleWrite("**** @extended: " & @extended & @CRLF) GUISetOnEvent($GUI_EVENT_CLOSE, "OverlayWindow_Exit") GUISetState(@SW_SHOW, $hGUI) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ConsoleWrite("**** $hGraphics : " & $hGraphics & @CRLF) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 4) ; Red If ($rectToHighlight <> Null) Then _GDIPlus_GraphicsDrawRect($hGraphics, $rectToHighlight[0], $rectToHighlight[1], $rectToHighlight[2], $rectToHighlight[3], $hPen) EndIf _GDIPlus_PenDispose($hPen) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000) ; RED $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 14, 2) $tLayout = _GDIPlus_RectFCreate($rectForText[0], $rectForText[1], $rectForText[2], $rectForText[3]) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $textToWrite, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphics, $textToWrite, $hFont, $aInfo[0], $hFormat, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_GraphicsDispose($hGraphics) Return $hGUI EndFunc Func OverlayWindow_Exit() ConsoleWrite("* * * Exit event called" & @CRLF) EndFunc Func Handle_Esc() $Done = True EndFunc ;----------------------------------------------------------------- ;Main() _GDIPlus_Startup() Global $Done = False Local $rect = [10, 10, 400, 400] Local $rectForText = [15, 15, 380, 380] $hGUI = OverlayWindow(Null, $rect, $rectForText, "This is a test with long text long text and should automatically wrap long text " & @CRLF & "and " & @CRLF & " handle " & @CRLF & "cariage returns and line feeds") HotKeySet ( "{Esc}", Handle_Esc) While Not $Done Sleep(100) WEnd GUIDelete($hGUI) _GDIPlus_Shutdown () Exit 0 I am assuming the since CreateGUI returns 0 that the  _GDIPlus_GraphicsCreateFromHWND is simply creating a "graphics context" based on the desktop then and not on my window.  And thus - there IS no window (despite no @error nor no @extended data) 
      So I think the issue is in the "styles" of window I am using.
      If I don't use WS_CHILD (for example I use WS_POPUP) then I get a handle back for my window and the lifetime of the window is what i want but it is not transparent as I want. Setting styles on the window to be transparent (either using extended styles, or using WinSetTrans or _WinAPI_SetBkMode) results in my rectangle and string being transparent - not what I want either. 

      Any suggestions?

      any and all help is appreciated
      Thanks! 

       

    • By DynamicRookie
      Hi
       
      I am developing a script that types a  string that can be specified in the Inputbox that has the $In01 variable attached.
       
      But 3 things are not working:
       
      It's not loading the gui, even when Guicreate() is specified in the code It's not typing the string, and i dont know why it doesn't type it. And last of them, It's not detecting if the script has a different name than the original, My Script is below:
      ;Script STRNG= 103494x104955x01 #include <Misc.au3> #Include <File.au3> #include <GuiConstants.au3> #INCLUDE <GuiConstantsEx.au3> #pragma compile(inputboxres, true)" If @ScriptName Not = "DynamicRookie's Colorized No. 103494x104955x01.au3" Then MsgBox(0, "Unofficial", "You are running an unnoficial version of STRNG: 103494x104955x01 by DynamicRookie, but feel free to use it below your own risk :)") ShellExecute("https://www.autoitscript.com/forum/profile/104955-dynamicrookie/") EndIf $StringVal116 = 1 $Const_Win32_idGetHandle = WinGetHandle("103494x104955x01", "1x1") Sleep (10) Hotkeyset("{=}", "_ResetVariable") SetError(0, 0, 0) $In01 = InputBox("In01", "Please enter the string you want to automate :)") If @error = 4 Then Call("ConsoleErrorFunction") EndIf MsgBox(4, "In03", "Want to enable _HasToRenewVal Function? (DEFAULT: Yes)") If $IDYES = 6 Then $_HTRVal = True Elseif $IDNO = 7 Then $_HTRVal = False EndIf Global $StringVal104910 = 0 ;Default String 0x0x1 :) Global $StringVal116 = 0 ;Custom String 0x5x1 :) Global $State = 1 Global $vReStr = '000' MsgBox(0, "DynaRookie", "Script made by DynamicRookie, for 103494 in AutoIt Forums") GUICreate("103494x104955x01", 400, 400, -1, -1, -1, -1) GUICtrlCreateLabel("103494x104955x01 Active Process", 10, 10, 100, 20, -1, -1) GUICtrlCreateLabel("Value Extension Macrostring: ", 10, 40, 100, 20) $vReStr = GUICtrlCreateLabel("N/V/R", 112, 40, 50, 20) GUICtrlCreateLabel("String Specified: # " & $In01 & " #, type K to type specified string.", 0, 100, 300, 20) Call("_D4N4M11CCKR010K133") ;It waits until u press K to check for $In03 and if checked to type type $In01 in the chat, then you need to press "=" key to enable the variable back, else ;If HasToRenew function is enabled you dont need to enable it back, ;else if the variable is already enabled and you dont want to make it type $In01 when you press K, press "=" when ;the variable is already enabled, it will deactivate it until you press "=" again. Func Init0() GUICtrlSetData($vReStr, 'Initializing: Control 0x1') $StatusString = "Init0" Sleep(1) $i_Win32_idPosition = WinGetPos("103494x104955x01", "1x2") $i_Win32_Status = "Active0" GUICtrlSetData($vReStr, 'Ready to use!') $StatusString = "RD1" Call("_D4N4M11CCKR010K133") EndFunc Func _D4N4M11CCKR010K133() While 1 If _IsPressed('4B') And $StringVal116 = 1 Then $StringVal104910 = 1 ExecuteFunction_0_0_0_1() EndIf Sleep(100) WEnd EndFunc Func _ResetVariable() If $State = 0 And $_HTRVal = True Then $State = 1 Call ("_D4N4M11CCKR010K133") Elseif $State = 1 And $_HTRVal = True Then $State = 0 Call ("_D4N4M11CCKR010K133") Else Call("_D4N4M11CCKR010K133") EndIf Endfunc Func ExecuteFunction_0_0_0_1() If $StatusString = "Init0" Then MsgBox(0, "Wait", "Please wait until it loads completely") Call("Init0") ElseIf $State = 1 And $_HTRVal = True Then GUICtrlSetData($vReStr, "Typing specified string") Send('' & $In01 & '', 1) $State = 0 GuiCtrlSetData($vReStr, "Sent function command!") Call("_D4N4M11CCKR010K133") ElseIf $State = 0 or $State = 1 And _HTRVal = False Then GUICtrlSetData($vReStr, "Typing specified string") Send('' & $In01 & '', 1) GuiCtrlSetData($vReStr, "Sent function command!") Call("_D4N4M11CCKR010K133") Else Call("_D4N4M11CCKR010K133") EndIf EndFunc Func ConsoleErrorFunction() ConsoleWrite($Const_Win32_idGetHandle) MsgBox("1, 48, 256, 4096, 2097152", "Exception @error", "An Unexpected error has occurred, please contact DynamicRookie for help, in AutoIt forums ( This window will close in " & $i_idTimeout_msg & "seconds", $i_idTimeout_msg) Exit 0 If @error = 1 Then ConsoleWrite("User has decided: Cancel = Val. 2") Exit 0 ElseIf @error = 2 Then ShellExecute("https://www.autoitscript.com/forum/profile/104955-dynamicrookie/") ConsoleWrite("User has decided: Nothing = Val. 0") Exit 0 EndIf  
×
×
  • Create New...