
iAmNewbe
Active Members-
Posts
212 -
Joined
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by iAmNewbe
-
Another option with the Program delay is to create a Pause feature where you can manually pause the loop and then restart it when you are ready. OR.. just close the program then restart it when you are ready. An option for the Pause feature is to use a variable switch and set it to True or False based on where you clicked to Pause or Start the program. I use a Tray Menu Item and set the label to change for Pause or Start. Then in the While Loop you already have you can either enclose the Switch in an If statement or set a new Case in the Switch and set an outside the Loop variable and check it. If $toggle = "Start" or something like that. Then set $toggle or whatever variable name to Pause to bypass the Switch. There are different ways to do it but that is one option.
-
You want to add a Sleep statement at the end of your While loop to reduce the CPU usage your program is currently using. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $READ READ_VALUE() EndSwitch Sleep(10) ; Added to eliminate unnecessary CPU usage WEnd The quickest solution for your program delay is to just change the Sleep statement at the beginning of the Read_Value() function to 5 minutes. Sleep uses Milliseconds so 1000 MS is equal to 1 second. 60000 MS is equivalent to 1 minute.
-
When playing sound you have to close the handle after it is done playing or the sound is stopped. If you do not do this, I have ran into an issue especially if you run multiple copies of the application at once where all sound on the computer stops playing. I use SoundPlay instead of _SoundPlay because you can close the handle and stop the sound with one line SoundPlay("") Something to take into consideration with playing sound that unless you close the handle to currently playing sound, even if you stop it, you could run into no sound at all and you have to reboot to get it back.
-
I have several wireless mouses that the primary left click button seems to become defective and produce multiple left clicks when pressed. Not sure why but this seems to begin happening after 3 to 4 months and I got tired of buying a new mouse so I delved into the AutoIT manual and wrote with borrowing from the manual the following code that temporarily disables input once the left mouse button is clicked to prevent false double and single clicks from registering. #RequireAdmin #Region ; Includes #include <AutoItConstants.au3> #include <Misc.au3> #include <WinAPI.au3> #EndRegion #Region ; Tray Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown. Opt("TrayOnEventMode", 1) TraySetClick(16) ; Release Right Mouse Button Show Tray Menu TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "Terminate") TraySetToolTip("Mouse Click Delay") #EndRegion Global $hDLL = DllOpen("user32.dll") While 1 If (_IsPressed("1", $hDLL)) Then While _IsPressed("1", $hDLL) Sleep(10) WEnd BlockInput(1) Sleep(240) ; Amount of Delay between disabling and re-enabling input BlockInput(0) EndIf Sleep(10) WEnd Func Terminate() DllClose($hDLL) Exit 0 EndFunc I played around with the sleep times to get what seems to work with very little hassle in usability. There is a minor noticeable delay between pressing the left click button and before being able to move the mouse but anything less and multiple left clicks get registered. I can now use the collection of mouses that have this issue again. It would be better if there was a way to disable just the mouse but BlockInput is the only thing available. I tried setting the MouseclickDelay and also the MouseClickDownDelay Options but they did not work for this issue and the BlockInput did.
-
[Solved] Help with Inactivity Application
iAmNewbe replied to Rhys_A's topic in AutoIt General Help and Support
@Nine your update above is more inline with what the OP describes. The first version of your code just exited once the window was closed and there was no way for any further checks to occur. I took a stab at this and made a few changes to @Nines code. is equal to TRUE, so for readability I changed this to $BooleanMessageDisplayed = TRUE , below. While True WinWait("BoxTop Advantage"); wait till application is back If _Timer_GetIdleTime() >= $WarningMessageTime Then If $BooleanMessageDisplayed = TRUE Then $BooleanMessageDisplayed = FALSE MessageBoxTimeOut() EndIf Endif If _Timer_GetIdleTime() >= $InactivityTime Then CloseBoxTop() Sleep (10) ; reduce CPU impact WEnd You can add a timeout to WinWait if you want, the script is essentially locked until the window reappears in this code snippit otherwise. I don't like using NOT especially with booleans, just write it out in plain as possible language will remove confusion. -
[Solved] Help with Inactivity Application
iAmNewbe replied to Rhys_A's topic in AutoIt General Help and Support
Remove the ExitLoop after CloseBoxTop() This will keep the While Loop running and your application will not exit after CloseBoxTop() runs -
Loop causing non-working controls in Application
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
The problem is that it stops while the mouse button, primary, is held down. I do not want it to stop at all. If you add a time begin, when the count was started and a time stop when the count terminated the time does not match the counter. This is an example of a use case where you do not want the script to pause. Yes, once the button is released the count continues. It should not stop at all though. -
Loop causing non-working controls in Application
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Ran into an issue where if you drag the window or mouse click and hold the title bar the script pauses which throws the counter off. Is there a way to keep the script running while the window is being moved around? -
Loop causing non-working controls in Application
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Yes, I understand. I changed my code to reflect this and it works, thank you. I had forgotten about that operator thing with AutoIt. I do not use it an a daily basis and every other language I use does not have that. Thanks for reminding me. I appreciate your help, you helped solve my problem. -
Loop causing non-working controls in Application
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
So the solution is to not start the second loop via the event of the button press and instead set flags? I think I ran into this before in a different scenerio.. Weird. I do have a question about the use of Shouldn't this be a comparison operator instead of an assignment? I see that it works the same both ways, when changing the code but I don't understand this. Have seen it with loop examples in the documentation also, I thought that this would create never ending loops forever assigning to the variable being checked? -
Loop causing non-working controls in Application
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
I am trying to understand how to make a loop that iterates counters and displays the count live in application while keeping functionality of buttons, modals, events etc... -
Loop causing non-working controls in Application
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
The issue is that once the Loop inside displayLoop starts all events, buttons stop working. ContinueLoop would only come into play when their is a condition that when met the rest of the code is needed to be bypassed for that iteration of the loop. In my use case and way the application is currently written, this is not something that fits with the existing code. -
AutoIT Versions: 3.3.14.5 & 3.3.14.2 Once the Counter Button is pressed all events stop working. I understand the issue is the loop inside displayLoop Function prevents the inital event from stopping and new events from occuring. Not sure how to make this application work without the loop inside displayLoop function. Originally I used images to display the counter numbers but since you do not have access to that I changed the code to display text numbers. Trying to create a Timer Counter eventually for time management. How do I make the counter count without the loop or does it need to be somewhere else? In another thread Jos said to look at this for help --> https://www.autoitscript.com/wiki/Managing_Multiple_GUIs Though in my use case I do not understand. My Code Below --------------------------- #include <GUIConstantsEx.au3> #include <Array.au3> #include <FontConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode HotKeySet("{ESC}", "endApp") Global $title = "A Little Counter Application" Global $stopLoop = "No" Global $imageNumbers[11] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":"] Global $theApplication = GUICreate($title, 300, 200, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "endApp") Global $btnStartDisplayLoop = GUICtrlCreateButton("Start Count", 90, 120, 100, 30) GUICtrlSetOnEvent($btnStartDisplayLoop, "btnPress") GUISetFont(24, $FW_NORMAL, $GUI_FONTNORMAL, "Arial") Global $imgMIN1 = GUICtrlCreateLabel($imageNumbers[0], 50, 50) Global $imgMIN2 = GUICtrlCreateLabel($imageNumbers[0], 100, 50) Global $spacer = GUICtrlCreateLabel($imageNumbers[10], 150, 50) Global $imgSEC1 = GUICtrlCreateLabel($imageNumbers[0], 200, 50) Global $imgSEC2 = GUICtrlCreateLabel($imageNumbers[0], 250, 50) GUISetState(@SW_SHOW, $theApplication) Func displayLoop($duration = 5) Dim $stopLoop, $min, $sec While 1 if $stopLoop == "Yes" Then ExitLoop If $min == $duration Then ExitLoop EndIf $sec = $sec + 1 If($sec == 60) Then $min = $min + 1 $sec = 0 EndIf $mins = returnArray($min) GUICtrlSetData($imgMIN1, $imageNumbers[$mins[1]]) GUICtrlSetData($imgMIN2, $imageNumbers[$mins[2]]) $secs = returnArray($sec) GUICtrlSetData($imgSEC1, $imageNumbers[$secs[1]]) GUICtrlSetData($imgSEC2, $imageNumbers[$secs[2]]) Sleep(1000) WEnd MsgBox(0,"","Counter Stopped") EndFunc Func returnArray($number) Local $newArray[3] if $number = "" Then $number = 0 Local $numberArray = StringSplit($number, "") If($numberArray[0] == 1) Then $newArray[0] = 2 $newArray[1] = 0 $newArray[2] = $numberArray[1] $numberArray = $newArray EndIf return $numberArray EndFunc Func btnPress() Dim $stopLoop $getBtnText = GUICtrlRead($btnStartDisplayLoop, $GUI_READ_EXTENDED) If $getBtnText == "Start Count" Then GUICtrlSetData($btnStartDisplayLoop, "Stop Count") $stopLoop = "No" displayLoop() ; Starts Display Loop ElseIf $getBtnText == "Stop Count" Then GUICtrlSetData($btnStartDisplayLoop, "Start Count") $stopLoop = "Yes" EndIf EndFunc Func endApp() Local $exitCode = MsgBox(68,'',"Are you sure you want to quit?") If($exitCode == 6) Then GUIDelete($theApplication) Exit EndIf EndFunc While 1 ;~ Keep Application Running WEnd Once button is initially pressed it does not respond and the close modal button does not work. The hotkey {ESC} does work. I am lost at how to make this work, please help.
-
Open an exe after opening a webpage
iAmNewbe replied to 6401integramandj's topic in AutoIt General Help and Support
I am not sure that will work @water There are two pages the initial one opened with the instance then the user logins and another page loads. I am not sure how you grab the second page. What you have there may work but wouldn't it be better to check when the page reloads instead of forever looping grabbing the page, wouldn't that use up a lot of resources? OR get the IP banned for too many connections, spamming the server? -
Open an exe after opening a webpage
iAmNewbe replied to 6401integramandj's topic in AutoIt General Help and Support
If that is the entire code you have, there is no looping structure to grab the page again, it is only doing it once. It also will just keep retrieving "https://WebSite.com/accounts/service-login#." The only way that I know of to do this is to create your own custom browser application with AutoIt unless you can grab the current page from an existing IE instance which I am not sure how to do. Anything like what you are trying to do that I have seen work uses custom browser plugins that allow the plugin and the exe to talk to each other. Since you initiated the IE instance you should have the handle id which you can use to target that specific IE instance. -
Left vs Right shifting keys & HotKeySet
iAmNewbe replied to SQLDave's topic in AutoIt General Help and Support
Look at the options under "Send" for the L and R CTRL key. You may have better luck specifically targeting each CTRL key separately. -
Long story short -1 centers GUI 0 Paces GUI on left edge of desktop I do not understand -1 result with GUI placement.
-
Discrepancy between first post and post #3 In Post 1 (@DesktopWidth - $Left) when $Left is 1920 which after calculation result is ZERO I said position of GUI is one pixel off from Left side of desktop. Then When removal of @DesktopWidth and just place the numeric 0 then the GUI touches the Left side of the desktop. Both are same numerically. When testing again with both of these options I get the equal result of the GUI window left edge touching the left edge of the desktop. I do NOT know why I got a different result the first time around. I am pulling the $Left variable or integer from an ini file setting. For some reason I can not pass @DesktopWidth or other @ constants via ini file it just does not work so I have to hard code these constants / directives into the code and just pass the numeric number through. Which I believe are strings when doing it this way and not integers. I am not sure why -1 does not work but I will just use the 0 for LEFT option for positioning horizontally where I want via subtracting the desktop width by itself to get zero.
-
Further Investigation --------------------------------------------------- Two Monitors, Left Monitor and Right Monitor @DesktopWidth = 1920 GUICreate(TITLE, WIDTH, HEIGHT, LEFT, TOP, STYLE, EXSTYLE, PARENT) LEFT Option of GUICreate contains ----------------------------------------------- (@DesktopWidth - 1920) Result Numerical 0 AND Positions to Left side of Left Monitor (@DesktopWidth - 0) Result Numerical 1920 AND Positions to Left side of Right Monitor (@DesktopWidth - 1921) Result Numerical -1 AND Positions to Center of Left Monitor (@DesktopWidth - -1) Result Numerical 1921 AND Positions to close to Left Edge of Right Monitor (gaps between edges of GUI Window and Right Monitor) 0 <== Left Side of Left Monitor -1 <== Centers on Left Monitor -2 <== Left Edge of GUI is past Left Edge of Desktop out of sight --------------------------------------------- It seems the issue is when -1 is used in the spacing of the Left Option for GUICreate. For me in this situation if I just use 0 without @DesktopWidth calc then it positions how I want on the left edge of the left monitor / desktop.
-
GUICreate("",350,60,(@DesktopWidth - $Left),(@DesktopHeight - $Top),$WS_POPUP+$WS_BORDER) ; title, width, height, left, top, This is the specific line for creating and positioning the Gui Window. $Left = 1921 so (@DesktopWidth - 1921) <== PROBLEM occurs
-
I have two 27" Monitors in Dual setup. I created the following code in another thread due to not able to get TrayTips to work how I need. It creates a popup window via GUICreate. I have discovered an odd quirk that I am not sure why it is happening. If you do not have these same sized monitors then you will not be able to see the problem if you run the code as is. Using the code below I am moving the created popup window to various areas of my desktop. Trying to get it to hug the left side of the left monitor or specifically the desktop, a certain number "1921" will center the window instead. ----------------------------------------------------------------------------------------------- There is a boundary border around the GUI window. $Left = 1920 <== The left side of the GUI Window and the left side of the desktop there is a one pixel space between them $Left = 1921 <== The left side of the GUI Window and the left side of the monitor are SUPPOSE to Hug, no gaps Instead this centers the window on the left monitor $Left = 1922 <== The left side edge of the gui window is just over the desktop left edge out of sight, can't see the white left border. #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <ColorConstants.au3> $Left = 1920 $Top = 150 Notice("Left Edge","Left Monitor - Left Edge",4,1,$Left,$Top) ; -- BUG -- $Left = 1921 ; <-- 1921 puts gui window center of screen - Left Monitor WHY? $Top = 150 Notice("Funky Position","Moves to center of left monitor",4,2,$Left,$Top) ; -- END BUG -- $Left = 1922 $Top = 150 Notice("Past Left Edge","Moves Left of Left Edge - Left Monitor",4,1,$Left,$Top) Func Notice($message, $description, $timeout = 2, $icon=0,$Left=352,$Top=120) Local $iconArray[4] = ["", "16783", "161", "240" ] Local $popup = GUICreate("",350,60,(@DesktopWidth - $Left),(@DesktopHeight - $Top),$WS_POPUP+$WS_BORDER) ; title, width, height, left, top, style, exStyle, parent GUICtrlSetDefColor(0xFFFFFF) GUISetBkColor(0x1F1F1F) if($icon > 3) Then $icon = 0 if($timeout < 1) Then $timeout = 2 $timeout = $timeout * 1000 if($icon > 0) Then GUICtrlCreateIcon("shell32.dll", $iconArray[$icon], 10, 7,43,43) ; filename, iconName, left, top, width, height, style, exstyle $theMessage = GUICtrlCreateLabel($message,65, 10, 300, 30) ; text, left, top, width, height, style, ex style GUICtrlSetFont(-1, 12, 600, 0, "", 2) ; size, weight, attribute ( 2 = italic, 4 = underline, 8 = strike ), fontname, quality $theDescription = GUICtrlCreateLabel($description, 65, 32, 300, 30) GUICtrlSetFont(-1, 9, 100, 0,"",2) ; GUICtrlSetColor(-1, 0xACAEAC) GUISetState(@SW_SHOW, $popup) Sleep($timeout) GUIDelete($popup) EndFunc Is there something I am doing wrong in my code or is this a bug? Why does the code above when 1921 is entered into the LEFT option for GUICreate position does it dramatically alter the gui window position?
-
Possible to map a programmable keyboards macro keys?
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
If there are codes being sent then there has to be a way to retrieve that information without decompiling anything. The other possibility is that they are blank and the software that comes with the keyboard programs these keys and what is returned is the recorded macro key combinations. If that is the case then there really isn't much I can think of that can be done. -
Possible to map a programmable keyboards macro keys?
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
I can not find the website for this program there seems to be multiple versions around which none of them I would want to come near my windows 10 computer at all. I can assign a macro of keys to each programmable key via the software that came with the keyboard but not something like A1.. it would be A then the number 1. I maybe able to create a combination like this for each key that I maybe able to capture with Autoit, will have to experiment and it would mean I would not be able to use the software that came with the keyboard again after this or it would erase the key assignments. Will have to experiment. -
Possible to map a programmable keyboards macro keys?
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
Autoit keyboard polling code writing keys pressed to console. Since you do not seem to understand here is a copy past of one of the programs directly from the manual. There are others, this is just one example. #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()')) GUIRegisterMsg($WM_KEYDOWN, 'WM_KEYDOWN') GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_KEYDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ConsoleWrite(_WinAPI_GetKeyNameText($lParam) & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_KEYDOWN There does not seem to be a way to retrieve the unassigned keys from Autoit, which means I can not get an id to assign anything to or trigger an action when one of the keys are pressed. This is what I want to do. -
Possible to map a programmable keyboards macro keys?
iAmNewbe replied to iAmNewbe's topic in AutoIt General Help and Support
I don't know, there are a lot of functions to do just that in Autoit, mouse and keyboard.