Partykilla Posted January 4, 2013 Posted January 4, 2013 Could someone be so kaind and help me put a hotkey to send the results? This would be a Pincode generator, And I would like it to have a hotkey (F4) to: send($results) AND update the Input and Lable box. And I would like to have the hotkey disabled if it's clicked within the GUI It'll be used to generate pincodes for keycards within another software. Ty for help in advance! In short: I would like F4 to do the same as if you would click "$button1" Only to also send it to active window. <The generated pincode that is. expandcollapse popup#include #include #include _Main() Func _Main() Local $button1, $button2 Local $output, $die, $msg, $results GUICreate("Nokas 4 Pin Generator", 265, 150, -1, -1) GUICtrlCreatePic("nokas.gif", 170, 50, 85, 70) GUICtrlCreateLabel("GENERERT PIN KODE:", 30, 15, 150, 15) $button1 = GUICtrlCreateButton("Generer (F4)", 15, 105, 150, 30) $button2 = GUICtrlCreateButton("C", 185, 105, 65, 30, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 240) $output = GUICtrlCreateInput("####", 15, 45, 150, 50, BitOR($BS_PUSHLIKE, $SS_CENTER)) $die = GUICtrlCreateLabel(" Nokas", 185, 15, 70, 20, 0x1000) GUICtrlSetFont($output, 24, 800, "", "Comic Sans MS") GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results = Random(1000, 9999, 1) GUICtrlSetData($output, $results) GUICtrlSetData($die, " Ferdig") Case $msg = $button2 GUICtrlSetData($output, "####") GUICtrlSetData($die, " Klar") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc
Partykilla Posted January 4, 2013 Author Posted January 4, 2013 #include's are: GUIConstantsEx.au3 ButtonConstants.au3 StaticConstants.au3>
Developers Jos Posted January 4, 2013 Developers Posted January 4, 2013 What was the problem you had implementing this yourself? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Partykilla Posted January 5, 2013 Author Posted January 5, 2013 What was the problem you had implementing this yourself?Yeah I cannot get it to work without failing bigtime
Developers Jos Posted January 5, 2013 Developers Posted January 5, 2013 The intent was that you would show what you have that is not working Here is something to play with: expandcollapse popup#include<GUIConstantsEx.au3> #include<ButtonConstants.au3> #include<StaticConstants.au3> ; _Main() ; Func _Main() Local $button1, $button2 Local $msg, $results Global $output, $die GUICreate("Nokas 4 Pin Generator", 265, 150, -1, -1) GUICtrlCreatePic("nokas.gif", 170, 50, 85, 70) GUICtrlCreateLabel("GENERERT PIN KODE:", 30, 15, 150, 15) $button1 = GUICtrlCreateButton("Generer (F4)", 15, 105, 150, 30) $button2 = GUICtrlCreateButton("C", 185, 105, 65, 30, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 240) global $output = GUICtrlCreateInput("####", 15, 45, 150, 50, BitOR($BS_PUSHLIKE, $SS_CENTER)) Global $die = GUICtrlCreateLabel(" Nokas", 185, 15, 70, 20, 0x1000) GUICtrlSetFont($output, 24, 800, "", "Comic Sans MS") GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results = Random(1000, 9999, 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $results = ' & $results & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console GUICtrlSetData($output, $results) GUICtrlSetData($die, " Ferdig") HotKeySet("{F4}", "SendData") Case $msg = $button2 GUICtrlSetData($output, "####") GUICtrlSetData($die, " Klar") HotKeySet("{F4}") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main ; Func SendData() Send(GUICtrlRead($output)) GUICtrlSetData($output, "####") GUICtrlSetData($die, " Klar") EndFunc ;==>SendData Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
czardas Posted January 5, 2013 Posted January 5, 2013 (edited) Another option instead of using a hotkey would be to use an accelerator. I didn't notice Jos had already replied, but here's the example I was writing, in case you find a useful: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> _Main() Func _Main() Local $button1, $button2 Local $output, $die, $msg, $results GUICreate("Nokas 4 Pin Generator", 265, 150, -1, -1) GUICtrlCreatePic("nokas.gif", 170, 50, 85, 70) GUICtrlCreateLabel("GENERERT PIN KODE:", 30, 15, 150, 15) $button1 = GUICtrlCreateButton("Generer (F4)", 15, 105, 150, 30) $button2 = GUICtrlCreateButton("C", 185, 105, 65, 30, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 240) $output = GUICtrlCreateInput("####", 15, 45, 150, 50, BitOR($BS_PUSHLIKE, $SS_CENTER)) $die = GUICtrlCreateLabel(" Nokas", 185, 15, 70, 20, 0x1000) GUICtrlSetFont($output, 24, 800, "", "Comic Sans MS") Local $hDummy = GUICtrlCreateDummy() ; Create a dummy control to send a message to Local $aAccelKeys[1][2] = [["{F4}", $hDummy]] ; Define the accelerator hey GUISetAccelerators($aAccelKeys) ; Set accelerators GUISetState() While 1 $msg = GUIGetMsg() Switch $msg ; Changed to a Switch statement Case $button1, $hDummy ; Either message will trigger the results. $results = Random(1000, 9999, 1) GUICtrlSetData($output, $results) GUICtrlSetData($die, " Ferdig") Case $button2 GUICtrlSetData($output, "####") GUICtrlSetData($die, " Klar") EndSwitch If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc I like the way it looks BTW. Edited January 5, 2013 by czardas operator64 ArrayWorkshop
Partykilla Posted January 5, 2013 Author Posted January 5, 2013 Thanks for replying to both of you <3 I managed to do exatly what I wanted to now Thanks for inspiring me hehe. Here is the result: expandcollapse popup#include<GUIConstantsEx.au3> #include<ButtonConstants.au3> #include<StaticConstants.au3> HotKeySet("{F4}", "GenHotkey") _Main() ; Func _Main() Local $button1, $button2 Local $msg, $results Global $output, $die GUICreate("Nokas 4 Pin Generator", 265, 150, -1, -1) GUICtrlCreatePic("nokas.gif", 170, 50, 85, 70) GUICtrlCreateLabel("GENERERT PIN KODE:", 30, 15, 150, 15) $button1 = GUICtrlCreateButton("Generer (F4)", 15, 105, 150, 30) $button2 = GUICtrlCreateButton("C", 185, 105, 65, 30, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 240) global $output = GUICtrlCreateInput("####", 15, 45, 150, 50, BitOR($BS_PUSHLIKE, $SS_CENTER)) Global $die = GUICtrlCreateLabel(" Nokas", 185, 15, 70, 20, 0x1000) GUICtrlSetFont($output, 24, 800, "", "Comic Sans MS") GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results = Random(1000, 9999, 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $results = ' & $results & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console GUICtrlSetData($output, $results) GUICtrlSetData($die, " Ferdig") Case $msg = $button2 GUICtrlSetData($output, "####") GUICtrlSetData($die, " Klar") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main ; Func GenHotkey() $results = Random(1000, 9999, 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $results = ' & $results & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console GUICtrlSetData($output, $results) GUICtrlSetData($die, " Ferdig") send($results) EndFunc ;==>SendData This will just simply fill in random pincodes to keycards (Within another system by pressing F4) to access doors
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now