Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - Shortcut - trayicon
Forum - Visual Basic 6 - Shortcut - trayicon

Avatar
TSP (Ex-Member)
Pro


Messaggi: 99
Iscritto: 17/03/2008

Segnala al moderatore
Postato alle 20:23
Martedì, 06/05/2008
Ho creato un software che volendo si riduce a trayicon e vorrei sapere se è possibile utilizzare gli shortcut (ex Ctrl + C per copiare) mentre è nella tryicon

grazie in anticipo per eventuali risp:k:

PM Quote
Avatar
kryc (Normal User)
Rookie


Messaggi: 23
Iscritto: 10/12/2007

Segnala al moderatore
Postato alle 20:48
Martedì, 06/05/2008
non si capisce bene, vuoi copiare elementi all'interno del programma o intendi copiare le cose esterne mentre il programma è minimizzato?

PM Quote
Avatar
TSP (Ex-Member)
Pro


Messaggi: 99
Iscritto: 17/03/2008

Segnala al moderatore
Postato alle 14:45
Mercoledì, 07/05/2008
No forse non hai capito, ctrl+C era un esempio comunque è un riproduttore di files audio, se io lo tengo nella tryicon e volessi che con ctrl + W facesse pausa come faccio???:k:

PM Quote
Avatar
kryc (Normal User)
Rookie


Messaggi: 23
Iscritto: 10/12/2007

Segnala al moderatore
Postato alle 17:59
Mercoledì, 07/05/2008
Non credo, dipende da che applicativo hai in primo piano , se hai aperto altri programmi aperti che stai usando che dispongono delle shortcut penso che il tuo comando vada a scatenare eventi del programma aperto e non quello in background.
Ho fatto una prova col media player in background, e nno funzionano le shortcut

PM Quote
Avatar
TSP (Ex-Member)
Pro


Messaggi: 99
Iscritto: 17/03/2008

Segnala al moderatore
Postato alle 14:17
Giovedì, 08/05/2008
io pensavo al getasynckey che si usa anche nei keylogger non si potrebbe adattare???

PM Quote
Avatar
GrG (Member)
Guru^2


Messaggi: 3430
Iscritto: 21/08/2007

Segnala al moderatore
Postato alle 16:50
Giovedì, 08/05/2008
IN UN MODULO:

Codice sorgente - presumibilmente VB.NET

  1. Global LastKey As String
  2. Global timeout As Byte
  3. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  4.  
  5. Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
  6.  
  7.  
  8. Public Function GetCapslock() As Boolean
  9. ' Return or set the Capslock toggle.
  10.  
  11. GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
  12.  
  13. End Function
  14.  
  15. Public Function GetShift() As Boolean
  16.  
  17. ' Return or set the Capslock toggle.
  18.  
  19. GetShift = CBool(GetAsyncKeyState(vbKeyShift))
  20.  
  21. End Function



Nel Form:

Codice sorgente - presumibilmente VB.NET

  1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  2.  
  3.  
  4. Private Sub Timer1_Timer()
  5. Dim FoundKeys As String
  6.  
  7. On Error Resume Next
  8.  
  9. Dim AddKey
  10.  
  11. KeyResult = GetAsyncKeyState(13)
  12. If KeyResult = -32767 Then
  13. AddKey = vbCrLf
  14. GoTo KeyFound
  15. End If
  16. KeyResult = GetAsyncKeyState(8)
  17. If KeyResult = -32767 Then
  18. l = Len(Text1.Text)
  19. AddKey = "[Backspace]"
  20. GoTo KeyFound
  21. End If
  22.  
  23.  
  24.  
  25. '------------FUNCTION KEYS
  26. '------------SPECIAL KEYS
  27.  
  28. KeyResult = GetAsyncKeyState(32)
  29. If KeyResult = -32767 Then
  30. AddKey = " "
  31. GoTo KeyFound
  32. End If
  33.  
  34. KeyResult = GetAsyncKeyState(186)
  35. If KeyResult = -32767 Then
  36. If GetShift = False Then AddKey = "è" Else AddKey = "é"
  37. GoTo KeyFound
  38. End If
  39.  
  40. KeyResult = GetAsyncKeyState(187)
  41. If KeyResult = -32767 Then
  42. If GetShift = False Then AddKey = "+" Else AddKey = "*"
  43. GoTo KeyFound
  44. End If
  45.  
  46. KeyResult = GetAsyncKeyState(188)
  47. If KeyResult = -32767 Then
  48. If GetShift = False Then AddKey = "," Else AddKey = ";"
  49. GoTo KeyFound
  50. End If
  51.  
  52. KeyResult = GetAsyncKeyState(189)
  53. If KeyResult = -32767 Then
  54. If GetShift = False Then AddKey = "-" Else AddKey = "_"
  55. GoTo KeyFound
  56. End If
  57.  
  58. KeyResult = GetAsyncKeyState(190)
  59. If KeyResult = -32767 Then
  60. If GetShift = False Then AddKey = "." Else AddKey = ":"
  61. GoTo KeyFound
  62. End If
  63.  
  64. KeyResult = GetAsyncKeyState(191)
  65. If KeyResult = -32767 Then
  66. If GetShift = False Then AddKey = "ù" Else AddKey = "§" '/
  67. GoTo KeyFound
  68. End If
  69.  
  70. KeyResult = GetAsyncKeyState(192)
  71. If KeyResult = -32767 Then
  72. If GetShift = False Then AddKey = "ò" Else AddKey = "ç" '`
  73. GoTo KeyFound
  74. End If
  75.  
  76.  
  77.  
  78. '----------NUM PAD
  79. KeyResult = GetAsyncKeyState(96)
  80. If KeyResult = -32767 Then
  81. If GetShift = False Then AddKey = "0" Else AddKey = "="
  82. GoTo KeyFound
  83. End If
  84.  
  85. KeyResult = GetAsyncKeyState(97)
  86. If KeyResult = -32767 Then
  87. If GetShift = False Then AddKey = "1" Else AddKey = "!"
  88. GoTo KeyFound
  89. End If
  90.  
  91.  
  92. KeyResult = GetAsyncKeyState(98)
  93. If KeyResult = -32767 Then
  94. If GetShift = False Then AddKey = "2" Else AddKey = Chr(34)
  95. GoTo KeyFound
  96. End If
  97.  
  98. KeyResult = GetAsyncKeyState(99)
  99. If KeyResult = -32767 Then
  100. If GetShift = False Then AddKey = "3" Else AddKey = "£"
  101. GoTo KeyFound
  102. End If
  103.  
  104.  
  105. KeyResult = GetAsyncKeyState(100)
  106. If KeyResult = -32767 Then
  107. If GetShift = False Then AddKey = "4" Else AddKey = "$"
  108. GoTo KeyFound
  109. End If
  110.  
  111. KeyResult = GetAsyncKeyState(101)
  112. If KeyResult = -32767 Then
  113. If GetShift = False Then AddKey = "5" Else AddKey = "%"
  114. GoTo KeyFound
  115. End If
  116.  
  117.  
  118. KeyResult = GetAsyncKeyState(102)
  119. If KeyResult = -32767 Then
  120. If GetShift = False Then AddKey = "6" Else AddKey = "&"
  121. GoTo KeyFound
  122. End If
  123.  
  124. KeyResult = GetAsyncKeyState(103)
  125. If KeyResult = -32767 Then
  126. If GetShift = False Then AddKey = "7" Else AddKey = "/"
  127. GoTo KeyFound
  128. End If
  129.  
  130.  
  131. KeyResult = GetAsyncKeyState(104)
  132. If KeyResult = -32767 Then
  133. If GetShift = False Then AddKey = "8" Else AddKey = "("
  134. GoTo KeyFound
  135. End If
  136.  
  137. KeyResult = GetAsyncKeyState(105)
  138. If KeyResult = -32767 Then
  139. If GetShift = False Then AddKey = "9" Else AddKey = ")"
  140. GoTo KeyFound
  141. End If
  142.  
  143.  
  144. KeyResult = GetAsyncKeyState(106)
  145. If KeyResult = -32767 Then
  146. If GetShift = False Then AddKey = "'*" Else AddKey = ""
  147. GoTo KeyFound
  148. End If
  149.  
  150. KeyResult = GetAsyncKeyState(107)
  151. If KeyResult = -32767 Then
  152. If GetShift = False Then AddKey = "+" Else AddKey = "+"
  153. GoTo KeyFound
  154. End If
  155.  
  156. KeyResult = GetAsyncKeyState(108)
  157. If KeyResult = -32767 Then
  158. AddKey = ""
  159. If GetShift = False Then Text1.Text = Text1.Text & vbCrLf
  160. GoTo KeyFound
  161. End If
  162.  
  163. KeyResult = GetAsyncKeyState(109)
  164. If KeyResult = -32767 Then
  165. If GetShift = False Then AddKey = "-" Else AddKey = "_"
  166. GoTo KeyFound
  167. End If
  168.  
  169. KeyResult = GetAsyncKeyState(110)
  170. If KeyResult = -32767 Then
  171. If GetShift = False Then AddKey = "." Else AddKey = ""
  172. GoTo KeyFound
  173. End If
  174.  
  175. KeyResult = GetAsyncKeyState(2)
  176. If KeyResult = -32767 Then
  177. If GetShift = False Then AddKey = "/" Else AddKey = "/"
  178. GoTo KeyFound
  179. End If
  180.  
  181. KeyResult = GetAsyncKeyState(220)
  182. If KeyResult = -32767 Then
  183. If GetShift = False Then AddKey = "\" Else AddKey = "|"
  184. GoTo KeyFound
  185. End If
  186.  
  187. KeyResult = GetAsyncKeyState(222)
  188. If KeyResult = -32767 Then
  189. If GetShift = False Then AddKey = "à" Else AddKey = °
  190. GoTo KeyFound
  191. End If
  192.  
  193. KeyResult = GetAsyncKeyState(221)
  194. If KeyResult = -32767 Then
  195. If GetShift = False Then AddKey = "ì" Else AddKey = "^"
  196.  
  197.  
  198. GoTo KeyFound
  199. End If
  200.  
  201. KeyResult = GetAsyncKeyState(219) '219
  202. If KeyResult = -32767 Then
  203. If GetShift = False Then AddKey = "[" Else AddKey = "{"
  204. GoTo KeyFound
  205. End If
  206.  
  207.  
  208.  
  209. For n = 65 To 128
  210. KeyResult = GetAsyncKeyState(n)
  211. If KeyResult = -32767 Then
  212. If GetShift = False Then
  213. If GetCapslock = True Then AddKey = UCase(Chr(n)) Else AddKey = LCase(Chr(n))
  214. Else
  215. If GetCapslock = False Then AddKey = UCase(Chr(n)) Else AddKey = LCase(Chr(n))
  216. End If
  217. GoTo KeyFound
  218. End If
  219. Next n
  220.  
  221.  
  222. For n = 48 To 57
  223. KeyResult = GetAsyncKeyState(n)
  224. If KeyResult = -32767 Then
  225. If GetShift = True Then
  226. Select Case Val(Chr(n))
  227. Case 1
  228. AddKey = "!"
  229. Case 2
  230. AddKey = Chr(34)
  231. Case 3
  232. AddKey = "£"
  233. Case 4
  234. AddKey = "$"
  235. Case 5
  236. AddKey = "%"
  237. Case 6
  238. AddKey = "&"
  239. Case 7
  240. AddKey = "/"
  241. Case 8
  242. AddKey = "("
  243. Case 9
  244. AddKey = ")"
  245. Case 0
  246. AddKey = "="
  247. End Select
  248. Else
  249. AddKey = Chr(n)
  250. End If
  251. GoTo KeyFound
  252. End If
  253. Next n
  254. DoEvents
  255. Exit Sub
  256.  
  257. KeyFound:
  258. If AddKey = "A" Then
  259. 'ESEGUI L'AZIONE DI PAUSA
  260. End If
  261. DoEvents
  262. End Sub



L'unico problema è ke può individuare solo UN TASTO premuto NON una COMBINAZIONE tipo ctrl + w

Ultima modifica effettuata da GrG il 08/05/2008 alle 16:51
PM Quote