Random Number Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Random Number

15 Jan 2018, 08:17

Hello!, so here is what i have,

- 1 Button
- 2 Edit box
- Random Number Gen..

Code: Select all

Gui, Add, Button, x12 y9 w100 h40 gRandomButton, Get Random Number

Gui, Add, Edit, x122 y9 w70 h40 , Edit
Gui, Add, Edit, x202 y9 w70 h40 , Edit
Gui, Show, x296 y190 h66 w287, New GUI Window
Return

RandomButton:
Gui, Submit, NoHide
Random, randXY, 1, 10

MsgBox, %randXY%
return

GuiClose:
ExitApp
And what i need is, i press on the Button and its Generate a Random Number, and IF

_ I click on the First Edit Box and its wirte the Random Number in the First Edit Box.
_ And if i Click on the Second Edit Box its write the Number in the Second Box.
_ But! after i "write" in a Box i cant Delete it any more.

Thanks for Help and Tipps !.
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: Random Number

16 Jan 2018, 07:26

BoBo wrote::arrow: GuiControl
Thanks for the Tipp but, i dont know how i can use GuiControl with my Problem, do you want Help me ? :)
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Random Number  Topic is solved

16 Jan 2018, 08:04

Try this:

Code: Select all

OnMessage(0x0201, "WM_LBUTTONDOWN")	
Gui, Add, Button, x12 y9 w100 h40 gRandomButton, Get Random Number
Gui, Add, Edit, x122 y9 w70 h40 vEdi1
Gui, Add, Edit, x202 y9 w70 h40 vEdi2
Gui, Show, x296 y190 h66 w287, New GUI Window
Return

RandomButton:
   Random, randXY, 1, 10
   GuiControl, ,%ControlSelected%, %randXY%
return

WM_LBUTTONDOWN() {
   global  
   If (A_Gui and substr(A_GuiControl,1,3) = "Edi") {
      ControlSelected := A_GuiControl
   }   
}
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: Random Number

16 Jan 2018, 08:26

Odlanir wrote:Try this:

Code: Select all

OnMessage(0x0201, "WM_LBUTTONDOWN")	
Gui, Add, Button, x12 y9 w100 h40 gRandomButton, Get Random Number
Gui, Add, Edit, x122 y9 w70 h40 vEdi1
Gui, Add, Edit, x202 y9 w70 h40 vEdi2
Gui, Show, x296 y190 h66 w287, New GUI Window
Return

RandomButton:
   Random, randXY, 1, 10
   GuiControl, ,%ControlSelected%, %randXY%
return

WM_LBUTTONDOWN() {
   global  
   If (A_Gui and substr(A_GuiControl,1,3) = "Edi") {
      ControlSelected := A_GuiControl
   }   
}
Thats Exacly what i needet, thanks ! <3 :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jomaweb and 108 guests