Jump to content

How to escape GUIButton?


Recommended Posts

Dear AutoIt Community,

I need some clarification as to why GUI does not work as planned. This is the snippet of code that's troubling me:

Else
      GUICreate("Path", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, $WS_EX_ACCEPTFILES)
      Local $idFile = GUICtrlCreateInput("", 10, 5, 300, 20)
      GUICtrlSetState(-1, $GUI_DROPACCEPTED)
      Local $idPath = GUICtrlRead($idFile)
      GUICtrlCreateLabel("Type path of .exe or drag file into InputBox", 10, 35)
      Local $idBtn = GUICtrlCreateButton("OK", 160 - 30, 75, 60, 20)
      GUISetState(@SW_SHOW)

      ; Loop until the user exits.
      While 1
         Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               ExitLoop
            Case $idBtn
               ExitLoop
         EndSwitch
      WEnd

      Run($idPath)
      ProcessWait("Patcher.exe")
      WinWait("Patcher")
      WinWaitActive("Patcher")
      If Not WinActive("Patcher") Then
         WinActivate("atcher")
      EndIf
   EndIf

My problem here is that when I want to exit the created GUI or press the button $idBtn, it won't exit. However, when I execute the following snippet by itself, it works.

GUICreate("Path", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, $WS_EX_ACCEPTFILES)
   Local $idFile = GUICtrlCreateInput("", 10, 5, 300, 20)
   GUICtrlSetState(-1, $GUI_DROPACCEPTED)
   Local $idPath = GUICtrlRead($idFile)
   GUICtrlCreateLabel("Type path of .exe or drag file into InputBox", 10, 35)
   Local $idBtn = GUICtrlCreateButton("OK", 160 - 30, 75, 60, 20)

   GUISetState(@SW_SHOW)

   ; Loop until the user exits.
   While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            ExitLoop
         Case $idBtn
            ExitLoop
      EndSwitch
   WEnd

I don't know what to do.

Mny Thanks in advance,

~Medallyon

Link to comment
Share on other sites

  • Moderators

Medallyon,

The script is almost certainly halting at either the ProcessActive or WinWaitActive lines - add a timeout to them both so that the script proceeds with the loop until the process and GUI are present.

M23

P.S. And seeing the name of the process/GUI, could I point you to the Forum rules if you have not already read them.

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Melba23

Thanks for your quick response.

Medallyon,

The script is almost certainly halting at either the ProcessActive or WinWaitActive lines - add a timeout to them both so that the script proceeds with the loop until the process and GUI are present.

I added a timeout to both of the lines but that did nothing.

P.S. And seeing the name of the process/GUI, could I point you to the Forum rules if you have not already read them.

Ayy, I know the rules. My script in no way or form messes with games or game integrity (as far as I know). It's a mere process of clicking Login so that I don't have to do it.

Why?

Because 

  1. I have too much time on my hands
  2. I take joy in creating things

This is the full code:

<snip>

If you have any more ideas I could try out, I welcome you to share them :)

Many thanks in advance,

~Medallyon

Edited by Melba23
Code removed
Link to comment
Share on other sites

  • Moderators

Medallyon,

Ayy, I know the rules.

Really? So how do you square this line:

Run("lol.launcher.exe")

with this prohibition?

Do not ask for help with AutoIt scripts, post links to, or start discussion topics on the following subjects:
[...]
•Launching, automation or script interaction with games or game servers, regardless of the game.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Medallyon,

Correct - thread closed.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...