GetWindowThreadProcessId的問題 |
答題得分者是:careychen
|
lirick2003
一般會員 發表:17 回覆:16 積分:11 註冊:2007-02-23 發送簡訊給我 |
[code delphi] unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, TlHelp32, Spin, ComCtrls, jpeg, shellAPI, WinSkinData; type TMainForm = class(TForm) Panel1: TPanel; Panel2: TPanel; Timer1: TTimer; PageControl1: TPageControl; TabSheet2: TTabSheet; Label26: TLabel; Image1: TImage; GroupBox1: TGroupBox; CheckBox1: TCheckBox; ComboBox1: TComboBox; Label10: TLabel; SpinEdit1: TSpinEdit; Label2: TLabel; Label18: TLabel; HotKeyBox1: TComboBox; TabSheet1: TTabSheet; TabSheet3: TTabSheet; GroupBox2: TGroupBox; CheckBox2: TCheckBox; ComboBox2: TComboBox; Label11: TLabel; SpinEdit2: TSpinEdit; Label1: TLabel; Label19: TLabel; HotKeyBox2: TComboBox; HotKeyBox3: TComboBox; Label3: TLabel; SpinEdit3: TSpinEdit; ComboBox3: TComboBox; CheckBox3: TCheckBox; CheckBox4: TCheckBox; ComboBox4: TComboBox; SpinEdit4: TSpinEdit; Label4: TLabel; HotKeyBox5: TComboBox; Label6: TLabel; SpinEdit5: TSpinEdit; ComboBox5: TComboBox; CheckBox5: TCheckBox; CheckBox6: TCheckBox; ComboBox6: TComboBox; SpinEdit6: TSpinEdit; Label7: TLabel; HotKeyBox6: TComboBox; HotKeyBox7: TComboBox; Label8: TLabel; SpinEdit7: TSpinEdit; ComboBox7: TComboBox; CheckBox7: TCheckBox; HotKeyBox4: TComboBox; Edit1: TEdit; Button1: TButton; TabSheet4: TTabSheet; TabSheet5: TTabSheet; Memo1: TMemo; Label5: TLabel; SkinData1: TSkinData; GroupBox3: TGroupBox; MsEnabled: TLabel; MsOnOff: TLabel; MsLoad: TLabel; MapName: TLabel; MapValue: TLabel; MapID: TLabel; MapIDNum: TLabel; PlayerXY: TLabel; PlayerX: TLabel; PlayerY: TLabel; X: TLabel; Y: TLabel; Item: TLabel; ItemValue: TLabel; PlayerLV: TLabel; LVValue: TLabel; Red: TLabel; RedValue: TLabel; Mob: TLabel; MobValue: TLabel; Label36: TLabel; Label37: TLabel; GroupBox4: TGroupBox; Label38: TLabel; Label39: TLabel; GroupBox5: TGroupBox; Label40: TLabel; Label41: TLabel; GroupBox6: TGroupBox; Label42: TLabel; Label43: TLabel; Image3: TImage; Label59: TLabel; Ch: TLabel; ChX: TLabel; HP: TEdit; MaxHP: TEdit; MP: TEdit; MaxMP: TEdit; EXP: TEdit; MaxEXP: TEdit; LV: TEdit; MapIDV: TEdit; MapNameV: TEdit; PX: TEdit; PY: TEdit; ItemV: TEdit; MobV: TEdit; CHV: TEdit; Label12: TLabel; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Label25: TLabel; Label27: TLabel; Label28: TLabel; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; TabSheet6: TTabSheet; AutoClick: TCheckBox; MP3: TEdit; MP2: TEdit; MP1: TEdit; EXPBar: TProgressBar; MPBar: TProgressBar; HPBar: TProgressBar; MPB: TComboBox; MPA: TComboBox; EXPEnabled: TCheckBox; MPEnabled: TCheckBox; LVset: TEdit; EXPset: TEdit; HPB: TComboBox; HPA: TComboBox; HP3: TEdit; HP2: TEdit; HP1: TEdit; HpEnabled: TCheckBox; Label58: TLabel; Label57: TLabel; Label56: TLabel; Label55: TLabel; Label54: TLabel; Label53: TLabel; Label52: TLabel; Label51: TLabel; Label50: TLabel; Label49: TLabel; Label48: TLabel; Label47: TLabel; Label46: TLabel; Label45: TLabel; Label44: TLabel; Label35: TLabel; OffsetA: TTimer; RedV: TEdit; Label60: TLabel; CheckBox8: TCheckBox; ComboBox8: TComboBox; SpinEdit8: TSpinEdit; HotKeyBox8: TComboBox; Label9: TLabel; Timer2: TTimer; Label33: TLabel; CheckBox9: TCheckBox; ComboBox9: TComboBox; SpinEdit9: TSpinEdit; Label34: TLabel; ComboBox14: TComboBox; CheckBox10: TCheckBox; ComboBox10: TComboBox; SpinEdit10: TSpinEdit; Label61: TLabel; ComboBox16: TComboBox; CheckBox11: TCheckBox; ComboBox11: TComboBox; SpinEdit11: TSpinEdit; Label62: TLabel; ComboBox18: TComboBox; procedure Button1Click(Sender: TObject); procedure CheckBox1Click(Sender: TObject); procedure SpinEdit1Change(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Image3Click(Sender: TObject); procedure HpEnabledClick(Sender: TObject); procedure MPEnabledClick(Sender: TObject); procedure EXPEnabledClick(Sender: TObject); procedure OffsetATimer(Sender: TObject); procedure Timer2Timer(Sender: TObject); private { Private declarations } hCurrentWindow: HWnd; procedure TimerTimer(Sender: TObject); public { Public declarations } end; var MainForm: TMainForm; hproc: hWnd; ProcID: hWnd; V_Key: array[0..85] of Word = (VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_INSERT, VK_DELETE, VK_BACK, VK_MENU, VK_CONTROL, VK_SHIFT, VK_SPACE, VK_ESCAPE, VK_RETURN, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, $C0, Ord('1'), Ord('2'), Ord('3'), Ord('4'), Ord('5'), Ord('6'), Ord('7'), Ord('8'), Ord('9'), Ord('0'), $BD, $BB, $DB, $DD, $DC, $BA, $DE, $BC, $BE, $BF, Ord('A'), Ord('B'), Ord('C'), Ord('D'), Ord('E'), Ord('F'), Ord('G'), Ord('H'), Ord('I'), Ord('J'), Ord('K'), Ord('L'), Ord('M'), Ord('N'), Ord('O'), Ord('P'), Ord('Q'), Ord('R'), Ord('S'), Ord('T'), Ord('U'), Ord('V'), Ord('W'), Ord('X'), Ord('Y'), Ord('Z'), VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9 ); implementation {$R *.dfm} function PostMessageX(hWnd:HWND; MSG:UINT; wParam:WPARAM; lParam:LPARAM):LRESULT;stdcall; var DblWord:DWORD; hHandle:THandle; begin hHandle:=LoadLibrary('user32.dll'); DblWord:=DWORD(GetProcAddress(hHandle,'PostMessageA')) 5; asm mov edi,edi push ebp mov esp,ebp jmp [DblWord] end; end; function RPM(hProcess:THANDLE;lpBaseAddress:pointer;lpBuffer:pointer;nSize:DWORD;var NumberOfBytesRead:DWORD):BOOL; stdcall;external'IlvMoney.dll' function OP(dwDesiredAccess:DWORD;bInheritHandle:BOOL;dwProcessId:DWORD):THANDLE; stdcall;external'IlvMoney.dll' function MakeKeyLparam(Index: Integer; keyflag: DWord): DWord; var Firstbyte, Secondbyte: DWord; ScanCode: DWord; S, t: DWord; ChFlag: Integer; begin if keyflag = WM_KEYDOWN then begin Firstbyte := $00 end else Firstbyte := $C0; if Index < 4 then Firstbyte := Firstbyte 1; Firstbyte := Firstbyte * $1000000; ScanCode := MapVirtualKey(V_Key[Index], 0); ScanCode := ScanCode * $10000; S := Firstbyte ScanCode; t := S 1; Result := t; end; procedure TMainForm.TimerTimer(Sender: TObject); var cHwnd: HWnd; Index: integer; begin hCurrentWindow := Findwindow(nil, PChar(Edit1.Text)); Caption := IntToStr(hCurrentWindow); Index := TComboBox(FindComponent('Combobox' IntToStr(TTimer(Sender).Tag))).ItemIndex; if Index < 0 then exit; if hCurrentWindow <> 0 then begin PostMessageX(hCurrentWindow, WM_KEYDOWN, V_Key[Index], MakeKeyLparam(Index, WM_KEYDOWN)); Sleep(100); PostMessageX(hCurrentWindow, WM_KEYUP, V_Key[Index], MakeKeyLparam(Index, WM_KEYUP)); end; end; procedure TMainForm.Button1Click(Sender: TObject); var hWnd : THandle; StarLight:THandle; PID:Cardinal; begin hCurrentWindow := Findwindow(nil, PChar(Edit1.Text)); if hCurrentWindow = 0 then begin ShowMessage('找不到楓之谷'); end; if hCurrentWindow <> 0 then begin MsOnOff.Caption:='已啟動'; GetWindowThreadProcessId(hwnd, PID); StarLight := OP(PROCESS_ALL_ACCESS, False, PID); end; if StarLight = 0 then begin showMessage('楓之谷載入發生錯誤'); MsLoad.Caption:='錯誤'; end; if StarLight <> 0 then begin //MsLoad.Caption:='載入成功'; Edit1.Enabled:=False ; Button1.Enabled:=False ; //------▽▽開啟保護區選項▽▽------ HpEnabled.Enabled:=True ; MpEnabled.Enabled:=True ; EXPEnabled.Enabled:=True ; //AutoClick.Enabled:=True ; //------▽▽開啟輔助技能區選項▽▽------ //CheckBox區▽ CheckBox1.Enabled:=True ; CheckBox2.Enabled:=True ; CheckBox3.Enabled:=True ; CheckBox4.Enabled:=True ; CheckBox5.Enabled:=True ; CheckBox6.Enabled:=True ; CheckBox7.Enabled:=True ; CheckBox8.Enabled:=True ; CheckBox9.Enabled:=True ; CheckBox10.Enabled:=True ; CheckBox11.Enabled:=True ; //ComboBox區▽ ComboBox1.Enabled:=True ; ComboBox2.Enabled:=True ; ComboBox3.Enabled:=True ; ComboBox4.Enabled:=True ; ComboBox5.Enabled:=True ; ComboBox6.Enabled:=True ; ComboBox7.Enabled:=True ; ComboBox8.Enabled:=True ; ComboBox9.Enabled:=True ; ComboBox10.Enabled:=True ; ComboBox11.Enabled:=True ; //Dalay區▽ SpinEdit1.Enabled:=True ; SpinEdit2.Enabled:=True ; SpinEdit3.Enabled:=True ; SpinEdit4.Enabled:=True ; SpinEdit5.Enabled:=True ; SpinEdit6.Enabled:=True ; SpinEdit7.Enabled:=True ; SpinEdit8.Enabled:=True ; SpinEdit9.Enabled:=True ; SpinEdit10.Enabled:=True ; SpinEdit11.Enabled:=True ; //HotKeys區▽ HotKeyBox1.Enabled:=True ; {HotKeyBox2.Enabled:=True ; HotKeyBox3.Enabled:=True ; HotKeyBox4.Enabled:=True ; HotKeyBox5.Enabled:=True ; HotKeyBox6.Enabled:=True ; HotKeyBox7.Enabled:=True ; HotKeyBox8.Enabled:=True ;} end; end; procedure TMainForm.CheckBox1Click(Sender: TObject); var delaytime: integer; t: integer; SE: TSpinEdit; begin t := TCheckBox(Sender).Tag; SE := TSpinEdit(FindComponent('SpinEdit' IntToStr(t))); if TCheckBox(Sender).Checked then begin TTimer.Create(Self).Name := 'rTm' IntToStr(t); if TTimer(FindComponent('rTm' IntToStr(t))) <> nil then begin TTimer(FindComponent('rTm' IntToStr(t))).Enabled := false; if SE <> nil then delaytime := SE.Value else delaytime := 100; TTimer(FindComponent('rTm' IntToStr(t))).Interval := delaytime; TTimer(FindComponent('rTm' IntToStr(t))).Tag := t; TTimer(FindComponent('rTm' IntToStr(t))).Enabled := true; TTimer(FindComponent('rTm' IntToStr(t))).OnTimer := TimerTimer; end; end else begin TTimer(FindComponent('rTm' IntToStr(TCheckBox(Sender).Tag))).Enabled := false; TTimer(FindComponent('rTm' IntToStr(TCheckBox(Sender).Tag))).Free; //FreeAndNil(TTimer(FindComponent('rTm' IntToStr(TCheckBox(Sender).Tag)))); end; end; procedure TMainForm.SpinEdit1Change(Sender: TObject); var Tm: TTimer; begin Tm := TTimer(FindComponent('rTm' IntToStr(TSpinEdit(Sender).Tag))); if Assigned(Tm) then begin Tm.Interval := TSpinEdit(Sender).Value; if Tm.Enabled then begin Tm.Enabled := false; Tm.Enabled := true; end; end; end; procedure TMainForm.FormCreate(Sender: TObject); begin hCurrentWindow := Findwindow(nil, 'MapleStory'); Caption := IntToStr(hCurrentWindow); end; procedure TMainForm.Timer1Timer(Sender: TObject); var i, j: integer; begin for i := 17 to 28 do begin if odd(GetAsyncKeyState(V_Key[i])) then //for j := 1 to 13 do for j := 1 to 11 do if TComboBox(FindComponent('HotKeyBox' IntToStr(j))).ItemIndex = (i-17) then begin TCheckBox(FindComponent('CheckBox' IntToStr(j))).Checked := not TCheckBox(FindComponent('CheckBox' IntToStr(j))).Checked; end; end; end; procedure TMainForm.Image3Click(Sender: TObject); begin if messagedlg('你是否要訪問浪漫月光吸怪版網站',mtconfirmation,[mbyes,mbno],0)=mryes then begin ShellExecute(0, pchar('open'),pchar('http://bbs.yoyo-do.com/forumdisplay.php?fid=76'), pchar(''),pchar(''), SW_MAXIMIZE ); end; end; procedure TMainForm.HpEnabledClick(Sender: TObject); begin HP1.Enabled:=HpEnabled.checked; HP2.Enabled:=HpEnabled.checked; HP3.Enabled:=HpEnabled.checked; HPA.Enabled:=HpEnabled.checked; HPB.Enabled:=HpEnabled.checked; end; procedure TMainForm.MPEnabledClick(Sender: TObject); begin MP1.Enabled:=MpEnabled.checked; MP2.Enabled:=MpEnabled.checked; MP3.Enabled:=MpEnabled.checked; MPA.Enabled:=MpEnabled.checked; MPB.Enabled:=MpEnabled.checked; end; procedure TMainForm.EXPEnabledClick(Sender: TObject); begin EXP.Enabled:=EXPEnabled.checked; LV.Enabled:=EXPEnabled.checked; end; procedure TMainForm.OffsetATimer(Sender: TObject); var address,address2,addressoff: dword; processhandle: thandle; read,realvalue: dword; check: boolean; StarLight:THandle; begin if StarLight <> 0 then begin address:=($009443A4); addressoff:=($18); check:=RPM(processhandle,pointer(address),@address2,4,read); check:=RPM(processhandle,pointer(address2 addressoff),@realvalue,4,read); RedV.Text:=IntToStr(realvalue); RedValue.Caption:=RedV.Text; end; end; procedure TMainForm.Timer2Timer(Sender: TObject); {var i, j: integer; } begin { for i := 17 to 28 do begin if odd(GetAsyncKeyState(V_Key[i])) then for j := 2 to 4 do if TComboBox(FindComponent('HotKeyBox' IntToStr(j))).ItemIndex = (i-17) then begin TCheckBox(FindComponent('CheckBox' IntToStr(j))).Checked := not TCheckBox(FindComponent('CheckBox' IntToStr(j))).Checked; end; end; } end; end. 我想問一下,當我按下Button1時...我要讓他去GetWindowThreadProcessId... 但是不知道哪裡出錯了~ [/code] |
careychen
尊榮會員 發表:41 回覆:580 積分:959 註冊:2004-03-03 發送簡訊給我 |
因為你把型態當變數用,不過~~看來你好像在寫機器人???
===================引 用 lirick2003 文 章=================== [code delphi] .... (略) procedure TMainForm.Button1Click(Sender: TObject); var hWnd : THandle; /// 這個是錯的 StarLight:THandle; PID:Cardinal; begin hCurrentWindow := Findwindow(nil, PChar(Edit1.Text)); if hCurrentWindow = 0 then begin ShowMessage('找不到楓之谷'); end; if hCurrentWindow <> 0 then begin MsOnOff.Caption:='已啟動'; GetWindowThreadProcessId(hwnd, PID); /// 這個是錯的 StarLight := OP(PROCESS_ALL_ACCESS, False, PID); end; ..... (略) [/code]
------
價值的展現,來自於你用哪一個角度來看待它!! |
lirick2003
一般會員 發表:17 回覆:16 積分:11 註冊:2007-02-23 發送簡訊給我 |
請問這樣對嗎?
[code delphi] procedure TMainForm.Button1Click(Sender: TObject); var hw : Hwnd; StarLight:THandle; PID:DWord; begin hCurrentWindow := Findwindow(nil, PChar(Edit1.Text)); if hCurrentWindow = 0 then begin ShowMessage('找不到@#$@%); end; if hCurrentWindow <> 0 then begin GetWindowThreadProcessId(hw, PID); StarLight := OP(PROCESS_ALL_ACCESS, False, PID); end;[/code]
編輯記錄
lirick2003 重新編輯於 2008-07-27 12:36:39, 註解 無‧
|
careychen
尊榮會員 發表:41 回覆:580 積分:959 註冊:2004-03-03 發送簡訊給我 |
目前這樣是對的,因為你只要不用型態當變數名就行了, 至於程式能不能執行就看你原本的能不能 Run 囉
===================引 用 lirick2003 文 章=================== 請問這樣對嗎? [code delphi] procedure TMainForm.Button1Click(Sender: TObject); var hw : Hwnd; StarLight:THandle; PID:DWord; begin hCurrentWindow := Findwindow(nil, PChar(Edit1.Text)); if hCurrentWindow = 0 then begin ShowMessage('找不到@#$@%); end; if hCurrentWindow <> 0 then begin GetWindowThreadProcessId(hw, PID); StarLight := OP(PROCESS_ALL_ACCESS, False, PID); end;[/code]
------
價值的展現,來自於你用哪一個角度來看待它!! |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |