How to click and edit text fields in apps? - automation

I need in Davinci Resolve to select in the inspector window the zoom text field using the Acc library:
I used Accessible Info Viewer to find identifying properties but hit a wall trying to selecting the text field and double clicking it to replace its value.
Code:
#+j::
WinGet, hWnd, ID, A
vAcc := Acc_Get("Object", "4.2.2.1.1.2.4.1.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.2.1", 0, "ahk_id" hWnd)
%vAcc%.accDoDefaultAction(0)
return
How to enter a new value in the zoom box? Manually, you double click it and enter a value. I have a script that does this with SendInput but want to without needing panels to be in specific positions prior to activating the hotkey.

Use UIAutomation instead. It is the successor to the Acc/MSAA framework.
Here is the example1 code
#NoEnv
#SingleInstance force
SetTitleMatchMode, 2
;#include <UIA_Interface> ; Uncomment if you have moved UIA_Interface.ahk to your main Lib folder
#include ..\Lib\UIA_Interface.ahk
Run, notepad.exe
UIA := UIA_Interface() ; Initialize UIA interface
WinWaitActive, ahk_exe notepad.exe
npEl := UIA.ElementFromHandle("ahk_exe notepad.exe") ; Get the element for the Notepad window
documentEl := npEl.FindFirstByType("Document") ; Find the first Document control (in Notepad there is only one). This assumes the user is running a relatively recent Windows and UIA interface version 2+ is available. In UIA interface v1 this control was Edit, so an alternative option instead of "Document" would be "UIA.__Version > 1 ? "Document" : "Edit""
documentEl.Highlight() ; Highlight the found element
documentEl.Value := "Lorem ipsum" ; Set the value for the document control.
; Equivalent ways of setting the value:
; documentEl.CurrentValue := "Lorem ipsum"
; documentEl.SetValue("Lorem ipsum")
ExitApp
Use some find methods (FindFirstByName, FindFirstByType, ...) to get the element you want to click, and then call element.Click().
UIAutomation
Github wiki

Related

How can I change the program header in sap abap?

