Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > C# WinApp อยากทราบว่าสามารถเอาข้อความใน textbox หรือ label จาก Program อื่นมาใช้งานได้ไม๊ครับ



 

C# WinApp อยากทราบว่าสามารถเอาข้อความใน textbox หรือ label จาก Program อื่นมาใช้งานได้ไม๊ครับ

 



Topic : 122739



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook



ตอนนี้รื้อ โปรแกรม AutoInstall มาเขียนใหม่อยู่ครับ
แต่ก่อนตอนหัดซ่อมคอมใหม่ๆใช้ Autoit เขียน
เนื้อหากล่าวถึงการเรียกใช้งานโปรแกรม PEiD.exe
แล้วเอาข้อความต่างๆใน โปรแกรม PEiD.exe มาใช้งาน


ถ้าเป็น C# หรือ VB.net ต้องเขียนยังไงหรือครับ
หรือว่ามีวิธีดึง parameter การ Install ออกมาไม๊ครับ

http://www.overclockzone.com/forums/archive/index.php/t-847971.html

Code
;--------------------------------------start script---------------------------
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Date.au3>

Global $title_peid = 'PEiD v0.94'

;create gui
GUICreate("Advance Auto Installer v 2.0", 320, 179, 353, 292)
GUISetBkColor(0xC0DCC0)
$Progress1 = GUICtrlCreateProgress(9, 25, 302, 17)
$Button1 = GUICtrlCreateButton("Browse", 238, 62, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Select program to install.")
$Input1 = GUICtrlCreateInput("", 82, 64, 155, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY), _
BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Input2 = GUICtrlCreateInput("", 104, 104, 115, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY), _
BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Button2 = GUICtrlCreateButton("Install", 124, 144, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Auto install.")
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Exit", 300, 165, 21, 17, $SS_CENTER)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Close")
GUICtrlCreateLabel("ProgramName:", 10, 66, 70, 17)
GUICtrlCreateLabel("Parameters:", 45, 106, 60, 17)
$Label2 = GUICtrlCreateLabel("Progression", 130, 6, 59, 17, $SS_CENTER)
GUICtrlCreateLabel("by:sak2005", 1, 145, 59, 17, $SS_CENTER)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label3 = GUICtrlCreateLabel("dd//mm//yyyy", 1, 162, 52, 17, $SS_CENTER)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetData($Label3, _NowDate())

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label1
ExitLoop
Case $Button1 ;file browse and run plugin (PEiD) scan search type installer.
$executable = FileOpenDialog("Select a file to install", @DesktopDir & "|", _
"Program Setup (*.exe;*.msi)", 1 + 4)
If Not $executable Then ContinueLoop
Run(@ScriptDir & '\Plugin\PEiD.exe -hard ' & '"' & $executable & '"')
WinSetState($title_peid, '', @SW_HIDE)
$textstring = ControlGetText($title_peid, '', 'Edit1')
$idstring = ControlGetText($title_peid, '', 'Edit2')
While ($idstring = 'Scanning...') Or ($idstring = '')
$textstring = ControlGetText($title_peid, '', 'Edit1')
$idstring = ControlGetText($title_peid, '', 'Edit2')
WEnd
WinClose($title_peid)
; file path split for file.exe
Select
Case StringInStr($executable, 'exe')
$StringSp = StringSplit($Executable, '\')
If StringInStr($StringSp[2], 'exe') Then
$install = $StringSp[2]
ElseIf StringInStr($StringSp[3], 'exe') Then
$install = $StringSp[3]
ElseIf StringInStr($StringSp[4], 'exe') Then
$install = $StringSp[4]
ElseIf StringInStr($StringSp[5], 'exe') Then
$install = $StringSp[5]
ElseIf StringInStr($StringSp[6], 'exe') Then
$install = $StringSp[6]
ElseIf StringInStr($StringSp[7], 'exe') Then
$install = $StringSp[7]
ElseIf StringInStr($StringSp[8], 'exe') Then
$install = $StringSp[8]
EndIf
;scan type installer file.exe and parameters.
If StringInStr($idstring, 'Inno') Or StringInStr($idstring, 'Borland') Then
$parameters = '/sp- /verysilent'
ElseIf StringInStr($idstring, 'Nullsoft') Then
$parameters = '/S'
ElseIf StringInStr($idstring, 'Wise') Then
$parameters = '/s'
ElseIf StringInStr($idstring, 'InstallShield AFW') Then
$parameters = '/s /a /s /sms /f1"" /f2""'
ElseIf StringInStr($idstring, 'InstallShield 2003') Then
$parameters = '/v"/qn"'
ElseIf StringInStr($idstring, 'RAR SFX') Then
$parameters = '/s'
Else ;check error! if cann't found parameters
MsgBox(48, "Error!" , "Cann't found Parameters" & @CRLF & "This's a program cann't run or install.")
_reset()
ContinueLoop

EndIf
GUICtrlSetData($Input1, $install)
GUICtrlSetData($Input2, $parameters)
GUICtrlSetState($Button2, $GUI_ENABLE)
;file path split for file.msi and parameters.
Case StringInStr($Executable, 'msi')
$StringSp = StringSplit($Executable, '\')
If StringInStr($StringSp[2], 'msi') Then
$install = $StringSp[2]
ElseIf StringInStr($StringSp[3], 'msi') Then
$install = $StringSp[3]
ElseIf StringInStr($StringSp[4], 'msi') Then
$install = $StringSp[4]
ElseIf StringInStr($StringSp[5], 'msi') Then
$install = $StringSp[5]
ElseIf StringInStr($StringSp[6], 'msi') Then
$install = $StringSp[6]
ElseIf StringInStr($StringSp[7], 'msi') Then
$install = $StringSp[7]
ElseIf StringInStr($StringSp[8], 'msi') Then
$install = $StringSp[8]
EndIf
GUICtrlSetData($Input1, 'msiexec /i' & ' ' & $install)
GUICtrlSetData($Input2, '/qn')
GUICtrlSetState($Button2, $GUI_ENABLE)
EndSelect
Case $Button2
GUICtrlSetState($Button2, $GUI_DISABLE)
Select ;run or installer program setup.exe
Case StringInStr($executable, 'exe')
Dim $pid
$pid = Run($install & ' ' & $Parameters)
GUICtrlSetData($Label2, "Installing...")
GUICtrlSetColor($Label2, 0x0000FF)
Dim $i = 0
While ProcessExists($pid)
GUICtrlSetData($Progress1, $i)
$i = $i + 1
Sleep(20)
If $i > 100 Then $i = 0
If ProcessExists($pid) = 0 Then ExitLoop
WEnd
ProcessWaitClose($pid)
Sleep(500)
GUICtrlSetData($Progress1, 100)
Sleep(500)
GUICtrlSetData($Label2, "")
MsgBox(64, "" ,"Completed.")
_reset()
;run or installer program setup.msi
Case StringInStr($executable, 'msi')
GUICtrlSetState($Button2, $GUI_DISABLE)
$Parameters = '/qn'
Dim $pid
$pid = Run('msiexec /i' & ' ' & $install & ' ' & $Parameters)
Dim $i = 0
While ProcessExists($pid)
GUICtrlSetData($Progress1, $i)
$i = $i + 1
Sleep(20)
If $i > 100 Then $i = 0
If ProcessExists($pid) = 0 Then ExitLoop
WEnd
ProcessWaitClose($pid)
Sleep(500)
GUICtrlSetData($Progress1, 100)
Sleep(500)
MsgBox(64, "" ,"Completed.")
_reset()
EndSelect
EndSwitch
WEnd
;refresh function.
Func _reset()
GUICtrlSetData($Label2, "Progression")
GUICtrlSetColor($Label2, 0x000000)
GUICtrlSetData($Progress1, 0)
GUICtrlSetData($Input1, "")
GUICtrlSetData($Input2, "")
GUICtrlSetState($Button2, $GUI_DISABLE)
EndFunc
;--------------------------------------end script----------------------------




Tag : .NET, C#, VS 2012 (.NET 4.x), Windows







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-05-03 18:48:39 By : lamaka.tor View : 1494 Reply : 7
 

 

No. 1



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook








แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-04 10:32:39 By : lamaka.tor
 


 

No. 2



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ดันซักหน่อยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-10 09:41:46 By : lamaka.tor
 

 

No. 3



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-18 14:44:09 By : lamaka.tor
 


 

No. 4



โพสกระทู้ ( 242 )
บทความ ( 0 )



สถานะออฟไลน์


ลองเอาไปดูนะครับ



https://www.autoitscript.com/autoit3/docs/
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-24 06:49:45 By : bigsuntat
 


 

No. 5



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 4 เขียนโดย : bigsuntat เมื่อวันที่ 2016-05-24 06:49:45
รายละเอียดของการตอบ ::
Autoit ผมทำได้แล้วครับท่าน
แต่ผมจะเอามาเขียนเป็น C# ครับ
ติดที่การอ่านค่าของ control ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-24 08:31:33 By : lamaka.tor
 


 

No. 6

Guest


ถ้า VB.NET ใช้ AutoitX Library แบบในคลิปมาเขียนจะได้ไหมครับ ?

https://www.youtube.com/watch?v=PNOUkgN8ewU

ตัวอย่างโค้ด :
Code (VB.NET)
Imports AutoItX3Lib

Public Class MainForm
    Dim AutoitCommand As New AutoItX3

    Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
   AutoitCommand.Run("notepad.exe")
       AutoitCommand.WinWait("Untitled - Notepad")
       AutoitCommand.Send("This text sent to notepad by autoit functions{ENTER}Have Fun")
       AutoitCommand.Sleep(1000)
       AutoitCommand.WinKill("Untitled - Notepad")
       End
    End Sub
End Class

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-24 09:28:03 By : Pebble
 


 

No. 7



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 6 เขียนโดย : Pebble เมื่อวันที่ 2016-05-24 09:28:03
รายละเอียดของการตอบ ::
ขอบคุณมากครับ
ลองทำตามแล้ว เรียกใช้ AutoItX3Lib.AutoItX3 ได้ครับ
แต่ติดตรง
Code
Run(@ScriptDir & '\Plugin\PEiD.exe -hard ' & '"' & $executable & '"') WinSetState($title_peid, '', @SW_HIDE) $textstring = ControlGetText($title_peid, '', 'Edit1') $idstring = ControlGetText($title_peid, '', 'Edit2') While ($idstring = 'Scanning...') Or ($idstring = '') $textstring = ControlGetText($title_peid, '', 'Edit1') $idstring = ControlGetText($title_peid, '', 'Edit2') WEnd WinClose($title_peid)


ผมเขียนแบบนี้
Code (C#)
AutoItX3Lib.AutoItX3 Aut = new AutoItX3Lib.AutoItX3();
            string title_peid = "PEiD v0.94";
            Aut.Run(@"I:\Program\PEiD.exe -hard '"  + @"I:\Program\mp3gain-win-1_2_5.exe" + "'");
            Aut.WinSetState(title_peid, "",Aut.SW_HIDE);
            System.Threading.Thread.Sleep(1500);
string textstring = Aut.ControlGetText(title_peid, "", "Edit1");
string idstring = Aut.ControlGetText(title_peid, "", "Edit2");
while (idstring == "Scanning..." || idstring == "")
{
     textstring = Aut.ControlGetText(title_peid, "", "Edit1");
     idstring = Aut.ControlGetText(title_peid, "", "Edit2");
}
Aut.WinClose(title_peid);
MessageBox.Show(textstring + " "+ idstring);



มันไม่ส่งค่า Edit2 กลับมายัง idstring ยังหาสาเหตุไม่ได้เช่นกันว่าติดจากตัวไหนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-05-24 13:36:29 By : lamaka.tor
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : C# WinApp อยากทราบว่าสามารถเอาข้อความใน textbox หรือ label จาก Program อื่นมาใช้งานได้ไม๊ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่