Jump to content
Sign in to follow this  
Combo

Having trouble with 2 windows with same title

Recommended Posts

Combo

Hi, we have a program that we'd like to login automatically then hide.

Problem is the login window and the program windows itself have same title,

so i googled and one of the solution is to use text inside window to differentiate them.. 

I tried this but it won't work.. any idea why? text1 is login window, text2 is the program window

#RequireAdmin
$smartbilling = "E:\SmartLauncher.exe"
$hWnd = "SmartBilling"
$pasd = "1234"
$text1 = "Pemilik"
$text2 = "Manajemen Server"
Func Logon()
If WinExists($hWnd, [$text1]) Then
   Send("$pasd{ENTER}")
   WinWaitActive($hWnd, [$text2]) Then
   WinSetState($hWnd, "", @SW_HIDE)
Elseif WinExists($hWnd, [$text2]) Then
   WinSetState($hWnd, "", @SW_HIDE)
Else
   Run($smartbilling)
   WinWaitActive($hWnd, [$text1])
   Send("$pasd{ENTER}")
   WinWaitActive($hWnd, [$text2]) Then
   WinSetState($hWnd, "", @SW_HIDE)
EndIf
EndFunc

This is the pic of both windows,

I circled text1 and text2

KYgw6Sl.jpg

 

Edited by Combo

Share this post


Link to post
Share on other sites
iamtheky

maybe its just your send and winwaits being incorrectly formatted

Send($pasd & "{ENTER}")

 

WinWaitActive($hWnd, $text1)

 

the brackets are there to show the parameter is optional, they are not to be included

 

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Combo

maybe its just your send and winwaits being incorrectly formatted

Send($pasd & "{ENTER}")

 

WinWaitActive($hWnd, $text1)

 

the brackets are there to show the parameter is optional, they are not to be included

Sending password worked, i tried it separately without other function.

I think the problem is reading text within windows.
When i run that script it only asks for admin rights then nothing happens

Is there's any other method to differentiate 2 windows with same title?

Edit : fixed it, it opens the login windows, but now it won't login.. I think it still can't read the text inside windows..

#RequireAdmin
$smartbilling = "E:\SmartLauncher.exe"
$hWnd = "SmartBilling"
$hWnd2 = "SB News"
$pasd = "1234"
$text1 = "Pemilik"
$text2 = "Manajemen"
If WinExists($hWnd, $text1) Then
   Send($pasd & "{ENTER}")
   WinWaitActive($hWnd, $text2)
   WinSetState($hWnd, "", @SW_HIDE)
Elseif WinExists($hWnd, $text2) Then
   WinSetState($hWnd, "", @SW_HIDE)
Else
   Run($smartbilling)
   WinWaitActive($hWnd, $text1)
   Send($pasd & "{ENTER}")
   WinWaitActive($hWnd, $text2)
   WinSetState($hWnd, "", @SW_HIDE)
EndIf

Edit2 : Yeah, it's definitely reading text issue, i removed text1 and it logged in.. 

So which text can be used for my case?

Edited by Combo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×