I inherited a project that involves a .ahk script to open a file from a location and load it into a program. Sadly, I've had to learn from scratch and I've come upon a section of code that I can't figure out or get to work for the life of me.
Here's the snippet:
if Not oLV:=COM_AccessibleObjectFromWindow(hwnd) ; checks if its valid
ExitApp
When I run the script on a PC using Windows 7, this works fine. When I ported it over to a machine with Windows 10, this one line stops working. Everything else in the script works fine. I'm printing oLV.accChildCount to a textbox to see how many items are in my list. There are 5 items and this is shown on the old machine, but isn't showing on the new machine. The textbox just pops up blank. Any ideas?
Well, seems like oLV := Acc_ObjectFromWindow(hwnd) is what I needed to do. Still weird how COM_AccessibleObjectFromWindow(hwnd) doesn't work on the newer machine.
Related
This question already has answers here:
VBS Script - Need to change msgbox to echo
(3 answers)
Closed 9 months ago.
Background
I'm a tech writer but have dabbled in coding for many years now. For work, I need to test about a hundred different ancient script samples. The samples are stored in our documentation. They are in written in Basic (technically, in Cypress Enable BASIC, but it's essentially very similar if not identical to Basic scripting). I need to test them and fix any that are broken.
I want to set up Visual Studio Code to run these because I love VSC as it has a lot of benefits over the very old and vanilla scripting editor included with our product that I've been using.
My Need
Mainly, I need to be able to copy and paste the code I want to test into VSC into a simple .bas file and then run and test the code inside VSC with code coloring, code running, and a debugger. Intellisense would also be helpful. I can get color coding, but getting it to run and debug isn't working.
What I've Tried and Other Notes
I've already spent hours trying to set something up, but can't figure it out.
I have Windows 10
From something I found online, I've mapped this folder C:\Windows\Microsoft.NET\Framework64\v3.5 to my system's Path Environment Variable. (where <user> is my user name).
I've also tried different vbscript and vba related extensions, but have since uninstalled them as nothing seemed to resolve this very basic (no pun intended) problem.
I've searched various posts online and in this site, but haven't found a solution yet.
I tried enabling Run in Terminal in Code-runner to see if that made any difference.
Something is wrong, as I consistently get errors. For example, with Code Runner extension installed, if I try to run this very simple vbscript to show a test message box...
Sub Main ()
Dim testString
testString = "Meh... Will it work?"
MsgBox testString
End Sub
...I get this result in my VSC Output window:
[Running] cscript //Nologo "d:\Temp\vbscripttest.bas"
[Done] exited with code=0 in 0.174 seconds
I find very little info searching on code=0 error that is useful.
My script is in my d:\temp folder. I don't know if that makes a difference. If I try running the .bas file from the File Explorer window directly by double-clicking on it, nothing happens. Though from the icon style, it appears to be mapped to VBScript.
I gather either Windows or vbcode or both can't find the vbscripting goodness that makes things work, though I thought pointing the path variable to C:\Windows\Microsoft.NET\Framework64\v3.5 would fix that.
After two days of pulling my eyebrows out using our product's internal script editor to test my scripts (my hair has long since gone), I am hankering for some good old fashioned debugging support in my favorite code editor!
What do you recommend I do to get things working? Thank you in advance for your help.
Your sample program is running successfully. In that file there is no code in the code path. VBScript in a top level language (unlike VBA). That means code runs outside of a sub or function.
So insert before the first line Main to call Main. Or lose the Sub ... End Sub for VBScript. In VBA/VB6 you would choose Sub Main as the startup sub in Properties.
While this is not your problem, just to be complete, if you start a script in CScript or WScript using //b command line parameter then message boxes are not displayed. See CScript /?.
Hello guys i am new to programming and i just installed vs code, everything is working fine except when i run the code the console comes and goes without me even seeing the output.So how do i make it stay. or how do i run the output inside the vs code terminal and just eliminate that pop up console.
The thing is i need to take screenshots of the output for my lecturer to see for future projects. Attached is a screenshot.the console is only here because it needs inputhere after input it just disappears
I have a question and I have been looking for a lot of reviews and nothing seems to work.
I am trying to run my project in my mac.
And always than I put in my cucumber file for example:
example:
only the line where I use "<>" show the next message : "step does not have a matching glue code.
and I totally sure that the same name is connected with his method in my page objects.
The weird thing is that in my windows computer the project run perfectly. I don't know why occurs this.
I hope you can help me.
I'm still studying for my computer science degree and have mostly focused on the mathematics side of things for now. However, in my current job I am working with Selenium IDE (specifically because it doesn't require coding knowledge) and I'm having a bit of trouble:
I need to test a Shift + click as well as a cherry-pick (Control + click) command on the web-based software we are creating, but it's not working. Manually pressing control and then clicking different elements on the screen works fine, however.
Like I said, I'm using Selenium IDE 2.9.1, and I'm using it on Firefox 50.0.2 on a Windows 10 install. My commands on that section are as follows:
Screenshot of the IDE command
The idea, obviously, being to select the object named Field1, depressing the Ctrl key, selecting the object named Field2 and then releasing the Ctrl key. This should, theoretically anyway (and does work when done manually outside of the IDE), select Field1 and then cherry-pick Field2 from the list as well.
This, however, is not the case, and it doesn't work.
Can anyone, please, advise me on how to proceed here? Should the commands be structured differently? Am I using the incorrect commands? Is there something else I can try?
As a PS: The same issue persists with the shiftKeyDown command as well.
I have searched for this issue online and found no help that actually works for me yet, hence this post.
I am looking forward to your replies, in the hope that I can find success... :)
I think that it is a Selenium IDE original command problem.
When you tried to simulate pressing Ctrl key and used "controlKeyDown/Up" command, it just changed the boolean value and did not fired a real key down/up event. Also Shift and Alt key could not work.
Maybe you should try to add a "keyDown/Up" command after "controlKeyDown/Up" command and the target could be //body .
And, if you need, please try to use the tool, SideeX, the extended version of Selenium IDE. Maybe this problem will be solve in the future and make the test case flexible. Here is the link to SideeX and there are more details about the tool.
OK, I found the solution.
When compiling the tests I test them by running through them step by step to ensure that everything is working like it should, before saving it to a test suite and letting it run on it's own. Now, this involves me double-clicking every command in the Table one by one, in sequence, and keeping and eye on the screen to ensure that it executes and behaves exactly like I want it to. Simple, understandable, logical, correct?
Well, it seems like the controlKeyDown and controlKeyUp commands DO NOT WORK in this way.
I built a bare-minimum test case using only the 4 commands: click the element, controlKeyDown, click the next element, controlKeyUp. I ran through the test a hundred times with no success, but then I started thinking - what if the controlKeyDown command is never released? That would cause issues outside of the test (on the rest of the environment, obviously), since the Ctrl key would be permanently depressed. So I figured that the Selenium IDE either 1. Releases the key in a short amount of time automatically (faster than I can execute the command to click the next element manually) or 2. It simple ignores the controlKeyDown command if it's not run in a complete test case/suite.
So I took the 4-line test case, built up a test screen with test grid elements and ran the test case - and it works. Perfectly, actually.
So, in case anyone has similar issues in the future, try to RUN the test case instead of clicking through it or executing commands manually.
I wrote an extremely lengthy script that creates a form. The main purpose of it it to connect to vCenter servers, total up hosts/vms within different datacenters and also identify ESXi host versions. Running the script in ISE the form loads fine and when I click the Button to start the many various functions to update the fields, it runs. I have Foreach() fields throughout and added in a little StatusLabel to the bottom of the form to show me where in the script it is currently scanning.
Once all was done and working, I saved the PS1 file and moved it to a shared server to be run. When I run the Powershell console (as Admin) and point to the file, the Form loads ok. Once I click the button to begin generating the info, It just changes to (Not Responding) and grays out. I know it's working and if left there long enough it will return the info.
Why does the console window not function like the ISE? I want to be able to see the information and Status Label update/change as it goes through the script (just like I do in the ISE).
Appreciate the feedback. The script is several thousand lines long and would need to be scrubbed before I upload. Was hoping to just get some general info before doing that.
I updated to v4 and verified that my command window was running as STA using the command from Jan Chrbolka. Script runs properly now.
I was also facing the same issue.(Btw, I cannot upgrade Powershell to V4 right now since it is my company owned one.)
The Browse button that I incorporated in my form was not working when I am lauching it from Powershell command line. It went to Not Responding state when I click the browse button.
I took the advise from Jan ChrbolkaMay about the STA and MTA.
I checked for the threads related to that and changed the script execution format to the below one which fixed my issue.(adding the word -STA)
powershell -STA -File D:\PS\GUI.ps1
For checking the current state. Use the below query in Commandshell as well as ISE.