I'd like to start two Terminals and put them at specific positions on my screen. I know how to do this with one Terminal but what do I have to do to open a second Terminal and position it next to the first one?
Here is the code for one Terminal:
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "2", function()
hs.application.launchOrFocus("Terminal")
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = 960
f.h = 540
win:setFrame(f)
end)
So this potentially gets quite complex, but what I would do is have the hotkey check to see if Terminal is already running. If not, launch it and put it in position 1. If it is already running, focus it, activate the menu item to open a new window, and put it in position 2.
I'd like to download GTA V for PC. The download is extremely slow (40kb/s), but when you click pause and then start it again downloads with 5,5mb/s for 1 minute.
I want to write a script for it in AutoIt.
But how i can focus the window AND work on in the foreground.
The window info of the download manager (mouse pointed at the button)
http://i.imgur.com/ckBudsO.png
My script looks like this at the moment:
While 1
; Here, the focus has to go, right?
MouseClick ( "primary" [, 637, 460 [, clicks = 1 [, speed = 0]]] )
Sleep(1000)
MouseClick ( "primary" [, 637, 460 [, clicks = 1 [, speed = 0]]] )
Sleep(60000)
WEnd
Ensure that you got right coords from Autoit Window Info screenshot
Try to use WinActivate() and ControlClick() (in that choice the mouse is not used) :
Opt("MouseCoordMode",2)
While 1
$hwnd = WinActivate('Launcher')
MouseClick ( "primary",637 ,460) ; with mouse coords
Sleep(1000)
ControlClick ( $hwnd, "", "[CLASS:AfxWnd110su; INSTANCE:2]") ;... and without mouse
Sleep(60000)
WinSetState ( $hwnd, "", #SW_MINIMIZE ); Minimaze the Launcher
WEnd
I have a script for entering records in our system that was originally working fine with a MsgBox, but I added a GUI to show the record entry. Now the script stops after the first record.
In the example below I've stripped out all of the actions and record lines to help make this easier to parse, but I've kept in all the important stuff and tested this version of the script.
Loop, read, C:\_AutoHotKey\AA_test.txt
{
StringSplit, LineArray, A_LoopReadLine, %A_Tab%
aaduedate := LineArray1
aauniqueid := LineArray2
aaprefix := LineArray3
aasequence := LineArray4
aadescript := LineArray5
aaelig := LineArray6
;-------------------------------------------------------------------------------------
;Use these to test the file match in the Input File.
;Remove surrounding comments and surround the rest of the script up to the last brace.
SendInput, Prefix: %aaprefix% {enter}
SendInput, Sequence: %aasequence% {enter}
SendInput, Description: %aadescript% {enter}
SendInput, Eligibility: %aaelig% {enter}
SendInput, ID Card: %aaidcard% {enter}
;---------------------------------------------------------------------------------------
;Pop-up validation menu
Gui, Add, Button, x22 y380 w100 h30 , &Submit
Gui, Add, Button, x362 y380 w100 h30 , &Cancel
Gui, Font, S14 CDefault, Verdana
Gui, Add, Text, x152 y10 w210 h30 +Center, Is the entry correct?
Gui, Font, S10 CDefault, Verdana
Gui, Add, Text, x102 y40 w90 h20 , %aaprefix%
Gui, Add, Text, x102 y70 w130 h20 , %aaelig%
Gui, Add, Text, x312 y70 w30 h20 , %aadescript%
Gui, Add, Text, x432 y70 w30 h20 , %aaidcard%
Gui, Font, S8 CDefault, Verdana
Gui, Add, Text, x132 y380 w230 h40 +Center, Click Submit/press S to continue. Click cancel to stop script.
; Generated using SmartGUI Creator 4.0
Gui, Show, x9 y250 h428 w480, Auto Action Validation
Return
ButtonCancel:
ExitApp
ButtonSubmit:
Gui, Submit ;
MouseMove, 630,55
Sleep, 100
SendInput, {Click 630,55}
SendInput ^S
Return
}
The buttons do work and clicking Submit will send the MouseMove and SendInput. But after that it just stops and doesn't load the next record in the text file.
Thanks in advance!
You have a return command within the loop.
This exits the program
See this example.
This loop should run 5 times, but the return
command stops it after the first run.
Loop, 5
{
msgbox, %A_Index%
return
}
I was able to get this to work by removing the submit button from the GUI and moving it to a MsgBox.
The GUI is basically the same but the Submit and Cancel lines have been removed along with the returns and all logic following it.
Next, a MsgBox was added to confirm the data. This now uses the GUI to display the contents of the record and the MsgBox to confirm and move on to the next record.
Also, there's some code I stole (and don't really understand) that moves the MsgBox so that it doesn't block the data entry screen in the receiving app.
Here's the new code that replaces everything after Gui, Show, x9...
OnMessage(0x44, "WM_COMMNOTIFY")
MsgBox 4, AA Entry, Would you like to continue? (press Yes or No)
WM_COMMNOTIFY(wParam) {
if (wParam = 1027) { ; AHK_DIALOG
Process, Exist
DetectHiddenWindows, On
if WinExist("ahk_class #32770 ahk_pid " . ErrorLevel) {
WinGetPos,,, w
WinMove, 90, 650
}
}
}
;If the user responds yes, then close the Gui (Destroy) and enter the record
IfMsgBox Yes
{
Gui destroy
Sleep, 100
}
else
ExitApp
}
Thanks, and I hope this is helpful to someone.
I am trying to learn Corona in order to make a 'virtual pet' sort of game. When an Item such as an apple is left on the floor for like 15 seconds I want to attempt to delete and re spawn the item.
You do not want a collision event after a certain time...
You want to check if a object is standing still after 15 seconds!
Just add a enterFrame event to your Runtime.
Then you check for every object if the position changed and set a variable on the object, something like:
if myObject.x ~= myObject.lastX and myObject.y ~= myObject.lastY then
myObject.timeSinceLastMovement = event.time
end
myObject.lastX = myObject.x
myObject.lastY = myObject.y
event.time in a enterFrame usually tracks the time since the app started in miliseconds.
Then you check if some object is stopped for 15 seconds.
if myObject.timeSinceLastMovement + 15000 < event.time then
-- code to respawn myObject go here
end
I want to open a folder, and select a file by default.
I do it like this:
Declare Long WinExec In kernel32 String #, Integer
WinExec("Explorer /select, C:\tt.txt",5)
But if the folder has been opened, the file can't be selected by default.
How to do it?
What is your purpose of prompting a user with picking a particular file...
The closest you can get from wthin VFP is "GetFile()" where you can give it a default extension of a file you are hoping to find and it brings up a file selection dialog.
lcFileSelected = GetFile( "Txt", "Caption left of combobox selection (but only shows about 16 chars)", "Button Caption", nOptionalButton )
where ex:
nOptionalButton
0 = no extra button at bottom right, just the OK, Cancel (where OK is overridden by the "Button Caption" sample above.
1 = OK, New, Cancel
2 = Ok, None, Cancel
If a value selected, you'll have the file name, otherwise blank.
REVISED ANSWER..
Then what you want is PUTFILE() which allows you to prompt a user a simple message, similar to a "Save to", and allows to put a fully qualified path and file name. Upon return, much like that of doing GETFILE() will return the final path/file name entered by the user. Ex:
lcUserAnswer = PUTFILE( "save where", "C:\program files\myTest.txt" )
now you can do whatever with the "lcUserAnswer" variable...