Zathus Posted February 23, 2021 Share Posted February 23, 2021 I have a script that runs just fine, below is an example of what I am doing, When I run this code, each function waits until the left mouse button is clicked and then will go to the next function: Start() Func Start() Function1() Function2() Function3() EndFunc Func Function1() Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ExitLoop EndIf WEnd EndFunc Func Function2() Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ExitLoop EndIf WEnd EndFunc Func Function3() Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ExitLoop EndIf WEnd EndFunc But when I add a GUI window and start this script with a button, it fires all at once and does not wait. expandcollapse popupWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $StartButton Start() Case $StopButton Exit EndSwitch WEnd Func Start() Function1() Function2() Function3() EndFunc Func Function1() Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ExitLoop EndIf WEnd EndFunc Func Function2() Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ExitLoop EndIf WEnd EndFunc Func Function3() Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ExitLoop EndIf WEnd EndFunc How can I get the GUI to act the same way as just running it on the page? Thanks! Link to comment Share on other sites More sharing options...
Nine Posted February 24, 2021 Share Posted February 24, 2021 You can not have a loop inside a GUI loop. You will have to gather everything inside a single loop. OR use GUI event instead of GUI loop. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
JockoDundee Posted February 24, 2021 Share Posted February 24, 2021 10 hours ago, Zathus said: How can I get the GUI to act the same way as just running it on the page? try this: Func Start() Function1() Sleep(50) Function2() Sleep(50) Function3() EndFunc reason is because _IsPressed doesn’t actually detect mouse clicks, it just says whether the mouse button is down at any given instant. most likely, it’s still returning true when it gets to function 2. Why it doesn’t do this in your original script, I’m not sure. Maybe you clicked quicker then... Code hard, but don’t hard code... 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