Old 30th May 2017, 19:53   #1
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 242
Question Find Control Id With Random ID Number

Control in some application after open have random control id!
i for find and send text in a text box with random id use this Section...

HTML Code:
!include WinMessages.nsh
ShowInstDetails show
var CounterM

Section

GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1

StrCpy $CounterM "0"


loop:
DetailPrint "$CounterM"

FindWindow $0 "WindowsForms10.Window.8.app.0.141b42a_r9_ad1" "Form1"
GetDlgItem $0 $0 $CounterM
SendMessage $0 ${WM_SETTEXT} 0 "STR:Hello World!"


intop $CounterM $CounterM + 1

Goto loop

SectionEnd


in my application text box id number is: 1246350

loop It takes a long time for find text box Id number and sendMessage to that...

There is a faster way for find text box or find other controls id and sendmessage to that's?
r2du-soft is offline   Reply With Quote
Old 31st May 2017, 01:14   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,604
Maybe provide some more information? Did you write this app? Why do you need to do this?

You can find child controls with FindWindow...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd June 2017, 06:02   #3
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 242
Intelligent and speed up the work
An organization has changed its Application Storage.
New software is written with C#.
The information contained in previous software all need to re-enter the new software.
In this application,Page where Add the product to inventory goods warehouse There is Has several fields.
The information to be entered in the fields, in a text file is available.
Such that The information contained in each line of text file must enter to a field.
We do it automatically To speed up the work.
There is no problem in reading text file lines,But the main problem here...Read the value of each line of text file Must enter This program in various fields...
And since the number control & HWNDPARENT is varies.in my section code has a loop so It takes a lot of time to control handler is found...
After finding the control HWNDPARENT each line of text file must enter to a field.

We have problems in doing so:

1-It takes a long time to find all HWNDPARENT controls and we do not know where we continue to loop for found all controls!
2-Can not obtain the name of each control
If the program was written with vb6 we can found control text but this application it was made with C#,C# Controls have Control Name and i can not find control name but can found vb6 control text...

3-What we want to do:
read line ONE of text file & Write to Control With Name 'ProductName'
read line TWO of text file & Write to Control With Name 'Stock'
and ...

4-Autoit how show controls Instance,Can be found control by Instance or TabIndex?

a question:
GetDlgItem Found control by ID.
Can be found control by Name and after that write to that control value?
If yes How?
the problem is solved If this can be done



Have prepared An example:
Was attached
Attached Files
File Type: zip GetDlgItem Example.zip (266.6 KB, 32 views)
r2du-soft is offline   Reply With Quote
Old 4th June 2017, 09:09   #4
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 242
Question

YES!
EnumChildWindows

HTML Code:
!include LogicLib.nsh
!include WinMessages.nsh
!include "defines.nsh"
ShowInstDetails show

Var HWND

Section

GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1

ReBack:
StrCpy $R2 ""
Dialogs::InputBox "InputBox sample" "Please type something 'Class Names' Or 'Title Names'" "OK" "Cancel" "0" ${VAR_R2}
StrCmp $R2 "" Cancel Ok

Cancel:
DetailPrint "No info was inputed by the user"
goto Exit

Ok:
DetailPrint "User info: $R2"



FindWindow $0 "" "$R2" ;$HWNDPARENT  #Class #Title
${IF} $0 == "0"
FindWindow $0 "$R2" "" ;$HWNDPARENT  #Class #Title
${IF} $0 == "0"
MessageBox MB_OK "Dont Find 'Class Names' Or 'Title Names' Please insert A true Value!"
Goto ReBack

${Else}

DetailPrint "Find Class"
${EndIf}
${Else}
DetailPrint "Find Title"
${EndIf}





StrCpy $HWND $0
System::Call 'user32.dll::GetClassName(i r0, t .r5, i ${NSIS_MAX_STRLEN}) i .n'
System::Call 'user32.dll::GetWindowText(i r0, t .r6, i ${NSIS_MAX_STRLEN}) i .n'
DetailPrint "-----------------------------------------------------------"

;FindWindow $0 "" "Form1" ;$HWNDPARENT  #Class #Title
;StrCmp $0 0 Exit 0

SetPluginUnload alwaysoff
System::Get "(i.r1, i) iss"
Pop $R0
System::Call "user32::EnumChildWindows(i $0, k R0, i) i.s"
loop:
        Pop $0
        StrCmp $0 "callback1" 0 done
        System::Call "user32::GetWindowText(ir1,t.r2,i${NSIS_MAX_STRLEN})"
        System::Call "user32::GetClassName(ir1,t.r3,i${NSIS_MAX_STRLEN})"
		System::Call 'user32.dll::RealGetWindowClass(ir1, t .r4, i ${NSIS_MAX_STRLEN})'
        IntFmt $1 "0x%X" $1
        ;DetailPrint "[$1] - [$3] $2"
		DetailPrint "Application HWNDPARENT: $HWND"
		DetailPrint "Application Class: $5"
		DetailPrint "Application Title: $6"
		DetailPrint "---"
		DetailPrint "Control HWNDPARENT: $1"
		DetailPrint "Control Class: $3"
		DetailPrint "Control Text: $2"
		DetailPrint "Control RealGetWindowClass: $4"
		DetailPrint "-----------------------------------------------------------"
		;-----------------------------------------------
		SendMessage $1 ${WM_SETTEXT} 0 "STR:0010"
		;-----------------------------------------------
        Push 1 # callback's return value
        System::Call "$R0"
        Goto loop
done:


Exit:
SectionEnd

just i have one problem:
See attached

Can return VB6 applications control text value but Can't Return C# Applications Control TEXT Value!!Why?

DetailPrint "Control Text: $2" Haven't Return Value

how can fix this?
Attached Files
File Type: zip Win.Info.zip (40.9 KB, 28 views)
r2du-soft is offline   Reply With Quote
Old 4th June 2017, 15:33   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,604
https://blogs.msdn.microsoft.com/old...21-00/?p=42833 hints that you need to use WM_GETTEXTLENGTH+WM_GETTEXT and not GetWindowText.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th June 2017, 00:39   #6
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 242
Down ↓ Code Return Initial Value Text Box The programmer Entered To The Text Box:

HTML Code:
System::Call "user32::GetWindowText(ir1,t.r2,i${NSIS_MAX_STRLEN})"

i test WM_GETTEXTLENGTH+WM_GETTEXT
HTML Code:
System::Call 'user32::SendMessage(i $1,i ${WM_GETTEXT},i ${WM_GETTEXTLENGTH},t.r9)'
that Return The Value Which Are Now In The Text Box....

But I Want Return Control Name...
But I Don't know How!
Such As Autoit

http://imgh.us/2017-06-05_04-04-50.jpg

attached!
Attached Files
File Type: zip Win.Info.zip (36.9 KB, 30 views)
r2du-soft is offline   Reply With Quote
Old 5th June 2017, 01:03   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,604
Name is not something a HWND has at the windowmanager level.

That tool might be using Microsoft Active Accessibility (MSAA) and/or UI Automation (UIA), IAccessible::get_accName perhaps.

You could try https://www.codeproject.com/Articles...-Accessibility and see if the Name there is the same thing.

However, this forum is not a general programming forum! When dealing with stuff like this you should first write it in some language you know (VB? C#?) and then (and only then) if you have problems doing the same thing with System::Call should you ask here on the forum.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump