Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz
  • 0

Wciskanie klawisza z comboboxa


Kacapek

Pytanie

Opublikowano

Witam, jak zrobić, żeby program naciskał wybrany klawisz z comboboxa? W comboboxie mam wstawione F1-F12 i chce żeby program używał wybranego przeze mnie. Ewentualnie czy jest możliwość żeby wpisać w "pole" (nie wiem jak to nazwać) powiedzmy F1 i żeby to było wstawiane?

reklama

15 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

Opublikowano
GUICtrlSetOnEvent($Button1,"A")
GUICtrlSetOnEvent($Button2,"B")

Global $aPosition = FileRead("aPos.txt")						
Global $aColor

 Func A()
		    MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
   $aPos = MouseGetPos()
	FileWrite("aPos.txt", "["&$aPos4[0]&", " & $aPos4[1]&"]")
   $aColor = PixelGetColor($aPosition[0], $aPosition[1])

    MsgBox(0, "Info", "Selected")
    Return $aPos
 EndFunc

Zapisuje pozycje ale mam problem z odczytaniem jej.

reklama

Opublikowano

Napisałem wyzej jak pobiera sie zapisane wartości z pliku ini. Rownie dobrze mozesz sobie sobie zapisac do zmiennej globalej, albo przy kazdym wywolaniu funkcji czytac z pliku.

 

Global $aPosition
Global $aColor

Global $bPosition
Global $bColor

Func JakasFunkcja()
	Local $aPosition[2]
	$aPosition[0] = IniRead($INI_PATH, "A()", "X1", "Default Value")
	$aPosition[1] = IniRead($INI_PATH, "A()", "Y1", "Default Value")

	If $aPosition[0] == "Default Value" or $aPosition[1] == "Default Value" Then
		$aPosition = A()
	EndIf

	If PixelGetColor($aPosition[0], $aPosition[1]) <> $aColor Then
	  MouseMove(245, 647)
	  MouseClick("primary")
	  Sleep(150)
	  MouseMove(1090, 501)
	EndIf
EndFunc

Func A()
	MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
   $aPosition = MouseGetPos()
   $aColor = PixelGetColor($aPosition[0], $aPosition[1])

	IniWrite($INI_PATH, "A()", "X1", $aPosition[0])
	IniWrite($INI_PATH, "A()", "Y1", $aPosition[1])
    MsgBox(0, "Info", "Selected")
    Return $aPosition
EndFunc

 

 

 

Opublikowano

