Christofer_Minestar Posted May 18, 2018 Share Posted May 18, 2018 Hi, new here. So I have tried WinClose, WinKill and ProcessClose with no avail, with ACTIVE, TITLE and CLASS, but can't get it to work. Also, the red X button does not work, to end script I need to kill it in Task Manager, and that's what the button is supposed to do. Code: expandcollapse popup#cs ---------------------------------------------------------------------------- Info: This is meant to repeat a set of keystrokes every {set} millisecond. {TAB} and others listed here: https://www.autohotkey.com/docs/Hotkeys.htm are supported AutoIt Version: 3.3.0.0 Discord: @Christofer // BeyondProjects#6955 #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> GUICreate("KRv4", 335, 75) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Key(s)", 20, 10) $key1 = GUICtrlCreateInput("", 80, 8, 160) GUICtrlCreateLabel("Time (ms)", 20, 44) $time1 = GUICtrlCreateInput("", 80, 40, 160) $startbutton = GUICtrlCreateButton("Start", 250, 7, 60) $endbutton = GUICtrlCreateButton("End", 250, 39, 60) While 1 $msg = GUIGetMsg() Select Case $msg = $startbutton $send1 = GUICtrlRead($key1) $sleep1 = GUICtrlRead($time1) While 1 Send($send1) Sleep($sleep1) WEnd Case $msg = $endbutton WinClose("[ACTIVE]", "") EndSelect WEnd $timer = TimerInit() KRv4.au3 Link to comment Share on other sites More sharing options...
Christofer_Minestar Posted May 18, 2018 Author Share Posted May 18, 2018 Forgot to say: The button that I'm trying to get to close the script is Quote $endbutton Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 18, 2018 Moderators Share Posted May 18, 2018 @Christofer_Minestar welcome to the forum. First, to close the script, for $endButton, just ExitLoop. Case $msg = $endbutton ExitLoop Second, this will work just fine until you hit the other button. As soon as you hit $startbutton you are creating an infinite While loop. While 1 Send($send1) Sleep($sleep1) WEnd Since this loop never ends, your click of the $endbutton is obviously never going to be recognized. Lastly, it appears that you are porting this script from AHK. Please ensure you read our forum rules before continuing; unlike that forum we do not tolerate any game automation scripts (which a lot of 'click random buttons x number of times' scripts turn out to be for). Do not be surprised if, in the course of assisting you with your script, you aren't asked to explain why you need to send so many button presses, as there is almost always a better way to accomplish a legitimate script. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Christofer_Minestar Posted May 18, 2018 Author Share Posted May 18, 2018 19 hours ago, JLogan3o13 said: First, to close the script, for $endButton, just ExitLoop. Case $msg = $endbutton ExitLoop Second, this will work just fine until you hit the other button. As soon as you hit $startbutton you are creating an infinite While loop. While 1 Send($send1) Sleep($sleep1) WEnd Thanks! I'll try to find a better way to do this. Quote Lastly, it appears that you are porting this script from AHK. I am not porting this from AKH, the link I put there is just because it supports AHK-like modifiers and keys Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 18, 2018 Moderators Share Posted May 18, 2018 2 minutes ago, Christofer_Minestar said: I am not porting this from AKH, the link I put there is just because it supports AHK-like modifiers and keys Glad to hear. The friendly reminder about the forum rules still applies. Aside from that, hope you are successful in what you're trying to do "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Christofer_Minestar Posted May 18, 2018 Author Share Posted May 18, 2018 Some progress: End button still works after using start button, but actual function of the key repeat is gone now, ah well. Keep trying I guess. New code: expandcollapse popup#cs ---------------------------------------------------------------------------- Key Repeat version 4 Info: This is meant to repeat a set of keystrokes every {set} millisecond. {TAB} and others are supported, listed here: https://www.autohotkey.com/docs/Hotkeys.htm AutoIt Version: 3.3.0.0 Discord: @Christofer // BeyondProjects#6955 #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> GUICreate("Key Repeat 4", 335, 75) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Key(s)", 20, 10) $key1 = GUICtrlCreateInput("", 80, 8, 160) GUICtrlCreateLabel("Time (ms)", 20, 44) $time1 = GUICtrlCreateInput("", 80, 40, 160) $startbutton = GUICtrlCreateButton("Start", 250, 7, 60) $endbutton = GUICtrlCreateButton("End", 250, 39, 60) While 1 $msg = GUIGetMsg() Select Case $msg = $startbutton $send1 = GUICtrlRead($key1) $sleep1 = GUICtrlRead($time1) While 1 Send($send1) Sleep($sleep1) ExitLoop WEnd Case $msg = $endbutton ExitLoop WinClose("[ACTIVE]", "") EndSelect WEnd $timer = TimerInit() Link to comment Share on other sites More sharing options...
LarsJ Posted May 19, 2018 Share Posted May 19, 2018 With the code in first post you can do it this way: expandcollapse popup#cs ---------------------------------------------------------------------------- Info: This is meant to repeat a set of keystrokes every {set} millisecond. {TAB} and others listed here: https://www.autohotkey.com/docs/Hotkeys.htm are supported AutoIt Version: 3.3.0.0 Discord: @Christofer // BeyondProjects#6955 #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <MenuConstants.au3> $hGui = GUICreate("KRv4", 335, 75) GUIRegisterMsg( $WM_COMMAND, "WM_COMMAND" ) GUIRegisterMsg( $WM_SYSCOMMAND, "WM_SYSCOMMAND" ) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Key(s)", 20, 10) $key1 = GUICtrlCreateInput("", 80, 8, 160) GUICtrlCreateLabel("Time (ms)", 20, 44) $time1 = GUICtrlCreateInput("", 80, 40, 160) $startbutton = GUICtrlCreateButton("Start", 250, 7, 60) $endbutton = GUICtrlCreateButton("End", 250, 39, 60) While 1 Switch GUIGetMsg() Case $startbutton $send1 = GUICtrlRead($key1) $sleep1 = GUICtrlRead($time1) While 1 Send($send1) Sleep($sleep1) WEnd EndSwitch WEnd Func WM_COMMAND( $hWnd, $iMsg, $wParam, $lParam ) Switch BitAND( $wParam, 0xFFFF ) ; LoWord Case $endbutton Switch BitShift( $wParam, 16 ) ; HiWord Case $BN_CLICKED Exit EndSwitch EndSwitch EndFunc Func WM_SYSCOMMAND( $hWnd, $iMsg, $wParam, $lParam ) Switch $hWnd Case $hGui Switch $wParam Case $SC_CLOSE Exit EndSwitch EndSwitch EndFunc The Autoit message loop is blocked, but not Windows. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Christofer_Minestar Posted May 19, 2018 Author Share Posted May 19, 2018 6 hours ago, LarsJ said: With the code in first post you can do it this way: The Autoit message loop is blocked, but not Windows. Wow, thanks! That's much cleaner. The reason I'm doing this is because my friend challenged me to revive and improve one of my old projects, and back when i made this I had very little AutoIt experience. I don't have time now but I will try the code later, thanks! 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