I want to change the header name of the ABAP program. What can I do or where can I find the option to edit the header?
Two ways for this:
Set it in program options. Select the program and check menu Goto / Attributes.
Or you can create a GUI title and set it via ABAP. This overwrites attributes' setting.
More about how to achieve: here.
To change the program header is more easier than it seems.
Just open you program via SE38 -> Goto -> Properties -> Check the title field and change -> Save
And you are done. :)
I have this.
Usually is changing the name in atributes with transaction se38, but sometimes this don't work, you need in the transaction se80, create a title GUI, if yuou don't have a title created, righ clic in the program name, create -> GUI title.
And put your name and code.
and in your program (se38) in PBO, you have to call the title with
SET TITLEBAR '100' (Put your title code)
(100 is the title code), but this instruction have to need inside of a moodle, if is outside don't will work.
I use the first moodle that i have in my PBO (i don't know if is the best decition or the right form, but is a way and works).
finally the title change
The path is SE38 -> (Put Program Name) -> Now open the program in edit mode -> Select the option GOTO -> select Properties Change the program title.

applescript getInputByClass2 with Safari 10.1

My Applescripts I used to run everyday to get text from Safari isn't working since my last system update
It used to work only in Safari, and not in Safari Preview, I guess the system for Safari Preview was bring to safari now/
tell application "Safari"
set DinfoGrab to do JavaScript "
document.getElementsByClassName(' field type-string field-Dinfo ')[0].innerHTML;" in tab 3 of window 1
end tell
with this error :
Safari got an error: Can’t make " document.getElementsByClassName('
field type-string field-Dinfo ')[0].innerHTML;" into type text.
how can I fix that? thanks.
UPDATE :
Here is something working perfectly with Chrome :
tell application "Google Chrome"
tell tab 3 of window 1 to set r to execute javascript "document.getElementsByClassName('field type-string field-Dinfo')[0].innerHTML;"
end tell
Without seeing the complete code, I can't say for sure what's going on. But judging by the name of your function -- getInputByClass2 -- I assume you're trying to get the value of HTML <input> fields. If this is true, you should be using outPut.push(arr[i].value) instead of outPut.push(arr[i].innerHTML)
As for the second bit of code, your JavaScript doesn't have any error handling in case the value of document.getElementsByClassName(' field type-string field-Dinfo ')[0] is null.
var els = document.getElementsByClassName(' field type-string field-Dinfo ');
//set to value of [0].innerHTML if [0] exists, else empty string
var html = els.length ? els[0].innerHTML : "";
//return value to AppleScript
html;
update (response to updated question)
Running the following script in Script Editor against this StackOverflow page will return the correct value (assuming you have the correct window/tab numbers set). If the search field at the top of this StackOverflow page is empty, you will get an empty string. If you enter a term (but don't submit) then run the AppleScript, you will get the value of the field.
tell application "Safari"
set DinfoGrab to do JavaScript "
document.getElementsByClassName('js-search-field')[0].value;" in tab 1 of window 1
end tell
The only changes from your script are the window/tab numbers, the classname (changed to match the StackOverflow page), and I used value instead of innerHTML.
I have tested in the most current version of Safari (10.0.3); if this doesn't work in your version of Safari, ensure you're pointing to the correct class name. If this script DOES work for you, then the issue is probably due to something on the page you're trying to search, perhaps related to the type of <input> field you're fetching or an incorrect classname. Maybe the update to Safari is causing the page to render differently, which indirectly affects your code.

How to Use GuiDropFiles with GUI controls?

How can I use GuiDropFiles with GUI controls?
I have several edit fields in my form, and I want to be able to drop files onto them separately and work with them.
This is what I came up with:
First, my controls are set up like this:
WS_EX_ACCEPTFILES=0x10
Gui, add, edit, vedit1, %file_1%
WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1
And my drag-drop routine is as such:
GuiDropFiles: ; Support drag & drop.
Loop, parse, A_GuiControlEvent, `n
{
thisfile := a_loopfield ; Get the first file only (in case there's more than one).
thiscontrol := a_guicontrol
break
}
alert(thisfile . "`r" . thiscontrol)
if(thiscontrol = edit1)
guicontrol,,%edit1%, %thisfile%
if(thiscontrol = edit2)
guicontrol,,%edit2%, %thisfile%
if(thiscontrol = edit3)
guicontrol,,%edit3%, %thisfile%
return
I am using the basic example from the autohotkey documentation. I also tried the example from here, but it keep saying, "not dropped on an edit box".
Any clue would be great.
Figured it out (after a few lost hours).
First, I didn't need this: WinSet,ExStyle, +WS_EX_ACCEPTFILES, edit1
and I didn't need to set any styles on the edit controls.
All I needed was this, which works since my edit controls have the variable-name starting with "UI_file":
GuiDropFiles: ; Support drag & drop.
Loop, parse, A_GuiEvent, `n
{
thisfile := A_LoopField ; Get the first file only (in case there's more than one).
thiscontrol := a_guicontrol
break
}
;alert(thisfile . "`r" . thiscontrol)
If InStr(A_GuiControl, "UI_file")
guicontrol,,%A_GuiControl%, %thisfile%
return

AutoHotKey - Resizing Windows

I currently have a HTPC connected to a plasma in my living room, and I've had a few issues with image retention. While browsing the web, etc. for an extended period of time I'll run into the issue. However, it looks like it should be relatively easy to set up a script with AutoHotKey to resize the window automatically on a timer. Could anyone help me get started on a script to accomplish this task? (Also open to any other ideas)
Thanks!
I created a script quite a while ago that "normalizes" windows, i.e. resizes, moves, and performs other actions to make a window confirm to my personal preference.
Whenever a window displays for the first time, it is normalized. If it is closed and re-opened, it is normalized again.
Below is a functioning version of the script and should satisfy the requirements from the original question.
The version I use is much more complicated because it has many more features, e.g. it supports multiple monitors and resizes windows while taking into account the height of the Windows task bar. I use the script to make open/save dialogs bigger (they are too small by default). I also use it to auto-login to some websites and applications.
; This script "normalizes" windows, i.e. resizes, moves, and performs other
; actions to make a window confirm to my personal preference.
SetTitleMatchMode, 2
; Go into an infinite loop
loop
{
; Pause so other apps can execute. 250 milliseconds seems to work well.
Sleep, 250
; If hotkeys are suspended for this script, then suspend all functionality
if A_IsSuspended
continue
; We will build a unique window name using the window title and window handle.
; Store each unique name in an array.
WinGet, HWND, ID, A
WinGetTitle, WindowTitle, A
WinGetClass, WindowClass, A
; Remember the previous window we processed
WindowTitleCleanPrevious := WindowTitleClean
; Only normalize windows that we haven't seen before.
; If we haven't already normalized the window, we do
; the normalize, then set a flag so we don't normalize the same window again.
; Strip out all chars that may be invalid in an AHK variable name.
WindowTitleCleanTemp := StringRemoveAllNonAlphaNum(WindowTitle)
; Variable names can be at most 254 chars, so truncate to less than that.
StringLeft, WindowTitleClean, WindowTitleCleanTemp, 230
; Process the window if:
; (1) It wasn't previously processed (i.e. not in our window-name list named WinList)
; (2) And we aren't sitting on the same window during each loop.
if (WinList%HWND%%WindowTitleClean% != 1 and WindowTitleClean != WindowTitleCleanPrevious)
{
; Get the window's position and size
WinGetPos, WinX, WinY, WinWidth, WinHeight, A
; Is this an MS Word window?
if (WindowClass == "OpusApp")
{
; Center the window and resize so it is 80% of the monitor width and 90% of height.
WinMove, A, , (A_ScreenWidth/2)-(WinWidth/2), (A_ScreenHeight/2)-(WinHeight/2), A_ScreenWidth * .8, A_ScreenHeight * .9
}
; Is this the Calculator window?
else if (WindowClass == "SciCalc")
{
; Center the window
WinMove, A, , (A_ScreenWidth/2)-(WinWidth/2), (A_ScreenHeight/2)-(WinHeight/2)
}
; Set a flag indicating this window has been processed so it is
; not processed again.
WinList%HWND%%WindowTitleClean% = 1
}
}
; --- Win+F5 will Reload this script ---
~#F5::Reload
; --- Win+Escape will Pause this script ---
~#Escape::Suspend, Toggle
; --- Win+Alt+Escape will Exit this script ---
; Close this script
~#!Escape::ExitApp
; ===========================================================================
; Removes all non-alphabetic and non-numeric characters from the given
; string. The resulting string is returned.
; ===========================================================================
StringRemoveAllNonAlphaNum(SourceString)
{
StringSplit, SplitSourceString, SourceString
OutputString =
Loop, %SplitSourceString0%
{
Char := SplitSourceString%A_Index%
if (Char >= "a") and (Char <= "z")
OutputString := OutputString Char
else if (Char >= "0") and (Char <= "9")
OutputString := OutputString Char
}
return OutputString
}
I am working on the same problem. Here is a script that opens and centers the Windows calculator based of your current screen size. I am still figuring everything out, but maybe this will get you started.
;This script opens and centers the calculator on your screen.
#NoTrayIcon
Run, calc.exe
WinWait, Calculator
WinGetPos,,, Width, Height, %WinTitle%
WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
Return
You can resize and snap the window using the below short cuts.
Windows Key + Left Arrow = Window snaps to left side of the screen
Windows Key + Right Arrow = Window snaps to right side of the screen
Windows Key + Up Arrow = Window snaps to upper side of the screen
Windows Key + Down Arrow = Window snaps to lower side of the screen
Windows Key + Up & Left Arrow = Window snaps to upper left corner of the screen
Windows Key + Up & Right Arrow = Window snaps to upper right corner of the screen

Simulate TAB keypress event in Selenium RC

I need to simulate a tab keypress in Selenium RC, using the Java API.
I do this after having entered some text using:
selenium.type(input, "mytext");
I've tried 3 alternatives to get the tab working:
selenium.keyPress(input, "\\9");
and:
selenium.focus(input);
selenium.keyPressNative("09");
and even:
selenium.getEval("var evt = window.document.createEvent('KeyboardEvent');evt.initKeyEvent ('keypress', true, true, window,0, 0, 0, 0,0, 9,0);window.document.getElementsByTagName('input')[2].dispatchEvent(evt);")
The best I can get is a "tab space" to be inserted after my text so I end up with this in the input field:
"mytext "
What I actually want is to tab to the next control. Any clues? Thanks!
(Note: I have to use tab and can not use focus or select to chose the element I want to go to, for various reasons, so no suggestions along these lines please!)
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB + "");
I don't use the Java API, but this post from google groups suggests it is your solution. I can't imagine that "9" is different from "09" in your question, but give it a try?
Try the official TAB char: \t or \u0009
Some functions may used Onblur. It will trigger the function when the field lose the key focus. here we can use fireEvent with "blur" or "focus" command as follows:
command: fireEvent
target: id=your_field_identification
value: blur
Reference: http://qaselenium.blogspot.com/2011/01/how-to-triger-tab-key-in-selenium.html
Improvising Ryley's answer, we can use
selenium.keyDownNative(java.awt.event.KeyEvent.VK_TAB + "");
selenium.keyUpNative(java.awt.event.KeyEvent.VK_TAB + "");
I tried this method for VK_CONTROL in IE and it worked good.
Use typeKeys():
Quoting the above link:
Unlike the simple "type" command, which forces the specified value into the page directly, this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.