Coś takiego?

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 208, 166, 192, 124)
$Combo1 = GUICtrlCreateCombo("F1", 16, 32, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "F1|F2|F3|F4|F5", "F1")
$Input1 = GUICtrlCreateInput("F1", 16, 64, 121, 21)
$Button1 = GUICtrlCreateButton("Ustaw z Input1", 64, 96, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Combo1
			SetHotkey($Combo1)
		Case $Button1
			SetHotkey($Input1)
	EndSwitch
WEnd

Func SetHotkey($Control)
	Local $key = GUICtrlRead($Control)
	HotKeySet("{" & $key & "}", "whoa")
	MsgBox(0, '', 'Nacisnij ' & $key)
EndFunc

Func whoa()
	MsgBox(0, '','Whoa..')
EndFunc

 

#Edit

 

Chociaż chyba bardziej chodzi o to:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 208, 166, 192, 124)
$Combo1 = GUICtrlCreateCombo("F1", 16, 32, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "F1|F2|F3|F4|F5", "F1")
$Input1 = GUICtrlCreateInput("F1", 16, 64, 121, 21)
$Button1 = GUICtrlCreateButton("Ustaw z Input1", 64, 96, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Combo1
			spam(GUICtrlRead($Combo1))
		Case $Button1
			spam(GUICtrlRead($Input1))
	EndSwitch
WEnd

Func spam($key)
	Local $spam_key = "{" & $key & "}"
	While 1
		Send($spam_key)
	WEnd
EndFunc

 

 

 

Opublikowano

Używam w programie wielu combo boxów i mouseget pos. Jest możliwość żeby zapisać te elementy żebym po ponownym włączeniu programu nie musiał wszystkiego wybierać na nowo?

reklama

Opublikowano

A jak teraz odczytać te zapisane wartości żebym mógł wykorzystać w dalszych funkcjach?

 

Global $aPosition
Global $aColor

Global $bPosition
Global $bColor


 If PixelGetColor($aPosition[0], $aPosition[1]) <> $aColor Then
			  MouseMove(245, 647)
			  MouseClick("primary")
			  Sleep(150)
			  MouseMove(1090, 501)
			  EndIf

 

reklama

Opublikowano

Mam taki kod:

 While 2
		 If GUICtrlRead($Checkbox1) = 1 Then  $pos1 = PixelSearch(457, 27, 457, 29, 0x232323)
			 If IsArray($pos1) Then
			  Send("{F1}")           ;<Tutaj
			  EndIf
			EndIf
			
			If GUICtrlRead($Checkbox2) = 1 Then  $pos2 = PixelSearch(1194, 405, 1347, 428, 0x00C000)
			 If IsArray($pos2) Then
			  MouseMove($pos2[0], $pos[1], 0)
			  MouseClick("primary")
			  Sleep(10000)
			  EndIf
			EndIf
		   WEnd

Mógł byś mi pomóc jakoś to połączyć?

 

reklama

Opublikowano

Chodzi mi o to żeby program był uniwersalny, czyli wybieramy punkty u siebie na komputerze aby program dobrze działał. Chciał bym żeby była możliwość zapisania tych funkcji żeby za każdym nie trzeba było wybierać 10 punktów na nowo. Nie mam zielonego pojęcia jak można by użyć w tym przypadku iniWrite iniRead

 

GUICtrlSetOnEvent($Button1,"A")
GUICtrlSetOnEvent($Button2,"B")

Global $aPosition						
Global $aColor

Global $bPosition							
Global $bColor

Global $cPosition					
Global $cColor

 Func A()
		    MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
   $aPosition = MouseGetPos()
   $aColor = PixelGetColor($aPosition[0], $aPosition[1])

    MsgBox(0, "Info", "Selected")
    Return $aPosition
 EndFunc

 Func B()
		    MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
   $bPosition = MouseGetPos()
   $bColor = PixelGetColor($bPosition[0], $bPosition[1])

    MsgBox(0, "Info", "Selected")
    Return $bPosition
 EndFunc

 

reklama

Opublikowano
Do zapisania:
FileWrite("punkta.txt","PUNKT A"&@CRLF)
FileWrite("punktb.txt","PUNKT B"&@CRLF)

Do odczytania:
FileReadLine("punkta.txt",1)
FileReadLine("punktb.txt",1)

 

Opublikowano

Taki sposób to słaby pomysł. Jak bedziesz mial powiedzmy 50 roznych wartosci to bedziesz tworzyl 50 plikow? :D

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 241, 127, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 8, 16, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 8, 80, 75, 25)
$Input1 = GUICtrlCreateInput("X1", 96, 16, 41, 21)
$Input2 = GUICtrlCreateInput("Y2", 145, 16, 55, 21)
$Input3 = GUICtrlCreateInput("X2", 96, 80, 41, 21)
$Input4 = GUICtrlCreateInput("Y2", 144, 80, 57, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $aPosition
Global $aColor

Global $bPosition
Global $bColor

Global $cPosition
Global $cColor

Global $INI_PATH = @DesktopDir & "\plik.ini"

Load()

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			A()
		Case $Button2
			B()
	EndSwitch
WEnd



 Func A()
	MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
   $aPosition = MouseGetPos()
   $aColor = PixelGetColor($aPosition[0], $aPosition[1])

	IniWrite($INI_PATH, "A()", "X1", $aPosition[0])
	IniWrite($INI_PATH, "A()", "Y1", $aPosition[1])
    MsgBox(0, "Info", "Selected")
    Return $aPosition
 EndFunc

Func B()
	MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
	Do
		Sleep(50)
	Until _IsPressed(01)
	$bPosition = MouseGetPos()
	$bColor = PixelGetColor($bPosition[0], $bPosition[1])

	IniWrite($INI_PATH, "B()", "X2", $bPosition[0])
	IniWrite($INI_PATH, "B()", "Y2", $bPosition[1])
	MsgBox(0, "Info", "Selected")
	Return $bPosition
EndFunc

Func Load()
	If Not FileExists($INI_PATH) Then Return

	GUICtrlSetData($Input1, IniRead($INI_PATH, "A()", "X1", "Default Value"))
	GUICtrlSetData($Input2, IniRead($INI_PATH, "A()", "Y1", "Default Value"))
	GUICtrlSetData($Input3, IniRead($INI_PATH, "B()", "X2", "Default Value"))
	GUICtrlSetData($Input4, IniRead($INI_PATH, "B()", "Y2", "Default Value"))
EndFunc

 

 

 

Opublikowano

Dalej mam z tym problem ;/ Pomoże ktoś? Wywala taki błąd:

"C:\Users\Karol\Desktop\test.au3" (331) : ==> Expected a "=" operator in assignment statement.:
$position4[0] = IniRead($INI_PATH, "A", "x", $pos4[0])
$position4^ ERROR

 

    Func A()
		    MsgBox(0, "Info", "Select point" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
   $pos4 = MouseGetPos()

   IniWrite($INI_PATH, "A", "x", $pos4[0])
    IniWrite($INI_PATH, "A", "y", $pos4[1])


    MsgBox(0, "Info", "Selected")
    EndFunc

Func _START()
		If GUICtrlRead($Checkbox2) = 1 Then				
		EndIf
		$position4[0] = IniRead($INI_PATH, "A", "x", $pos4[0])
		$position4[1] = IniRead($INI_PATH, "A", "y", $pos4[1])

		Local $color4 = PixelGetColor($position4[0], $position4[1])


		 If PixelGetColor($position4[0], $position4[1]) = $color4 Then
			Send("{" & GUICtrlRead($Combo4) & "}")
			Sleep(250)
		 EndIf
EndFunc

 

reklama

Opublikowano

A jak masz zadeklarowane $position4 ? Obstawiam, że:

Global $position4

Zamiast

Global $position4[2]

 

Jak juz wrzucasz kod to wrzucaj taki który da się uruchomic i przetestować, a nie sobie wybierasz losowo 10 linijek i je wklejasz.

 

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...