I've figured out how to send a TAB after it's matched the string I need it to
$textbox2_TextChanged={
#TODO: Place custom script here
if ($textbox2.Text.Trim() -match '[PC]{2}\d{6}')
{
$wshell.SendKeys('{tab}')
}
}
That's great.. So my question, is is there an easier way to tab through my next 9 boxes?
TAB on matched string
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: TAB on matched string
You can set the form to move through the tabs automatically in the order you set.
Place your test in the "Validating" event. When the event validates successfully the next control will be automatically selected.
If you want a different control to be next use the "Select()" method on the control you want to switch to. Place the code in the "Validated" event.
$controlname.Select()
We seldom ever use "SendKeys" as it can be unreliable.
Place your test in the "Validating" event. When the event validates successfully the next control will be automatically selected.
If you want a different control to be next use the "Select()" method on the control you want to switch to. Place the code in the "Validated" event.
$controlname.Select()
We seldom ever use "SendKeys" as it can be unreliable.
Re: TAB on matched string
The Validate and Validating events of ANY "forms control" control the behavior of the form. As long as "Validating" returns "$_.Cancel - $true" the control will remain in focus. When it doesn't the "Validated event will fire allowing us to determine what happens next. The default behavior is to select the next control in the tab order.localpct wrote:Validateevent of the textbox?
Look up and study the forms events control flow documentation. Understanding it can save you hundreds of lines of code
Re: TAB on matched string
I've not seen this holy "forms events control floe documentation"jvierra wrote:The Validate and Validating events of ANY "forms control" control the behavior of the form. As long as "Validating" returns "$_.Cancel - $true" the control will remain in focus. When it doesn't the "Validated event will fire allowing us to determine what happens next. The default behavior is to select the next control in the tab order.localpct wrote:Validateevent of the textbox?
Look up and study the forms events control flow documentation. Understanding it can save you hundreds of lines of code
Thanks
Re: TAB on matched string
Oh. Well holy was sorta sarcastic.jvierra wrote:Sorry:
Look up and study the "forms events control flow" documentation.
Language is tricky. I get sloppy at ties.
No worries sir and thanks for the link.
Re: TAB on matched string
So I think I've got this part down. But I feel I'm doing it the wrong/long way. I wasn't sure if I should create a new post as it's a different issue or not but what I'm running into now is keeping fields from the mainform and passing them over to the childform and then taking all of those items ( just textboxes ) and adding them to a CSV.. So here's a break down
I have an project form in progress to address missing computers.
When it first launches it checks against active directory for users of a specific group - this way whenever someone is added to certain managers, the application is automatically updated
The technicians are required to scan their badge to be able to scan a PC. On a single PC, exporting it to a CSV is no problem so for example the CSV looks like this
EmployeeID EmployeeName PCNumber Scanned Location
001 John Smith PC000001 Incident-Deployment
I'd like to create a batch process but I'm not sure how to add a new row in the CSV but also append the techs ID number, name, location etc and only change the PC# for example
The employee ID, Name and ScannedLocation is from the MainForm but the PCNumber will be from a child form. I can attach the childform for now.
I have an project form in progress to address missing computers.
When it first launches it checks against active directory for users of a specific group - this way whenever someone is added to certain managers, the application is automatically updated
The technicians are required to scan their badge to be able to scan a PC. On a single PC, exporting it to a CSV is no problem so for example the CSV looks like this
EmployeeID EmployeeName PCNumber Scanned Location
001 John Smith PC000001 Incident-Deployment
I'd like to create a batch process but I'm not sure how to add a new row in the CSV but also append the techs ID number, name, location etc and only change the PC# for example
- EmployeeID EmployeeName PCNumber Scanned Location
- 001 John Smith PC000001 Incident-Deployment
- 001 John Smith PC000072 Incident-Deployment
- 001 John Smith PC000068 Incident-Deployment
- 001 John Smith PC000099 Incident-Deployment
- 001 John Smith PC000101 Incident-Deployment
- 001 John Smith PC000062 Incident-Deployment
- 001 John Smith PC000073 Incident-Deployment
- Attachments
-
- BatchScanIT_Public.psf
- (45.25 KiB) Downloaded 109 times
Last edited by localpct on Wed Jun 21, 2017 4:11 pm, edited 1 time in total.
Re: TAB on matched string
You need to start a new question and state what you are actually coding and what issue you are not able to resolve.
Without some idea of what your code is trying to do this doesn't make much sense.
Without some idea of what your code is trying to do this doesn't make much sense.