I'm somewhat new to Applescript, and I am trying to make Applescript check a checkbox to select it. I want the checkbox to be clicked regardless of whether or not it's already checked. Here is the checkbox's location according to the Accessibility Inspector:
<AXApplication: “Safari”>
<AXWindow: “Studio”>
<AXGroup>
<AXGroup>
<AXGroup>
<AXScrollArea: “”>
<AXWebArea: “”>
<AXGroup: “”>
<AXCheckBox: “”>
Attributes:
AXRole: “AXCheckBox”
AXSubrole: “(null)”
AXRoleDescription: “check box”
AXChildren: “<array of size 0>”
AXHelp: “”
AXParent: “<AXGroup: “”>”
AXPosition: “x=1104 y=825”
AXSize: “w=18 h=19”
AXTitle: “”
AXDescription: “”
AXValue: “0”
AXFocused (W): “0”
AXEnabled: “1”
AXWindow: “<AXWindow: “Studio”>”
AXSelectedTextMarkerRange (W): “<AXTextMarkerRange 0x101937860 [0x7fff76e43fa0]>{startMarker:<AXTextMarker 0x1019378b0 [0x7fff76e43fa0]>{length = 24, bytes = 0xac01000000000000c0366e23010000001700000001000000} endMarker:<AXTextMarker 0x101938030 [0x7fff76e43fa0]>{length = 24, bytes = 0xac01000000000000c0366e23010000001700000001000000}}”
AXStartTextMarker: “<AXTextMarker 0x101938030 [0x7fff76e43fa0]>{length = 24, bytes = 0xa00000000000000098975e0d010000000000000001000000}”
AXEndTextMarker: “<AXTextMarker 0x1019378b0 [0x7fff76e43fa0]>{length = 24, bytes = 0xa200000000000000405e7812010000000000000001000000}”
AXVisited: “0”
AXLinkedUIElements: “(null)”
AXSelected: “0”
AXBlockQuoteLevel: “0”
AXTopLevelUIElement: “<AXWindow: “Studio”>”
AXTitleUIElement: “(null)”
AXAccessKey: “(null)”
AXRequired: “0”
AXInvalid: “false”
AXARIABusy: “0”
Actions:
AXPress - press
AXShowMenu - show menu
I've tried multiple methods to get this to work, and I haven't been able to. Any help is appreciated.
Your question with the Accessibility Inspector info is not very helpful I am afraid.
It would help if we could see the actual elements of the web page,
Have a look at this page which I found that shows check boxes and the code that makes it up.
Each element has a name and maybe within some other element.
on the page I can use this Applescript/Javascript to check the check1 checkbox.
Hopefully this will give you an idea of how to go about it.
But remember this code snippet is tailored to this page.
Open the web page and run this applescript
tell application "Safari"
set doc to document 1
do JavaScript "document.forms['testform']['check1'].checked = true" in doc
end tell
Update: Applescript GUI
Update:2 take into account "clicked regardless of whether or not it's already checked"
Taking a punt with your Accessibility Inspector. Which is a bit useless (not your fault)
try:
activate application "Safari"
tell application "System Events"
set theCheckbox to (checkbox 1 of group 3 of UI element 1 of scroll area 1 of group 1 of group 1 of group 2 of window 1 of application process "Safari")
set isEnabled to value of theCheckbox as boolean
if not isEnabled then
click theCheckbox
end if
end tell
Related
Im new to Access and need some help. D:
So I have a form in datasheet view which displays basic information of all the records from a query. By pressing a text field at the end of each record it opens another form in edit mode with the details of that specific record.
But after it opens I want to disable or hide some fields and controls including a button which clears all the fields in the form so that users can't press it accidentally and erase all Information in the form.
I've tried this code:
Private Sub Text23_Click()
DoCmd.OpenForm "FrmEntregas", acNormal, "", "[EntregasID]=" & Nz(CodeContextObject.EntregasID, 0), acEdit, acDialog
'Forms("FrmEntregas").btnReiniciar.Visible = False
'Forms!FrmEntregas!btnReiniciar.Visible = False
'Forms("FrmEntregas").Form.Controls(btnReiniciar).Visible = False
End Sub
The first line works great, the problem comes when refering to the form's button. I've tried refering to the button in three different ways but none of them work. It displays this message:
"Runtime Error 2450: Microsoft Access cannot find the referenced form 'FrmEntregas'."
If someone could point me in the right direction I'd be more than thankful!
Don't open in Dialog mode, the code after DoCmd works only when the form is closed. Change the Modal property of the form to Yes instead.
Private Sub Text23_Click()
DoCmd.OpenForm "FrmEntregas", acNormal, "", "[EntregasID]=" & Nz(CodeContextObject.EntregasID, 0), acEdit
Forms("FrmEntregas").btnReiniciar.Visible = False
End Sub
I'm brand new to MS-Access and had a few guideline-questions,
My organization uses MS-Access to track a large electronic-part inventory. These parts have a hyperlink field that links to the product webpage. Here's an example:
Part Number Part Type Value Description Component_Height Voltage Tolerance Schematic Part Layout PCB Footprint Manufacturer Part Number Manufacturer Distributor Part Number Distributor Price Availability Link
UMK105CG100DV-F Ceramic 10pF CAP CER 10PF 50V NP0 0402 0.35 MM 50V ±0.5pF xxxxx\C_NP,xxxxx\C_NP_Small c_0402 UMK105CG100DV-F Taiyo Yuden 587-1947-2-ND Digi-Key 0.00378 In Stock http://www.digikey.com/product-detail/en/UMK105CG100DV-F/587-1947-2-ND/1473246
Links Here:
http://www.digikey.com/product-detail/en/UMK105CG100DV-F/587-1947-2-ND/1473246
Nearly the entire majority of our hyperlinks point to the supplier DigiKey.
Right now the verification flow goes like this:
Every month or so a large group of us sits down and one by one copies the hyperlink into google.
We then open the corresponding webpage and verify component availability etc.
We have nearly 1000 components and this process takes hours. All I'm looking for is advice on how to improve our workflow. I was hoping there was say a way to write a "open hyperlink with default browser and search string" macro or scripting interface. The pseudo-script would then check that the string "Quantity Available" was greater than 1, and if it wasn't (the part was out of stock) mark the part as obsolete.
Any advice would be greatly appreciated, I'm really aiming to optimize our workflow.
You can traverse the DOM of the web page. A quick look at the web page and you can see a table with a name of product-details.
So the following VBA code would load the sample web page, and pull out the values.
Option Compare Database
Option Explicit
Enum READYSTATE
READYSTATE_UNINITIALIZED = 0
READYSTATE_LOADING = 1
READYSTATE_LOADED = 2
READYSTATE_INTERACTIVE = 3
READYSTATE_COMPLETE = 4
End Enum
Sub GetWebX()
Dim ie As New InternetExplorer
Dim HTML As New HTMLDocument
Dim strURL As String
Dim Htable As New HTMLDocument
Dim i As Integer
strURL = "http://www.digikey.com/product-detail/en/UMK105CG100DV-F/587-1947-2-ND/1473246"
ie.Navigate strURL
Do While ie.READYSTATE < READYSTATE_COMPLETE
DoEvents
Loop
Set HTML = ie.Document
Set Htable = HTML.getElementById("product-details")
For i = 0 To Htable.Rows.Length - 1
With Htable.Rows(i)
Debug.Print Trim(.Cells(0).innerText), Trim(.Cells(1).innerText)
End With
Next I
ie.Quit
Set ie = Nothing
End Sub
output of above:
Digi-Key Part Number 587-1947-2-ND
Quantity Available 230,000
Can ship immediately
Manufacturer Taiyo Yuden
Manufacturer Part Number UMK105CG100DV-F
Description CAP CER 10PF 50V NP0 0402
Expanded Description 10pF ±0.5pF 50V Ceramic Capacitor C0G, NP0 0402(1005 Metric)
Lead Free Status / RoHS Status Lead free / RoHS Compliant
Moisture Sensitivity Level (MSL) 1 (Unlimited)
Manufacturer Standard Lead Time 11 Weeks
Since the above is a array, then you could place a button right on the form, and have a few extra lines of VBA to write the values into the form. So a user would just have to go to the given record/form in Access - press a button and the above values would be copied right into the form.
the above VBA code requires a reference to:
Microsoft Internet Controls
Microsoft HTML Object Library
I would suggest that after testing you use late binding for the above two libraries.
This question is regarding a Windows form built in PowerShell using System.Windows.Forms - I intend to convert it to C# at some point, just hasn't happened yet. C# contextual answers welcomed.
So in order to make this tool appear more like an "app" verses another WPF thing, the control boxes were removed, along with the title. In doing so, we lose the ability to move the form. So I decided to write a nice little number to handle that, which you all may agree or disagree with. Anyhow, it works great on my workstation, laptop, and a remote session to a few random terminal servers. However, when testing with a user, the app experiences a "jump" when clicked on where this bit of code might be picking up on the mouse click. The form's icon still shows in the toolbar, but it's obvious that the form has gone way off screen, and cannot be pulled back to center. I am not 100% sure if it's the code, but I have a feeling. I cannot reproduce this on my machines. Please don't tell me how to get the form back on the screen, that is just a workaround. I appreciate any ideas.
$GLOBAL:ButtonDown = 0
$GLOBAL:FX = 0
$GLOBAL:MX = 0
$GLOBAL:FY = 0
$GLOBAL:MY = 0
$Form.Add_MouseUp({handler_Form_MouseUp})
function handler_Form_MouseUp{$GLOBAL:ButtonDown = 0}
$Form.Add_MouseDown({handler_Form_MouseDown})
function handler_Form_MouseDown{
$GLOBAL:FX = $Form.Location.X
$GLOBAL:MX = [System.Windows.Forms.Cursor]::Position.X
$GLOBAL:FY = $Form.Location.Y
$GLOBAL:MY = [System.Windows.Forms.Cursor]::Position.Y
$GLOBAL:ButtonDown = 1
}
$Form.Add_MouseMove({handler_Form_MouseMove})
function handler_Form_MouseMove{
if($GLOBAL:ButtonDown){
#write-host ("X:"+ ([System.Windows.Forms.Cursor]::Position.X) + " || Y:" + ([System.Windows.Forms.Cursor]::Position.Y))
$newX = $GLOBAL:FX + ([System.Windows.Forms.Cursor]::Position.X - $GLOBAL:MX)
$newY = $GLOBAL:FY + ([System.Windows.Forms.Cursor]::Position.Y - $GLOBAL:MY)
$Form.SetDesktopLocation($newX, $newY)
$GLOBAL:FX = $Form.Location.X
$GLOBAL:MX = [System.Windows.Forms.Cursor]::Position.X
$GLOBAL:FY = $Form.Location.Y
$GLOBAL:MY = [System.Windows.Forms.Cursor]::Position.Y
}
}
I am developing an windows application in F#. In the application I have to show the TextBox mode in Password Format. What is the code for using the password mode of TextBox in F#?
I have applied the following code:
let txtpwd = new TextBox(Top = 70, Left = 120)
From the above code the textbox is displaying. No problem. I have applied following code for password mode:
txtpwd.PasswordChar
The above code is not working properly.
You should set desired properties upon initialization of your control, for example:
txtpwd.Text <- "" // Set to no text
txtpwd.PasswordChar <-'*' // The password character is an asterisk
txtpwd.MaxLength <- 14 // The control will allow no more than 14 characters
Better yet, set the properties in your call to the constructor. One of the cool things about F# is that you can set properties in the call that you wouldn't normally be able to set in the constructor. Like this:
let txtpwd = new TextBox(Top = 70, Left = 120, Text = "", PasswordChar = '*',MaxLength = 14, Multiline = true)
This is basically equivalent to what Gene posted but, as far as I know, it's a little more idiomatic in F#.
If you check this page under the topic "Assigning Values To Properties At Initialization" (sorry can't post a direct link) although the page is discussing F# code, it holds for other .Net code as well.
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...